coinbase-pro-clj.core

Public and private endpoint functions and websocket feed functionality. In all function signatures, client is a map with the following keys: - :url - rest URL - :key - optional - your Coinbase Pro API key - :secret - optional - your Coinbase Pro API key - :passphrase - optional - your Coinbase Pro API key

key, secret, and passphrase are only required if the request is authenticated. These values can be created in the API settings of your Coinbase Pro account. Remember not to store these values in an online repository as this will give others access to your account. You could use something like environ to store these values locally outside of your code.

cancel-all

(cancel-all client)(cancel-all client product-id)

API docs

(cancel-all client "BTC-USD")

cancel-order

(cancel-order client order-id)

API docs

(cancel-order client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")

close

(close connection)

connection is created with create-websocket-connection.

create-websocket-connection

(create-websocket-connection opts)

API docs

opts is a map that takes the following keys:

  • :url - the websocket URL
  • :product_ids - either this or :channels or both must be provided (see the Coinbase Pro API docs) - a vector of strings
  • :channels - either this or :product_ids or both must be provided (see the Coinbase Pro API docs) - a vector of strings or maps with :name (string) and :product_ids (vector of strings)
  • :key - optional - your Coinbase Pro API key
  • :secret - optional - your Coinbase Pro API secret
  • :passphrase - optional - your Coinbase Pro API passphrase
  • :on-receive - optional - A unary function called when a message is received. The argument is received as edn.
  • :on-connect - optional - A unary function called after the connection has been established. The argument is a WebSocketSession.
  • :on-error - optional - A unary function called in case of errors. The argument is a Throwable describing the error.
  • :on-close - optional - A binary function called when the connection is closed. Arguments are an int status code and a String description of reason.
(def conn (create-websocket-connection {:product_ids ["BTC-USD"]
                                        :url "wss://ws-feed.pro.coinbase.com"
                                        :on-receive (fn [x] (prn 'received x))}))

deposit-from-coinbase

(deposit-from-coinbase client opts)

API docs

(deposit-from-coinbase client {:amount 2
                               :currency "BTC"
                               :coinbase_account_id "7d0f7d8e-dd34-4d9c-a846-06f431c381ba"})

deposit-from-payment-method

(deposit-from-payment-method client opts)

API docs

(deposit-from-payment-method client {:amount 10
                                     :currency "USD"
                                     :payment_method_id "7d0f7d8e-dd34-4d9c-a846-06f431c381ba"})

generate-report

(generate-report client opts)

API docs

(generate-report client {:type "fills"
                         :start_date "2018-6-1"
                         :end_date "2018-6-30"
                         :product_id "BTC-USD"})

get-24hour-stats

(get-24hour-stats client product-id)

API docs

(get-24hour-stats client "BTC-USD")

get-account

(get-account client account-id)

API docs

(get-account client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")

get-account-history

(get-account-history client account-id)(get-account-history client account-id paging-opts)

API docs

(get-account-history client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")
(get-account-history client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba" {:before 2 :limit 5})

get-account-holds

(get-account-holds client account-id)(get-account-holds client account-id paging-opts)

API docs

(get-account-holds client "BTC-USD" "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")
(get-account-holds client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba" {:before 2 :limit 5})

get-accounts

(get-accounts client)

get-coinbase-accounts

(get-coinbase-accounts client)

get-currencies

(get-currencies client)

get-fills

(get-fills client opts)

API docs

Opts must contain either :order_id or :product_id.

(get-fills client {:product_id "BTC-USD" :before 2})

get-historic-rates

(get-historic-rates client product-id)(get-historic-rates client product-id opts)

API docs

(get-historic-rates client "BTC-USD")
(get-historic-rates client "BTC-USD" {:start "2018-06-01"
                                      :end "2018-06-30"
                                      :granularity 86400})

get-order

(get-order client order-id)

API docs

(get-order client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")

get-order-book

(get-order-book client product-id)(get-order-book client product-id level)

API docs

(get-order-book client "BTC-USD")
(get-order-book client "BTC-USD" 2)

get-orders

(get-orders client)(get-orders client opts)

API docs

(get-orders client {:status ["open" "pending"]})

get-payment-methods

(get-payment-methods client)

get-products

(get-products client)

get-report-status

(get-report-status client report-id)

API docs

(get-report-status client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")

get-ticker

(get-ticker client product-id)(get-ticker client product-id opts)

API docs

(get-ticker client "BTC-USD")
(get-ticker client "BTC-USD" {:before 2 :limit 5})

get-time

(get-time client)

get-trades

(get-trades client product-id)(get-trades client product-id opts)

API docs

(get-trades client "BTC-USD")
(get-trades client "BTC-USD" {:before 2 :limit 5})

get-trailing-volume

(get-trailing-volume client)

place-order

(place-order client opts)

API docs

(place-order client {:side "buy"
                     :product_id "BTC-USD"
                     :price 5000
                     :size 1})

rest-url

The rest URL for Coinbase Pro.

sandbox-rest-url

The sandbox rest URL for Coinbase Pro.

sandbox-websocket-url

The sandbox websocket URL for Coinbase Pro.

subscribe

(subscribe connection opts)

API docs

  • connection is created with create-websocket-connection
  • opts is a map with the following keys:
    • :product_ids - either this or :channels or both must be provided (see the Coinbase Pro API docs) - a vector of strings
    • :channels - either this or :product_ids or both must be provided (see the Coinbase Pro API docs) - a vector of strings or maps with :name (string) and :product_ids (vector of strings)
    • :key - optional - your Coinbase Pro API key
    • :secret - optional - your Coinbase Pro API key
    • :passphrase - optional - your Coinbase Pro API key
(subscribe connection {:product_ids ["BTC-USD"]})

unsubscribe

(unsubscribe connection opts)

API docs

(unsubscribe connection {:product_ids ["BTC-USD"]})

websocket-url

The websocket URL for Coinbase Pro.

withdraw-to-coinbase

(withdraw-to-coinbase client opts)

API docs

(withdraw-to-coinbase client {:amount 2
                              :currency "BTC"
                              :coinbase_account_id "7d0f7d8e-dd34-4d9c-a846-06f431c381ba"})

withdraw-to-crypto-address

(withdraw-to-crypto-address client opts)

API docs

(withdraw-to-crypto-address client {:amount 2
                                    :currency "BTC"
                                    :crypto_address "15USXR6S4DhSWVHUxXRCuTkD1SA6qAdy"})

withdraw-to-payment-method

(withdraw-to-payment-method client opts)

API docs

(withdraw-to-payment-method client {:amount 10
                                    :currency "BTC-USD"
                                    :payment_method_id "7d0f7d8e-dd34-4d9c-a846-06f431c381ba"})