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

[ bitcoin, bsd3, finance, library, web ] [ Propose Tags ]

Haskell bindings to the Luno (formerly BitX) REST API, as described here:

Note that since this library interfaces directly with a financial API, great care must be taken in its use. In particular, the author cannot be held accountable for any financial losses as a result of programming error, whether that error is in your code, the code of the author of this library, or Luno's code. This is just common sense.

If you need to make sure that nothing funny happens in the code, apart from reading the source yourself, you should also perform a few test transactions with very small denominations, as I will strive to do every time before releasing a new version.

For a very small usage example, see Network.Bitcoin.BitX.Public.

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS],,,,,,,,,,,,,,,,,,, (info)
Change log CHANGES
Dependencies aeson (>=0.8), base (>=4.5 && <5), bytestring, deepseq, exceptions, http-client (>=, http-client-tls, http-types, microlens, microlens-th, network, QuickCheck (>=2.8), scientific, split (>=, text, time [details]
License BSD-3-Clause
Author Tebello Thejane, Tristan Seligmann
Maintainer Tebello Thejane <>
Category Web, Bitcoin, Finance
Home page
Source repo head: git clone git://
Uploaded by tebello_thejane at 2017-12-24T08:34:55Z
Distributions NixOS:
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 12587 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-12-24 [all 1 reports]

Readme for bitx-bitcoin-

[back to package description]

Build Status Hackage BSD3

(Hopefully useful) Haskell bindings to the Luno (formerly BitX) cryptocurrency exchange's API.

As a minimal example, to get the current selling price (in South African Rand) of Bitcoin on the Luno 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.Client (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 ++ ".")
    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) ++ "\""

Note that the code snippet above depends on http-types, text, http-client, lens (or any lens-compatible package, such as microlens), and finally bitx-bitcoin.

This library is known to work on Windows, but if you wish to use it then you will have to do a bit more work due to the Network library not building on Windows out of the box. Your best bet might be to just use Stack.