bitx-bitcoin- A Haskell library for working with the BitX bitcoin exchange.

Copyright2015 Tebello Thejane
MaintainerTebello Thejane <>
Portabilitynon-portable (GHC Extensions)
Safe HaskellNone



Usage example

As a small example, to get the current selling price of bitcoin on the BitX exchange, do the following:

import Control.Lens ((^.))
import Network.Bitcoin.BitX (BitXAPIResponse(..), getTicker, CcyPair(..))
import qualified Network.Bitcoin.BitX as BitX
import Data.Text (unpack)
import Network.HTTP.Types.Status (Status(..))
import Network.HTTP.Conduit (responseStatus)

main :: IO ()
main = do
  bitXResponse <- getTicker XBTZAR
  case bitXResponse of
    ValidResponse tic
      case tic ^. BitX.ask of
        Nothing              ->  putStrLn "The BTC-ZAR exchange not currently have an ask price..."
        Just p               ->  putStrLn ("1 bitcoin will set you back ZAR" ++ show p ++ ".00.")
    ErrorResponse err        ->
        error $ "BitX error received: \"" ++ unpack (err ^. BitX.error) ++ "\""
    ExceptionResponse ex     ->
        error $ "Exception was thrown: \"" ++ show ex ++ "\""
    UnparseableResponse _ resp ->
        error $ "Bad HTTP response; HTTP status code was: \"" ++ (show . statusCode . responseStatus $ resp) ++ "\""



getTicker :: CcyPair -> IO (BitXAPIResponse Ticker) Source

Returns the latest ticker indicators.

getTickers :: IO (BitXAPIResponse [Ticker]) Source

Returns the latest ticker indicators from all active BitX exchanges.

getOrderBook :: CcyPair -> IO (BitXAPIResponse Orderbook) Source

Returns a list of bids and asks in the order book.

Ask orders are sorted by price ascending. Bid orders are sorted by price descending. Note that multiple orders at the same price are not necessarily conflated.

getTrades :: Maybe UTCTime -> CcyPair -> IO (BitXAPIResponse [Trade]) Source

Returns a list of the most recent trades