Safe Haskell | None |
---|---|
Language | Haskell2010 |
CryptoCompare
Description
A haskell wrapper for the cryptocompare API, a source of information and pricing of different crypto currencies
module Main (main) where import CryptoCompare main :: IO () main = do coinList <- fetchCoinList either print (print . length) coinList either print (print . head) coinList priceResp <- fetchCurrentPrice "BTC" ["USD", "EUR", "BTC"] print priceResp priceHistResp <- fetchDailyPriceHistory "BTC" "USD" 300 print priceHistResp snapshotResp <- fetchCoinSnapshot "BTC" "USD" print snapshotResp
- fetchCoinList :: MonadIO m => m (Either String [CoinDetails])
- fetchCurrentPrice :: MonadIO m => String -> [String] -> m (Either String PriceResponse)
- fetchDailyPriceHistory :: MonadIO m => String -> String -> Integer -> m (Either String PriceHistoryResponse)
- fetchCoinSnapshot :: MonadIO m => String -> String -> m (Either String CoinSnapshot)
- data CoinDetails = CoinDetails {}
- data PriceHistoryResponse = PriceHistoryResponse {}
- data PriceHistoryResponseData = PriceHistoryResponseData {}
- data CoinSnapshot = CoinSnapshot {}
- data AggregatedSnapshot = AggregatedSnapshot {
- market :: String
- fromSymbol :: String
- toSymbol :: String
- flags :: String
- price :: Float
- lastUpdate :: Integer
- lastVolume :: Float
- lastVolumeto :: Float
- lastTradeId :: String
- volume24Hour :: Float
- volume24HourTo :: Float
- open24Hour :: Float
- high24Hour :: Float
- low24Hour :: Float
- lastMarket :: String
- newtype PriceResponse = PriceResponse (Map String Float)
Documentation
fetchCoinList :: MonadIO m => m (Either String [CoinDetails]) #
Get a list of all of the coins the API is aware of, and high level details about those coins
do coinList <- fetchCoinList either print (print . length) coinList either print (print . head) coinList
Arguments
:: MonadIO m | |
=> String | Coin symbol ( |
-> [String] | Currency symbol(s) to display prices in. Eg [ |
-> m (Either String PriceResponse) | Either an error or response data |
For a given coin, get the current price
do priceResp <- fetchCurrentPrice "BTC" ["USD", "EUR", "BTC"] print priceResp
Arguments
:: MonadIO m | |
=> String | Coin symbol ( |
-> String | Currency symbol to display prices in ( |
-> Integer | Days of history to return (Max 2000) |
-> m (Either String PriceHistoryResponse) | Either an error or response data |
For a given coin, get a daily history of the coin's price
do priceHistResp <- fetchDailyPriceHistory "BTC" "USD" 300 print priceHistResp
Arguments
:: MonadIO m | |
=> String | Coin symbol ( |
-> String | Currency symbol(s) to display prices in ( |
-> m (Either String CoinSnapshot) | Either an error or response data |
Fetch details about a particular coin
do snapshotResp <- fetchCoinSnapshot "BTC" "USD" print snapshotResp
data CoinDetails #
High level information about each coin.
Constructors
CoinDetails | |
Instances
Show CoinDetails # | |
Generic CoinDetails # | |
FromJSON [CoinDetails] # | |
type Rep CoinDetails # | |
data PriceHistoryResponse #
API response container for daily price history
Constructors
PriceHistoryResponse | |
Fields
|
data PriceHistoryResponseData #
Data for a particular snapshot of a coin's daily price
Constructors
PriceHistoryResponseData | |
data AggregatedSnapshot #
Aggregated data about a particular coin
Constructors
AggregatedSnapshot | |
Fields
|
Instances
newtype PriceResponse #
contains pairs of prices: crypto symbol -> (regular currency symbol, price)
Constructors
PriceResponse (Map String Float) |
Instances