simfin-1.0.0: A library to fetch and parse financial data from the SimFin(+) API.
Copyright(c) Owen Shepherd 2022
LicenseMIT
Maintainerowen@owen.cafe
Safe HaskellNone
LanguageHaskell2010

SimFin.Common

Description

 
Synopsis

Documentation

data ApiError Source #

Represents all the types of error the server returns, and that we can encounter on our side.

Constructors

DecodeError ByteString String

Can't turn ByteString into JSON

ParseError Value String

Can't turn JSON into result type

Other Text

Server returned '{"error": "..."}' along with a non-200 status code. This could in theory be parsed into machine-readable format, with variants such as `InvalidApiKey | RateLimited | ...`, but the API doesn't guarantee error message stability.

Instances

Instances details
Show ApiError Source # 
Instance details

Defined in SimFin.Common

FromJSON ApiError Source # 
Instance details

Defined in SimFin.Common

type ApiResult = Either ApiError Source #

The result of calling fetch* is either an error or a successful result.

fetchCompanyList :: (MonadThrow m, MonadIO m) => SimFinContext -> m (Either ApiError [CompanyListingRow]) Source #

Fetch a list of company tickers and SimFin ids. This is the only endpoint common to free and paid customers.

performRequest :: (MonadIO m, FromJSON a) => SimFinContext -> ByteString -> [QueryParam] -> m (ApiResult a) Source #

Make a request, all fetch* functions call this.