Skip to content

Commit

Permalink
Merge pull request #14 from bpringe/update-docs
Browse files Browse the repository at this point in the history
Update docs
bpringe authored Sep 8, 2018
2 parents 1138b05 + 393aff8 commit 75871bf
Showing 4 changed files with 57 additions and 82 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -59,7 +59,12 @@ From here you can call any of the functions (provided your client has a valid ke

### Websocket Feed

Websocket messages are passed as edn to your `on-receive` function. When a new connection is created, the heartbeat channel is subscribed to if no `:channel` is specified.
When a new connection is created, the heartbeat channel is subscribed to if no `:channel` is specified. The following list describes the callback functions that can be passed to `create-websocket-connection`:

- `:on-receive` - A unary function called when a message is received. The argument is received as edn.
- `:on-connect` - A unary function called after the connection has been established. The argument is a [WebSocketSession](https://www.eclipse.org/jetty/javadoc/9.4.8.v20171121/org/eclipse/jetty/websocket/common/WebSocketSession.html).
- `:on-error` - A unary function called in case of errors. The argument is a `Throwable` describing the error.
- `:on-close` - A binary function called when the connection is closed. Arguments are an `int` status code and a `String` description of reason.

```clojure
;; Create a new connection and subscribe to the ticker channel for BTC-USD
59 changes: 23 additions & 36 deletions docs/coinbase-pro-clj.core.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>coinbase-pro-clj.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Coinbase-pro-clj</span> <span class="project-version">1.0.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1 current"><a href="coinbase-pro-clj.core.html"><div class="inner"><span>coinbase-pro-clj.core</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-cancel-all"><div class="inner"><span>cancel-all</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-cancel-order"><div class="inner"><span>cancel-order</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-close"><div class="inner"><span>close</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-create-websocket-connection"><div class="inner"><span>create-websocket-connection</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-deposit-from-coinbase"><div class="inner"><span>deposit-from-coinbase</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-deposit-from-payment-method"><div class="inner"><span>deposit-from-payment-method</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-generate-report"><div class="inner"><span>generate-report</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-24hour-stats"><div class="inner"><span>get-24hour-stats</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-account"><div class="inner"><span>get-account</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-account-history"><div class="inner"><span>get-account-history</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-account-holds"><div class="inner"><span>get-account-holds</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-accounts"><div class="inner"><span>get-accounts</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-coinbase-accounts"><div class="inner"><span>get-coinbase-accounts</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-currencies"><div class="inner"><span>get-currencies</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-fills"><div class="inner"><span>get-fills</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-historic-rates"><div class="inner"><span>get-historic-rates</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-order"><div class="inner"><span>get-order</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-order-book"><div class="inner"><span>get-order-book</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-orders"><div class="inner"><span>get-orders</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-payment-methods"><div class="inner"><span>get-payment-methods</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-products"><div class="inner"><span>get-products</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-report-status"><div class="inner"><span>get-report-status</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-ticker"><div class="inner"><span>get-ticker</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-time"><div class="inner"><span>get-time</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-trades"><div class="inner"><span>get-trades</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-trailing-volume"><div class="inner"><span>get-trailing-volume</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-place-order"><div class="inner"><span>place-order</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-rest-url"><div class="inner"><span>rest-url</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-sandbox-rest-url"><div class="inner"><span>sandbox-rest-url</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-sandbox-websocket-url"><div class="inner"><span>sandbox-websocket-url</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-subscribe"><div class="inner"><span>subscribe</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-unsubscribe"><div class="inner"><span>unsubscribe</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-websocket-url"><div class="inner"><span>websocket-url</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-withdraw-to-coinbase"><div class="inner"><span>withdraw-to-coinbase</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-withdraw-to-crypto-address"><div class="inner"><span>withdraw-to-crypto-address</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-withdraw-to-payment-method"><div class="inner"><span>withdraw-to-payment-method</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">coinbase-pro-clj.core</h1><div class="doc"><div class="markdown"><p>Public and private endpoint functions and websocket feed functionality. In all function signatures, <code>client</code> takes the following shape:</p>
<pre><code class="clojure">{:url
:key ; optional
:secret ; optional
:passphrase} ; optional
</code></pre>
<ul>
<li><code>key</code>, <code>secret</code>, and <code>passphrase</code> are only required if the request is authenticated. These values can be created in the <a href="https://pro.coinbase.com/profile/api">API settings</a> of your Coinbase Pro account. <strong>Remember not to store these values in an online repository as this will give others access to your account. You could use something like <a href="https://github.com/weavejester/environ">environ</a> to store these values locally outside of your code.</strong></li>
</ul></div></div><div class="public anchor" id="var-cancel-all"><h3>cancel-all</h3><div class="usage"><code>(cancel-all client)</code><code>(cancel-all client product-id)</code></div><div class="doc"><div class="markdown"><p><a href="https://docs.pro.coinbase.com/#cancel-all">API docs</a></p>
<html><head><meta charset="UTF-8" /><title>coinbase-pro-clj.core documentation</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Coinbase-pro-clj</span> <span class="project-version">1.0.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 "><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1 current"><a href="coinbase-pro-clj.core.html"><div class="inner"><span>coinbase-pro-clj.core</span></div></a></li></ul></div><div class="sidebar secondary"><h3><a href="#top"><span class="inner">Public Vars</span></a></h3><ul><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-cancel-all"><div class="inner"><span>cancel-all</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-cancel-order"><div class="inner"><span>cancel-order</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-close"><div class="inner"><span>close</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-create-websocket-connection"><div class="inner"><span>create-websocket-connection</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-deposit-from-coinbase"><div class="inner"><span>deposit-from-coinbase</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-deposit-from-payment-method"><div class="inner"><span>deposit-from-payment-method</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-generate-report"><div class="inner"><span>generate-report</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-24hour-stats"><div class="inner"><span>get-24hour-stats</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-account"><div class="inner"><span>get-account</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-account-history"><div class="inner"><span>get-account-history</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-account-holds"><div class="inner"><span>get-account-holds</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-accounts"><div class="inner"><span>get-accounts</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-coinbase-accounts"><div class="inner"><span>get-coinbase-accounts</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-currencies"><div class="inner"><span>get-currencies</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-fills"><div class="inner"><span>get-fills</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-historic-rates"><div class="inner"><span>get-historic-rates</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-order"><div class="inner"><span>get-order</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-order-book"><div class="inner"><span>get-order-book</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-orders"><div class="inner"><span>get-orders</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-payment-methods"><div class="inner"><span>get-payment-methods</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-products"><div class="inner"><span>get-products</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-report-status"><div class="inner"><span>get-report-status</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-ticker"><div class="inner"><span>get-ticker</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-time"><div class="inner"><span>get-time</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-trades"><div class="inner"><span>get-trades</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-get-trailing-volume"><div class="inner"><span>get-trailing-volume</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-place-order"><div class="inner"><span>place-order</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-rest-url"><div class="inner"><span>rest-url</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-sandbox-rest-url"><div class="inner"><span>sandbox-rest-url</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-sandbox-websocket-url"><div class="inner"><span>sandbox-websocket-url</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-subscribe"><div class="inner"><span>subscribe</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-unsubscribe"><div class="inner"><span>unsubscribe</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-websocket-url"><div class="inner"><span>websocket-url</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-withdraw-to-coinbase"><div class="inner"><span>withdraw-to-coinbase</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-withdraw-to-crypto-address"><div class="inner"><span>withdraw-to-crypto-address</span></div></a></li><li class="depth-1"><a href="coinbase-pro-clj.core.html#var-withdraw-to-payment-method"><div class="inner"><span>withdraw-to-payment-method</span></div></a></li></ul></div><div class="namespace-docs" id="content"><h1 class="anchor" id="top">coinbase-pro-clj.core</h1><div class="doc"><div class="markdown"><p>Public and private endpoint functions and websocket feed functionality. In all function signatures, <code>client</code> is a map with the following keys: - <code>:url</code> - rest URL - <code>:key</code> - optional - your Coinbase Pro API key - <code>:secret</code> - optional - your Coinbase Pro API key - <code>:passphrase</code> - optional - your Coinbase Pro API key</p>
<p><code>key</code>, <code>secret</code>, and <code>passphrase</code> are only required if the request is authenticated. These values can be created in the <a href="https://pro.coinbase.com/profile/api">API settings</a> of your Coinbase Pro account. <strong>Remember not to store these values in an online repository as this will give others access to your account. You could use something like <a href="https://github.com/weavejester/environ">environ</a> to store these values locally outside of your code.</strong></p></div></div><div class="public anchor" id="var-cancel-all"><h3>cancel-all</h3><div class="usage"><code>(cancel-all client)</code><code>(cancel-all client product-id)</code></div><div class="doc"><div class="markdown"><p><a href="https://docs.pro.coinbase.com/#cancel-all">API docs</a></p>
<pre><code class="clojure">(cancel-all client "BTC-USD")
</code></pre></div></div></div><div class="public anchor" id="var-cancel-order"><h3>cancel-order</h3><div class="usage"><code>(cancel-order client order-id)</code></div><div class="doc"><div class="markdown"><p><a href="https://docs.pro.coinbase.com/#cancel-an-order">API docs</a></p>
<pre><code class="clojure">(cancel-order client "7d0f7d8e-dd34-4d9c-a846-06f431c381ba")
</code></pre></div></div></div><div class="public anchor" id="var-close"><h3>close</h3><div class="usage"><code>(close connection)</code></div><div class="doc"><div class="markdown"><p><code>connection</code> is created with <a href="coinbase-pro-clj.core.html#var-create-websocket-connection">create-websocket-connection</a>.</p></div></div></div><div class="public anchor" id="var-create-websocket-connection"><h3>create-websocket-connection</h3><div class="usage"><code>(create-websocket-connection opts)</code></div><div class="doc"><div class="markdown"><p><a href="https://docs.pro.coinbase.com/#websocket-feed">API docs</a></p>
<p><code>opts</code> is a map that takes the following keys:</p>
<ul>
<li>
<p><code>opts</code> takes the following shape:</p>
<pre><code class="clojure">{:url
:product_ids
:channels ; optional
:key ; optional
:secret ; optional
:passphrase ; optional
:on-connect ; optional
:on-receive ; optional
:on-close ; optional
:on-error} ; optional
</code></pre></li>
<li><code>key</code>, <code>secret</code>, and <code>passphrase</code> are only required if you want an authenticated feed. See the Coinbase Pro API docs for details on authenticated feeds.</li>
<li><code>channels</code> is a vector of channel names (strings) . If no channels are passed, the “heartbeat” channel is subscribed to.</li>
<li><code>on-connect</code>, <code>on-receive</code>, <code>on-close</code>, and <code>on-error</code> are callback functions. Coinbase-pro-clj uses gniazdo for its websocket client. See the <a href="https://github.com/stalefruits/gniazdo#gniazdocoreconnect-uri--options">gniazdo readme</a> for details on the callback functions.</li>
<li><code>:url</code> - the websocket URL</li>
<li><code>:product_ids</code> - either this or <code>:channels</code> or both must be provided (see the Coinbase Pro API docs) - a vector of strings</li>
<li><code>:channels</code> - either this or <code>:product_ids</code> or both must be provided (see the Coinbase Pro API docs) - a vector of strings or maps with <code>:name</code> (string) and <code>:product_ids</code> (vector of strings)</li>
<li><code>:key</code> - optional - your Coinbase Pro API key</li>
<li><code>:secret</code> - optional - your Coinbase Pro API secret</li>
<li><code>:passphrase</code> - optional - your Coinbase Pro API passphrase</li>
<li><code>:on-receive</code> - optional - A unary function called when a message is received. The argument is received as edn.</li>
<li><code>:on-connect</code> - optional - A unary function called after the connection has been established. The argument is a <a href="https://www.eclipse.org/jetty/javadoc/9.4.8.v20171121/org/eclipse/jetty/websocket/common/WebSocketSession.html">WebSocketSession</a>.</li>
<li><code>:on-error</code> - optional - A unary function called in case of errors. The argument is a <code>Throwable</code> describing the error.</li>
<li><code>:on-close</code> - optional - A binary function called when the connection is closed. Arguments are an <code>int</code> status code and a <code>String</code> description of reason.</li>
</ul>
<pre><code class="clojure">(def conn (create-websocket-connection {:product_ids ["BTC-USD"]
:url "wss://ws-feed.pro.coinbase.com"
@@ -87,17 +75,16 @@
:size 1})
</code></pre></div></div></div><div class="public anchor" id="var-rest-url"><h3>rest-url</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The rest URL for Coinbase Pro.</p></div></div></div><div class="public anchor" id="var-sandbox-rest-url"><h3>sandbox-rest-url</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The sandbox rest URL for Coinbase Pro.</p></div></div></div><div class="public anchor" id="var-sandbox-websocket-url"><h3>sandbox-websocket-url</h3><div class="usage"></div><div class="doc"><div class="markdown"><p>The sandbox websocket URL for Coinbase Pro.</p></div></div></div><div class="public anchor" id="var-subscribe"><h3>subscribe</h3><div class="usage"><code>(subscribe connection opts)</code></div><div class="doc"><div class="markdown"><p><a href="https://docs.pro.coinbase.com/#subscribe">API docs</a></p>
<ul>
<li><code>connection</code> is created with <a href="coinbase-pro-clj.core.html#var-create-websocket-connection">create-websocket-connection</a>.</li>
<li>
<p><code>opts</code> takes the following shape:</p>
<pre><code class="clojure">{:product_ids
:channels ; optional
:key ; optional
:secret ; optional
:passphrase} ; optional
</code></pre></li>
<li><code>key</code>, <code>secret</code>, and <code>passphrase</code> are only required if you want an authenticated feed. See the Coinbase Pro API docs for details on authenticated feeds.</li>
<li><code>channels</code> is a vector of channel names (strings). If no channels are passed, the “heartbeat” channel is subscribed to.</li>
<li><code>connection</code> is created with <a href="coinbase-pro-clj.core.html#var-create-websocket-connection">create-websocket-connection</a></li>
<li><code>opts</code> is a map with the following keys:
<ul>
<li><code>:product_ids</code> - either this or <code>:channels</code> or both must be provided (see the Coinbase Pro API docs) - a vector of strings</li>
<li><code>:channels</code> - either this or <code>:product_ids</code> or both must be provided (see the Coinbase Pro API docs) - a vector of strings or maps with <code>:name</code> (string) and <code>:product_ids</code> (vector of strings)</li>
<li><code>:key</code> - optional - your Coinbase Pro API key</li>
<li><code>:secret</code> - optional - your Coinbase Pro API key</li>
<li><code>:passphrase</code> - optional - your Coinbase Pro API key</li>
</ul>
</li>
</ul>
<pre><code class="clojure">(subscribe connection {:product_ids ["BTC-USD"]})
</code></pre></div></div></div><div class="public anchor" id="var-unsubscribe"><h3>unsubscribe</h3><div class="usage"><code>(unsubscribe connection opts)</code></div><div class="doc"><div class="markdown"><p><a href="https://docs.pro.coinbase.com/#subscribe">API docs</a></p>
10 changes: 1 addition & 9 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<!DOCTYPE html PUBLIC ""
"">
<html><head><meta charset="UTF-8" /><title>Coinbase-pro-clj 1.0.0</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Coinbase-pro-clj</span> <span class="project-version">1.0.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 current"><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1 "><a href="coinbase-pro-clj.core.html"><div class="inner"><span>coinbase-pro-clj.core</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name">Coinbase-pro-clj</span> <span class="project-version">1.0.0</span></span></h1><h5 class="license">Released under the <a href="https://opensource.org/licenses/MIT">MIT</a></h5><div class="doc"><p>A Clojure wrapper for the Coinbase Pro API (formerly GDAX).</p></div><h2>Installation</h2><p>To install, add the following dependency to your project or build file:</p><pre class="deps">[coinbase-pro-clj "1.0.0"]</pre><h2>Namespaces</h2><div class="namespace"><h3><a href="coinbase-pro-clj.core.html">coinbase-pro-clj.core</a></h3><div class="doc"><div class="markdown"><p>Public and private endpoint functions and websocket feed functionality. In all function signatures, <code>client</code> takes the following shape:</p>
<pre><code class="clojure">{:url
:key ; optional
:secret ; optional
:passphrase} ; optional
</code></pre>
<ul>
<li><code>key</code>, <code>secret</code>, and <code>passphrase</code> are only required if the request is authenticated. These values can be created in the <a href="https://pro.coinbase.com/profile/api">API settings</a> of your Coinbase Pro account. <strong>Remember not to store these values in an online repository as this will give others access to your account. You could use something like <a href="https://github.com/weavejester/environ">environ</a> to store these values locally outside of your code.</strong></li>
</ul></div></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="coinbase-pro-clj.core.html#var-cancel-all">cancel-all</a> </li><li> <a href="coinbase-pro-clj.core.html#var-cancel-order">cancel-order</a> </li><li> <a href="coinbase-pro-clj.core.html#var-close">close</a> </li><li> <a href="coinbase-pro-clj.core.html#var-create-websocket-connection">create-websocket-connection</a> </li><li> <a href="coinbase-pro-clj.core.html#var-deposit-from-coinbase">deposit-from-coinbase</a> </li><li> <a href="coinbase-pro-clj.core.html#var-deposit-from-payment-method">deposit-from-payment-method</a> </li><li> <a href="coinbase-pro-clj.core.html#var-generate-report">generate-report</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-24hour-stats">get-24hour-stats</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-account">get-account</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-account-history">get-account-history</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-account-holds">get-account-holds</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-accounts">get-accounts</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-coinbase-accounts">get-coinbase-accounts</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-currencies">get-currencies</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-fills">get-fills</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-historic-rates">get-historic-rates</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-order">get-order</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-order-book">get-order-book</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-orders">get-orders</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-payment-methods">get-payment-methods</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-products">get-products</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-report-status">get-report-status</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-ticker">get-ticker</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-time">get-time</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-trades">get-trades</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-trailing-volume">get-trailing-volume</a> </li><li> <a href="coinbase-pro-clj.core.html#var-place-order">place-order</a> </li><li> <a href="coinbase-pro-clj.core.html#var-rest-url">rest-url</a> </li><li> <a href="coinbase-pro-clj.core.html#var-sandbox-rest-url">sandbox-rest-url</a> </li><li> <a href="coinbase-pro-clj.core.html#var-sandbox-websocket-url">sandbox-websocket-url</a> </li><li> <a href="coinbase-pro-clj.core.html#var-subscribe">subscribe</a> </li><li> <a href="coinbase-pro-clj.core.html#var-unsubscribe">unsubscribe</a> </li><li> <a href="coinbase-pro-clj.core.html#var-websocket-url">websocket-url</a> </li><li> <a href="coinbase-pro-clj.core.html#var-withdraw-to-coinbase">withdraw-to-coinbase</a> </li><li> <a href="coinbase-pro-clj.core.html#var-withdraw-to-crypto-address">withdraw-to-crypto-address</a> </li><li> <a href="coinbase-pro-clj.core.html#var-withdraw-to-payment-method">withdraw-to-payment-method</a> </li></ul></div></div></div></body></html>
<html><head><meta charset="UTF-8" /><title>Coinbase-pro-clj 1.0.0</title><link rel="stylesheet" type="text/css" href="css/default.css" /><link rel="stylesheet" type="text/css" href="css/highlight.css" /><script type="text/javascript" src="js/highlight.min.js"></script><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript" src="js/page_effects.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html"><span class="project-title"><span class="project-name">Coinbase-pro-clj</span> <span class="project-version">1.0.0</span></span></a></h1></div><div class="sidebar primary"><h3 class="no-link"><span class="inner">Project</span></h3><ul class="index-link"><li class="depth-1 current"><a href="index.html"><div class="inner">Index</div></a></li></ul><h3 class="no-link"><span class="inner">Namespaces</span></h3><ul><li class="depth-1 "><a href="coinbase-pro-clj.core.html"><div class="inner"><span>coinbase-pro-clj.core</span></div></a></li></ul></div><div class="namespace-index" id="content"><h1><span class="project-title"><span class="project-name">Coinbase-pro-clj</span> <span class="project-version">1.0.0</span></span></h1><h5 class="license">Released under the <a href="https://opensource.org/licenses/MIT">MIT</a></h5><div class="doc"><p>A Clojure wrapper for the Coinbase Pro API (formerly GDAX).</p></div><h2>Installation</h2><p>To install, add the following dependency to your project or build file:</p><pre class="deps">[coinbase-pro-clj "1.0.0"]</pre><h2>Namespaces</h2><div class="namespace"><h3><a href="coinbase-pro-clj.core.html">coinbase-pro-clj.core</a></h3><div class="doc"><div class="markdown"><p>Public and private endpoint functions and websocket feed functionality. In all function signatures, <code>client</code> is a map with the following keys: - <code>:url</code> - rest URL - <code>:key</code> - optional - your Coinbase Pro API key - <code>:secret</code> - optional - your Coinbase Pro API key - <code>:passphrase</code> - optional - your Coinbase Pro API key</p></div></div><div class="index"><p>Public variables and functions:</p><ul><li> <a href="coinbase-pro-clj.core.html#var-cancel-all">cancel-all</a> </li><li> <a href="coinbase-pro-clj.core.html#var-cancel-order">cancel-order</a> </li><li> <a href="coinbase-pro-clj.core.html#var-close">close</a> </li><li> <a href="coinbase-pro-clj.core.html#var-create-websocket-connection">create-websocket-connection</a> </li><li> <a href="coinbase-pro-clj.core.html#var-deposit-from-coinbase">deposit-from-coinbase</a> </li><li> <a href="coinbase-pro-clj.core.html#var-deposit-from-payment-method">deposit-from-payment-method</a> </li><li> <a href="coinbase-pro-clj.core.html#var-generate-report">generate-report</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-24hour-stats">get-24hour-stats</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-account">get-account</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-account-history">get-account-history</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-account-holds">get-account-holds</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-accounts">get-accounts</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-coinbase-accounts">get-coinbase-accounts</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-currencies">get-currencies</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-fills">get-fills</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-historic-rates">get-historic-rates</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-order">get-order</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-order-book">get-order-book</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-orders">get-orders</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-payment-methods">get-payment-methods</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-products">get-products</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-report-status">get-report-status</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-ticker">get-ticker</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-time">get-time</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-trades">get-trades</a> </li><li> <a href="coinbase-pro-clj.core.html#var-get-trailing-volume">get-trailing-volume</a> </li><li> <a href="coinbase-pro-clj.core.html#var-place-order">place-order</a> </li><li> <a href="coinbase-pro-clj.core.html#var-rest-url">rest-url</a> </li><li> <a href="coinbase-pro-clj.core.html#var-sandbox-rest-url">sandbox-rest-url</a> </li><li> <a href="coinbase-pro-clj.core.html#var-sandbox-websocket-url">sandbox-websocket-url</a> </li><li> <a href="coinbase-pro-clj.core.html#var-subscribe">subscribe</a> </li><li> <a href="coinbase-pro-clj.core.html#var-unsubscribe">unsubscribe</a> </li><li> <a href="coinbase-pro-clj.core.html#var-websocket-url">websocket-url</a> </li><li> <a href="coinbase-pro-clj.core.html#var-withdraw-to-coinbase">withdraw-to-coinbase</a> </li><li> <a href="coinbase-pro-clj.core.html#var-withdraw-to-crypto-address">withdraw-to-crypto-address</a> </li><li> <a href="coinbase-pro-clj.core.html#var-withdraw-to-payment-method">withdraw-to-payment-method</a> </li></ul></div></div></div></body></html>
63 changes: 27 additions & 36 deletions src/coinbase_pro_clj/core.clj
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
(ns coinbase-pro-clj.core
"Public and private endpoint functions and websocket feed functionality. In all function signatures, `client` takes the following shape:
```clojure
{:url
:key ; optional
:secret ; optional
:passphrase} ; optional
```
- `key`, `secret`, and `passphrase` are only required if the request is authenticated. These values can be created in the [API settings](https://pro.coinbase.com/profile/api) of your Coinbase Pro account.
"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](https://pro.coinbase.com/profile/api) 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](https://github.com/weavejester/environ)
to store these values locally outside of your code.**"
(:require
@@ -389,17 +388,13 @@ Opts must contain either `:order_id` or `:product_id`.
(defn subscribe
"[API docs](https://docs.pro.coinbase.com/#subscribe)
- `connection` is created with [[create-websocket-connection]].
- `opts` takes the following shape:
```clojure
{:product_ids
:channels ; optional
:key ; optional
:secret ; optional
:passphrase} ; optional
```
- `key`, `secret`, and `passphrase` are only required if you want an authenticated feed. See the Coinbase Pro API docs for details on authenticated feeds.
- `channels` is a vector of channel names (strings). If no channels are passed, the \"heartbeat\" channel is subscribed to.
- `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
```clojure
(subscribe connection {:product_ids [\"BTC-USD\"]})
@@ -456,23 +451,19 @@ Opts must contain either `:order_id` or `:product_id`.

(defn create-websocket-connection
"[API docs](https://docs.pro.coinbase.com/#websocket-feed)
- `opts` takes the following shape:
```clojure
{:url
:product_ids
:channels ; optional
:key ; optional
:secret ; optional
:passphrase ; optional
:on-connect ; optional
:on-receive ; optional
:on-close ; optional
:on-error} ; optional
```
- `key`, `secret`, and `passphrase` are only required if you want an authenticated feed. See the Coinbase Pro API docs for details on authenticated feeds.
- `channels` is a vector of channel names (strings) . If no channels are passed, the \"heartbeat\" channel is subscribed to.
- `on-connect`, `on-receive`, `on-close`, and `on-error` are callback functions. Coinbase-pro-clj uses gniazdo for its websocket client. See the [gniazdo readme](https://github.com/stalefruits/gniazdo#gniazdocoreconnect-uri--options) for details on the callback functions.
`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](https://www.eclipse.org/jetty/javadoc/9.4.8.v20171121/org/eclipse/jetty/websocket/common/WebSocketSession.html).
- `: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.
```clojure
(def conn (create-websocket-connection {:product_ids [\"BTC-USD\"]

0 comments on commit 75871bf

Please sign in to comment.