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-order
(cancel-order client order-id)
(cancel-order client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")
create-websocket-connection
(create-websocket-connection opts)
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 aThrowable
describing the error.:on-close
- optional - A binary function called when the connection is closed. Arguments are anint
status code and aString
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)
(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)
(deposit-from-payment-method client {:amount 10
:currency "USD"
:payment_method_id "7d0f7d8e-dd34-4d9c-a846-06f431c381ba"})
generate-report
(generate-report client opts)
(generate-report client {:type "fills"
:start_date "2018-6-1"
:end_date "2018-6-30"
:product_id "BTC-USD"})
get-account
(get-account client account-id)
(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)
(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)
(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-fills
(get-fills client opts)
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)
(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)
(get-order client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")
get-order-book
(get-order-book client product-id)
(get-order-book client product-id level)
(get-order-book client "BTC-USD")
(get-order-book client "BTC-USD" 2)
get-orders
(get-orders client)
(get-orders client opts)
(get-orders client {:status ["open" "pending"]})
get-report-status
(get-report-status client report-id)
(get-report-status client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")
get-ticker
(get-ticker client product-id)
(get-ticker client product-id opts)
(get-ticker client "BTC-USD")
(get-ticker client "BTC-USD" {:before 2 :limit 5})
get-trades
(get-trades client product-id)
(get-trades client product-id opts)
(get-trades client "BTC-USD")
(get-trades client "BTC-USD" {:before 2 :limit 5})
place-order
(place-order client opts)
(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)
connection
is created with create-websocket-connectionopts
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)
connection
is created with create-websocket-connection.opts
takes the equivalent shape as subscribe.
(unsubscribe connection {:product_ids ["BTC-USD"]})
websocket-url
The websocket URL for Coinbase Pro.
withdraw-to-coinbase
(withdraw-to-coinbase client opts)
(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)
(withdraw-to-crypto-address client {:amount 2
:currency "BTC"
:crypto_address "15USXR6S4DhSWVHUxXRCuTkD1SA6qAdy"})
withdraw-to-payment-method
(withdraw-to-payment-method client opts)
(withdraw-to-payment-method client {:amount 10
:currency "BTC-USD"
:payment_method_id "7d0f7d8e-dd34-4d9c-a846-06f431c381ba"})