CoinJar Exchange offers a WebSocket-based API for streaming market data.
Introduction
CoinJar Exchange offers a WebSocket-based API for streaming market data.
Endpoint
The endpoint for CoinJar Exchange Data Feed in production is wss://feed.exchange.coinjar.com/socket/websocket
. If you are developing in the sandbox environment, please use wss://feed.exchange.coinjar-sandbox.com/socket/websocket
.
Phoenix JS
This API conforms to the Phoenix protocol and we recommend developers to use the official Phoenix JavaScript client, which abstracts away the complexity of handling duplicate subscriptions, reconnects and heartbeats.
Raw WebSocket
It is possible to use CoinJar Exchange Data Feed with raw WebSocket (or any WS library). However, you must send a heartbeat message every 45 seconds, otherwise the connection will be dropped by the server.
To send a heartbeat, push the following message to the socket:
{ "topic": "phoenix", "event": "heartbeat", "payload": {}, "ref": 0 }
To subscribe to a channel, push the following message to the socket:
{ "topic": "CHANNEL_NAME", "event": "phx_join", "payload": {}, "ref": 0 }
To subscribe to a authenticated private channel you will need your api token and push the following message to the socket:
{
"topic": "CHANNEL_NAME",
"event": "phx_join",
"payload": { "token": "MY_SECRET_API_TOKEN" },
"ref": 0
}