@hackage bitx-bitcoin0.2.0.0

A Haskell library for working with the BitX bitcoin exchange.

Build Status Hackage

CC0 1.0 Universal (Public Domain)

(Hopefully useful) Haskell bindings to the BitX bitcoin exchange's API.

As a minimal example, to get the current selling price (in South African Rand) of bitcoin on the BitX exchange, do the following:

{-# LANGUAGE QuasiQuotes #-}

import Record.Lens (view)
import Record (lens)
import Network.Bitcoin.BitX (BitXAPIResponse(..), getTicker, CcyPair(..))
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        -> print (view [lens| ask |] tic)
    ErrorResponse err        ->
        error $ "BitX error received: \"" ++ (unpack (view [lens| error |] err)) ++ "\""
    ExceptionResponse ex     ->
        error $ "Exception was thrown: \"" ++ (unpack ex) ++ "\""
    UnparseableResponse resp ->
        error $ "Bad HTTP response; HTTP status code was: \"" ++ (show . statusCode . responseStatus $ resp) ++ "\""

Note that the code snippet above depends on http-types, http-conduit, record, and finally bitx-bitcoin.

Note that this library will not build on Windows currently, due to networking dependencies which have no Windows support.