cryptocompare-0.1.2: Haskell wrapper for the cryptocompare API

Safe HaskellNone
LanguageHaskell2010

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
Synopsis

Documentation

fetchCoinList :: MonadIO m => m (Either String [CoinDetails]) Source #

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

fetchCurrentPrice Source #

Arguments

:: MonadIO m 
=> String

Coin symbol (BTC, ETH, etc)

-> [String]

Currency symbol(s) to display prices in. Eg [USD, EUR, ...]

-> 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

fetchDailyPriceHistory Source #

Arguments

:: MonadIO m 
=> String

Coin symbol (BTC, ETH, etc)

-> String

Currency symbol to display prices in (USD, EUR, etc)

-> 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

fetchCoinSnapshot Source #

Arguments

:: MonadIO m 
=> String

Coin symbol (BTC, ETH, etc)

-> String

Currency symbol(s) to display prices in (USD, EUR, etc)

-> 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 Source #

High level information about each coin.

Instances
Show CoinDetails Source # 
Instance details

Defined in CryptoCompare

Generic CoinDetails Source # 
Instance details

Defined in CryptoCompare

Associated Types

type Rep CoinDetails :: Type -> Type #

FromJSON [CoinDetails] Source # 
Instance details

Defined in CryptoCompare

type Rep CoinDetails Source # 
Instance details

Defined in CryptoCompare

data PriceHistoryResponse Source #

API response container for daily price history

Constructors

PriceHistoryResponse 

Fields

data PriceHistoryResponseData Source #

Data for a particular snapshot of a coin's daily price

Instances
Show PriceHistoryResponseData Source # 
Instance details

Defined in CryptoCompare

Generic PriceHistoryResponseData Source # 
Instance details

Defined in CryptoCompare

Associated Types

type Rep PriceHistoryResponseData :: Type -> Type #

FromJSON PriceHistoryResponseData Source # 
Instance details

Defined in CryptoCompare

type Rep PriceHistoryResponseData Source # 
Instance details

Defined in CryptoCompare

newtype PriceResponse Source #

contains pairs of prices: crypto symbol -> (regular currency symbol, price)

Constructors

PriceResponse (Map String Float) 
Instances
Show PriceResponse Source # 
Instance details

Defined in CryptoCompare

Generic PriceResponse Source # 
Instance details

Defined in CryptoCompare

Associated Types

type Rep PriceResponse :: Type -> Type #

FromJSON PriceResponse Source # 
Instance details

Defined in CryptoCompare

type Rep PriceResponse Source # 
Instance details

Defined in CryptoCompare

type Rep PriceResponse = D1 (MetaData "PriceResponse" "CryptoCompare" "cryptocompare-0.1.2-EtsoCtLtw8C1bgUGoJelT" True) (C1 (MetaCons "PriceResponse" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Map String Float))))