Websocket Streaming API

Cryptowatch offers a real-time Websocket Streaming API. It streams data for all of the markets supported on Cryptowatch.

The API is hosted at wss://stream.cryptowat.ch.

Alpha Testing Invitation

This API is currently in an invite-only alpha testing phase. Please [inquire here](https://docs.google.com/forms/d/e/1FAIpQLSdhv_ceVtKA0qQcW6zQzBniRBaZ_cC4al31lDCeZirntkmWQw/viewform?c=0&w=1) if you are interested in getting access to it.

Message Format

All messages sent over the Streaming API are encoded using Protocol Buffers. Protocol Buffers were chosen over JSON for their high efficiency, among other benefits.

Our protobuf definitions are available at github.com/cryptowatch/proto.

Client Libraries

You will want to use a client libeary to handle authenticating and connecting to the api. So far we have libraries written for `Golang` and `NodeJS`.

However, one could write a client in any language using our protobuf definitions and one of our libraries as a reference implementation. If you write a client, send us a link and we'll post it here!

Authentication

Since this API is not freely available to the public like our REST API, each client must authenticate their connection. Our authentication scheme relies on an API key and a secret key; when establishing a connection the client must send an APIAuthenticationMessage containing their public key, a nonce, and a token which is an HMAC-SHA-512 created with the corresponding secret key.

An example implementation of this HMAC can be found at stream-client-go.

Subscriptions

A client subscribes to a feed using the ClientSubscribeMessage. One can subscribe to market data using various scopes:

  • a single market (kraken:btceur)
  • all markets on an exchange (kraken)
  • all markets for a given pair (btceur)
  • all markets for a given asset (btc)
  • all markets in the system

Subscriptions are represented as colon-delimited strings. For example, exchanges:4:trades is a feed of all trades on the id=4 exchange (Kraken). A client need only subscribe to this single feed to receive all trade updates for the Kraken exchange.

One must know the entity ID associated with the scope they want to subscribe to. These IDs can be looked up in our REST API:

For example,

In some cases, one can also use a wildcard ID to scope their subscription to all markets.

Below we enumerate all possible subscription types, and the scopes they support.

Trade Feed

Proto message type: TradesUpdate

SyntaxDescription
markets:68:tradesA feed of trades for a single market
markets:*:tradesA feed of trades for all markets; this is the firehose
exchanges:4:tradesA feed of all trades on a given exchange
pairs:232:tradesA feed of all trades for a given pair
assets:60:tradesA feed of all trades for a given asset

See our example code for consuming a trade feed.

24 Hour Market Summary

Periodic messages summarizing a given market over the last 24 hours, including last price, total volume, total quote volume, and price change.

Proto message type: SummaryUpdate

SyntaxDescription
markets:68:summaryMarket summary updates for a single market
markets:*:summaryMarket summary updates for all markets
markets:*:summary-low-volumeMarket summary updates for all markets.
Throttled to one update per market per 2 minutes.
exchanges:4:summaryMarket summary updates for a given exchange
pairs:232:summaryMarket summary updates for a given pair
assets:60:summaryMarket summary updates for a given asset

OHLC Data

Otherwise known as "candlestick" data, an OHLC subscription publishes updates to the latest candlestick for each time period. See also REST API OHLC data for reference.

Proto message type: IntervalsUpdate

SyntaxDescription
markets:68:ohlcOHLC (candlestick) updates for a single market

Orderbook

We publish real-time updates to the spread (best bid & ask) for the order book.

Proto message type: OrderBookSpreadUpdate

SyntaxDescription
markets:68:book:spreadOrder book spread updates for a given market
markets:*:book:spreadOrder book spread updates for all markets
exchanges:4:book:spreadOrder book spread updates for a given exchange
pairs:232:book:spreadOrder book spread updates for a given pair
assets:60:book:spreadOrder book spread updates for a given asset

The structure of our orderbook data is going through some changes. We will document full order book feeds soon! Let us know if you are interested in this data.

Example Code

Here's some example code showing how to connect, authenticate, subscribe to feeds, and consume the messages received:

  • kraken-trades - printing a real-time feed of all trades on a single exchange
  • print-quotes - printing real-time quotes for a given pair across all supported exchanges