Skip to content

mdunnio/coinbase-pro

Repository files navigation

coinbase-pro

Client for Coinbase Pro REST and Websocket APIs.

Here is a list of implemented/unimplemented features:

  • Market Data
    • Products
      • Get Products
      • Get Product Order Book
      • Get Product Ticker
      • Get Trades
      • Get Historic Rates
      • Get 24hr Stats
    • Currencies
      • Get Currencies
    • Time
  • Private
    • Accounts
      • List Accounts
      • Get An Account
      • Get Account History
      • Get Holds
    • Orders
      • Place a New Order
      • Cancel an Order
      • Cancel all
      • List Orders
      • Get an Order
    • Fills
      • List Fills
    • Limits
      • Get Current Exchange Limits
    • Deposits
      • List Deposits
      • Single Deposit
      • Payment Method
      • Coinbase
      • Generate a Crypto Deposit Address
    • Withdrawals
      • List Withdrawals
      • Single Withdrawal
      • Payment Method
      • Coinbase
      • Crypto
      • Fee Estimate
    • Stablecoin Conversions
      • Create Conversion
    • Payment Methods
      • List Payment Methods
    • Coinbase Accounts
      • List Accounts
    • Fees
      • Get Current Fees
    • Reports
      • Create a new report
      • Get report status
    • Profiles
      • List Profiles
      • Get a Profile
      • Create a Profile Transfer
    • User Account
      • Trailing Volume
    • [ ] Margin (Disabled)[https://blog.coinbase.com/coinbase-pro-disables-margin-trading-42f5862f8a66]
    • Oracle
      • Get Oracle
  • Websocket Feed
    • Channels
      • The heartbeat channel
      • The status channel
      • The ticker channel
      • The level2 channel
      • The user channel
      • The matches channel
      • The full channel
  • FIX API
    • Messages

Request API

Market Data Requests

run Sandbox (trades (ProductId "BTC-USD")) >>= print

Authenticated Private Requests

runDefCbAuthT Sandbox cpc $ do
    fills (Just btcusd) Nothing >>= liftIO . print
  where
    accessKey  = CBAccessKey "<access-key>"
    secretKey  = CBSecretKey "<secret-key>"
    passphrase = CBAccessPassphrase "<passphrase>"
    cpc        = CoinbaseProCredentials accessKey secretKey passphrase

Websocket API

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

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

Example

Example execs can be found in src/example/

Run Example

To run any of the authenticated endpoints in test-request, the access key, secret key, and passphrase must be provided. See Authenticated Private Requests above.