Skip to main content
You manage subscriptions with JSON commands. Your first command must carry credentials; see Authentication.

Command keys

Every command is a JSON object. The server rejects unknown keys and wrong JSON types with error code 8. See Errors.
Keys are required (Y), optional (N), or conditionally required (C). Conditional keys are required based on the presence or value of other keys.
Value types are strictly enforced. channels, tickers, and ids must be arrays of strings. sid must be an integer and sids an array of integers. Instrument IDs in params.id and params.ids must be strings.

Subscribe

Subscribes to one channel. A command with more than one channel is rejected. Example request:
The server responds with a subscribed frame: Example response:
subscribed means the request was accepted. For the orderbook channel, the snapshot for each instrument follows separately.
On one connection, an instrument can belong to only one subscription per channel. A subscribe that overlaps an existing subscription on the same channel is rejected with error code 6. This includes an all-instruments subscription and any explicit subscription on the same channel.

Instrument selectors

The ticker, trade, and orderbook channels accept exactly four selectors: ticker, tickers, id, and ids. There are no aliases.
  • You can combine selectors; the server takes their union and removes duplicates.
  • Omit all selectors on ticker or trade to subscribe to all instruments.
  • orderbook requires at least one selector.
  • instrument_lifecycle and event_lifecycle always cover all resources. A selector on these channels is rejected.
  • A malformed or non-canonical ID is rejected with error code 8. A valid selector that matches no instrument is rejected with error code 5.
The examples below use the ticker channel. One ticker:
Several tickers:
One instrument ID:
Several instrument IDs:
No selector, which subscribes to all instruments. Valid on ticker and trade only:

Unsubscribe

Removes one or more subscriptions. Example request:
The server sends one unsubscribed frame per removed subscription: Example response for subscription 1, whose last data frame had seq 57. A second frame follows for subscription 2:
If the request includes both valid and unknown subscription IDs, the server removes the valid subscriptions and returns error code 4 for the unknown IDs.

List subscriptions

Lists the active subscriptions on the connection. Example request:
The server responds with an ok frame: Example response:

Update subscription

Adds instruments to, or removes them from, an existing subscription without tearing it down. Example request:
The server responds with an ok frame: Example response. Subscription 1 is an orderbook subscription, so the snapshot for the added instrument was sent first:
Rules:
  • trade subscriptions accept only ticker and tickers on update.
  • Lifecycle subscriptions and all-instruments subscriptions cannot be updated. To change an all-instruments subscription, unsubscribe and subscribe again.
  • You cannot add an instrument that is already in this subscription or in another subscription on the same channel.
  • delete_instruments cannot remove every remaining instrument; that request is rejected. Use Unsubscribe instead.
  • When you add instruments to an orderbook subscription, the server sends a snapshot for each new instrument before its updates. The ok frame is sent after the snapshots.
  • An update sent while another update on the same subscription is still pending is rejected with error code 6.