coinbase-pro: Client for Coinbase Pro

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Client for Coinbase Pro REST and Websocket APIs

[Skip to Readme]


Change log None available
Dependencies aeson (>=1.2 && <1.4), aeson-casing (==0.1.*), async (>=2.1 && <2.3), base (>=4.7 && <5), binary (==0.8.*), bytestring (==0.10.*), coinbase-pro, containers (==0.5.*), cryptonite (>=0.24 && <0.26), HsOpenSSL (==0.11.*), http-api-data (==0.3.*), http-client (==0.5.*), http-client-tls (==0.3.*), http-streams (==0.8.*), http-types (==0.12.*), io-streams (==1.5.*), memory (==0.14.*), network (==2.6.*), servant (==0.14.*), servant-client (==0.14.*), servant-client-core (==0.14.*), text (==1.2.*), time (==1.8.*), transformers (==0.5.*), unagi-streams (==0.2.*), unordered-containers (==0.2.*), vector (==0.12.*), websockets (==0.12.*), wuss (==1.1.*) [details]
License MIT
Copyright 2019 Michael Dunn <>
Author Michael Dunn <>
Maintainer Michael Dunn <>
Category Web, Finance
Home page
Bug tracker
Source repo head: git clone
Uploaded by mdunnio at 2019-09-22T16:56:43Z



Maintainer's Corner

For package maintainers and hackage trustees

Readme for coinbase-pro-

[back to package description]


Request API

{-# LANGUAGE OverloadedStrings #-}

module Main where

import           Control.Monad.IO.Class             (liftIO)

import           CoinbasePro.Authenticated
import           CoinbasePro.Authenticated.Accounts
import           CoinbasePro.Authenticated.Orders
import           CoinbasePro.Headers
import           CoinbasePro.MarketData.Types       hiding (time)
import           CoinbasePro.Request
import           CoinbasePro.Types                  hiding (time)
import           CoinbasePro.Unauthenticated

main :: IO ()
main = do
    stats btcusd >>= print
    candles btcusd Nothing Nothing Minute >>= print
    trades btcusd >>= print
    time >>= print
    products >>= print
    aggregateOrderBook btcusd (Just Best) >>= print
    aggregateOrderBook btcusd (Just TopFifty) >>= print
    fullOrderBook btcusd >>= print
    runCbAuthT cpc $ do
        accounts >>= liftIO . print
        account accountId >>= liftIO . print
        fills (Just btcusd) Nothing >>= liftIO . print
        listOrders (Just [All]) (Just btcusd) >>= liftIO . print
        placeOrder btcusd Sell (Size 0.001) (Price 99999.00) True Nothing Nothing Nothing >>= liftIO . print
        placeOrder btcusd Buy (Size 1.0) (Price 1.00) True Nothing Nothing Nothing >>= liftIO . print
        cancelOrder (OrderId "<cancel-order-id>")
        cancelAll (Just btcusd) >>= liftIO . print
    accessKey  = CBAccessKey "<access-key>"
    secretKey  = CBSecretKey "<secret-key>"
    passphrase = CBAccessPassphrase "<passphrase>"
    cpc        = CoinbaseProCredentials accessKey secretKey passphrase
    accountId  = AccountId "<account-id>"
    btcusd     = ProductId "BTC-USD"

Websocket API

To print out all of the full order book updates for BTC-USD:

{-# LANGUAGE OverloadedStrings #-}

module Main where

import           Control.Monad                     (forever)
import qualified System.IO.Streams                 as Streams

import           CoinbasePro.Types                 (ProductId (..))
import           CoinbasePro.WebSocketFeed         (subscribeToFeed)
import           CoinbasePro.WebSocketFeed.Request (ChannelName (..))

main :: IO ()
main = do
    msgs <- subscribeToFeed [ProductId "BTC-USD"] [Ticker]
    forever $ msgs >>= print


Example execs can be found in src/example/