Subscribing
Market-data messages are delivered by subscription. Private account messages are not - they arrive automatically once the connection is authenticated.
Subscribe
Send message type 151 with join: true:
[151, { "type": 151, "channel": "orderbook", "event": "BTCUSDT", "join": true }]
| Field | Type | Description |
|---|---|---|
| channel | string | Channel name - see the table below. |
| event | string | Channel-specific key, usually the pair symbol (BTCUSDT). |
| join | boolean | true to subscribe, false to unsubscribe. |
Channels
| Channel | event | Pushes | Type |
|---|---|---|---|
ticker | all | All tickers | 401 |
ticker | pair symbol, BTCUSDT | Pair ticker | 402 |
trade | pair symbol, BTCUSDT | Trade | 422 |
orderbook | pair symbol, BTCUSDT | Full order book | 431 |
obdiff | pair symbol, BTCUSDT | Order book difference | 432 |
Subscription result
The server answers with a result message (type 100):
[100, { "type": 100, "ok": true, "message": "join|orderbook:BTCUSDT" }]
message is always "<join|leave>|<channel>:<event>".
Immediately after a successful join, if the server already holds a cached snapshot for that channel/event, it pushes that snapshot as a separate message - so you normally receive a full picture before the first incremental update.
Unsubscribe
Send the same message with join: false. Two behaviours to be aware of:
- Unsubscribe is answered only when it actually removed something. Leaving a channel you were
not subscribed to produces no reply at all - not an
ok: false. - Re-subscribing to a channel/event you are already on replies
ok: false. That is an "already subscribed" signal, not a failure to deliver data; your existing subscription is untouched.