coindock-node
A wrapper for the Coindock REST and WebSocket APIs.
Coindock
Coindock is a cryptocurrency candle-builder service which aims to support all major exchanges with all their currency-pairs and any desired candle interval. The service builds all it's candles directly from the underlying trades and can therefore provide historic and live open-candles for all exchanges and symbols.
Current supported exchanges: binance
, coinbase
, coinbasepro
, bitfinex,
, bitstamp
, kraken
.
Current supported currency-pairs: any currency which is provided by the specified exchange.
Current supported candle-intervals: Xsec
, Xmin
, Xhour
, Xday
, Xweek
X can be any positive integer value.
Features:
- support for all major cryptocurrency exchanges (coming soon)
- candles for any desired candle interval (live and historic)
- binance like open-candles (live and historic)
- cross exchange, cross symbol trading signals (coming soon)
Installation · Usage · CMD-Tool · Examples
Installation
npm install coindock-node --save
Usage
Getting started
const api = ; const coindockRest = endpoint: 'localhost:5555' // required, server address apiKey: '<YOUR-API-KEY>' // required, api key timeout: 15000 // optional, defaults to 15000, is the request time out in milliseconds; const coindockWs = endpoint: 'localhost:6666' // required, server address, apiKey: '<YOUR-API-KEY>' // required, api key debugStreams: false // optional, defaults to false, enables debug information for candles;
Load historic candles
with promise
coindockRest ;
with callback
coindockRest;
View example response
time: '2019-01-01T00:00:00.000Z' open: 370123 high: 3713 low: 368422 close: 368969 volume: 480576904920241 amount: 1299906535 nrtrades: '10090' firstid: '82541550' lastid: '82551639' openTime: 1546300800000 closeTime: 1546308000000 intervalMs: 7200000 isClosed: true time: '2019-01-01T02:00:00.000Z' open: 368967 high: 369977 low: 367504 close: 369313 volume: 624446601946716 amount: 1692016999 nrtrades: '11550' firstid: '82551640' lastid: '82563189' openTime: 1546308000000 closeTime: 1546315200000 intervalMs: 7200000 isClosed: true time: '2019-01-01T04:00:00.000Z' open: 369232 high: 39865 low: 369232 close: 369295 volume: 71044948553 amount: 019237 nrtrades: '3' firstid: '82563190' lastid: '82563192' openTime: 1546315200000 closeTime: 1546315202000 intervalMs: 7200000 isClosed: false time: '2019-01-01T04:00:00.000Z' open: 369232 high: 39865 low: 369232 close: 369343 volume: 144913548553 amount: 039237 nrtrades: '4' firstid: '82563190' lastid: '82563193' openTime: 1546315200000 closeTime: 1546315203000 intervalMs: 7200000 isClosed: false time: '2019-01-01T04:00:00.000Z' open: 369232 high: 39865 low: 369232 close: 369343 volume: 178754231585 amount: 0483994 nrtrades: '5' firstid: '82563190' lastid: '82563194' openTime: 1546315200000 closeTime: 1546315204000 intervalMs: 7200000 isClosed: false time: '2019-01-01T04:00:00.000Z' open: 369232 high: 39865 low: 369232 close: 369341 volume: 185945670196 amount: 05034649999999999 nrtrades: '6' firstid: '82563190' lastid: '82563195' openTime: 1546315200000 closeTime: 1546315206000 intervalMs: 7200000 isClosed: false
Live candles
Live candles are provided via a websocket api.
Each call to onXXXX initiates a new websocket for the specified route, and calls your callback with the payload of each message received. Each call to onXXXX returns the instance of the websocket client if you want direct access (https://www.npmjs.com/package/ws).
Single candle stream
coindockWs;
View example response
Combined candle stream
With combined streams it is possible to use a single websocket for multiple streams.
const streams = coindockWsstreams; const btcusdt15min = streams;const ethusdt3h = streams;const ethbtc1d = streams;const bnbbtc10sec = streams; coindockWs;
View example response
Command-Line-Tool
This node module also provides a simple command line tool.
Installation
npm install coindock-node --g
Usage
historic data
coindock-rest endpoint apiKey exchange symbol interval [--from=timestampMs] [--to=timestampMs] [--limit=number] [--openLimit=number]
live data
coindock-ws endpoint apiKey exchange symbol interval [--limit=number] [--open=boolean]
Examples for binance-btcusdt candles
- load the last 100 1-day candles
coindock-rest localhost:5555 <YOUR-API-KEY> binance btcusdt 1d --limit=100
- load the last 1000 4-hour candles
coindock-rest localhost:5555 <YOUR-API-KEY> binance btcusdt 4h
- load all 30-second candles between 1546300800000 (1/1/2019, 12:00:00 AM) and 1546322400000 (1/1/2019, 06:00:00 AM)
coindock-rest localhost:5555 <YOUR-API-KEY> binance btcusdt 30sec --from=1546300800000 --to=1546322400000
- load 300 10-minute candles starting at 1546300800000 (1/1/2019, 12:00:00 AM) and 200 open-candles after the last closed candle
coindock-rest localhost:5555 <YOUR-API-KEY> binance btcusdt 10min --from=1546300800000 --limit=300 --openLimit=200
- live-stream for 10-minute open and closed candles
coindock-ws localhost:6666 <YOUR-API-KEY> binance btcusdt 10min
- live-stream for 10-second closed candles starting with the next interval-tick
coindock-ws localhost:6666 <YOUR-API-KEY> binance btcusdt 10sec --open=false
- load 300 closed candles and start live-stream for 3-hour open and closed candles
coindock-ws localhost:6666 <YOUR-API-KEY> binance btcusdt 10sec --limit=300 --open=true
License
MIT
This wrapper is heavily inspired by the binance wrapper https://github.com/zoeyg/binance