Commands
Commands
- Subscribe: Subscribes to one channel.
- Unsubscribe: Removes one or more subscriptions.
- List subscriptions: Lists the subscriptions on the connection.
- Update subscription: Adds instruments to, or removes them from, a subscription.
Command keys
Every command is a JSON object. The server rejects unknown keys and wrong JSON types with error code8. See Errors.
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:
subscribed frame:
Example response:
subscribed means the request was accepted. For the orderbook channel, the snapshot for each instrument follows separately.6. This includes an all-instruments subscription and any explicit subscription on the same channel.
Instrument selectors
Theticker, 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
tickerortradeto subscribe to all instruments. orderbookrequires at least one selector.instrument_lifecycleandevent_lifecyclealways 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 code5.
ticker channel. One ticker:
ticker and trade only:
Unsubscribe
Removes one or more subscriptions.
Example request:
unsubscribed frame per removed subscription:
Example response for subscription
1, whose last data frame had seq 57. A second frame follows for subscription 2:
4 for the unknown IDs.
List subscriptions
Lists the active subscriptions on the connection.
Example request:
ok frame:
Example response:
Update subscription
Adds instruments to, or removes them from, an existing subscription without tearing it down.
Example request:
ok frame:
Example response. Subscription
1 is an orderbook subscription, so the snapshot for the added instrument was sent first:
tradesubscriptions accept onlytickerandtickerson 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_instrumentscannot remove every remaining instrument; that request is rejected. Use Unsubscribe instead.- When you add instruments to an
orderbooksubscription, the server sends a snapshot for each new instrument before its updates. Theokframe is sent after the snapshots. - An update sent while another update on the same subscription is still pending is rejected with error code
6.