WebSocket
Message Format
Our WebSocket API uses JSON-formatted messages for all communication.
Request Format
All requests follow a consistent structure:
Code
| Field | Type | Required | Description |
|---|---|---|---|
id | string | number | Yes | Unique identifier for matching request/response |
method | string | Yes | The method to invoke |
params | object | array | No | Method parameters (varies by method) |
Response Format
Successful responses include the request ID and result:
Code
| Field | Type | Description |
|---|---|---|
id | string | number | Matches the request ID |
status | number | HTTP status code |
result | any | Method-specific response data |
Error Response
Error responses include error details:
Code
| Field | Type | Description |
|---|---|---|
id | string | number | Matches the request ID |
status | number | HTTP status code |
error.code | number | Internal error code |
error.msg | string | Human-readable error message |
Error Codes
| Code | HTTP Status | Description |
|---|---|---|
| -1000 | 500 | Internal server error |
| -1002 | 401 | Authentication required |
| -1003 | 429 | Rate limit exceeded |
| -1013 | 400 | Invalid parameters |
| -1020 | 400 | Unsupported operation |
| -2010 | 400 | Order rejected |
Event Types
Streaming events carry an e field that identifies the event type, so a single connection can demultiplex every subscription:
e value | Stream |
|---|---|
depthUpdate | L2 differential depth ({symbol}@depth, {symbol}@depth@100ms) |
orderUpdate | Order events (orders@account, orders@session) |
balanceUpdate | Balance updates (balances@account, balances@account@1s) |
positionReport | Position updates (positions@account, positions@account@1s) |
contractStatus | Contract status (contractStatus) |
The Book Ticker ({symbol}@bookTicker), L2 Partial Depth ({symbol}@depth5 / @depth10 / @depth20), and Trade ({symbol}@trade) payloads do not carry an e field — identify those by the stream you subscribed to.
New event types may be added over time. Treat any e value you do not recognize as a forward-compatible addition and ignore it.
Last modified on