Pushing Rules
- No user login required
- After subscribing, then the changes will be pushed
Request
Request
{"action":"subscribe","args":["<channel:symbol><@speed>"]}
- actions:
subscribe - channel: Channel name, such as
futures/depth20 - symbol: Trading pair, such as
BTCUSDT - speed: Update speed, support
200msor100ms
Parameters Channel Name List
| Channel Name | Description |
|---|---|
| futures/depth5 | 5 Level Depth Channel |
| futures/depth20 | 20 Level Depth Channel |
| futures/depth50 | 50 Level Depth Channel |
Response
Response
| Field | Type | Description |
|---|---|---|
| symbol | String | Symbol of the contract(like BTCUSDT) |
| way | Long | Trading side - 1=bid- 2=ask |
| depths | List | Array of depth details |
| ms_t | Long | Data push timestamp (in millisecond) |
depths details field:
| Field | Type | Description |
|---|---|---|
| price | String | price |
| vol | String | volume |
【Public】Depth-All Channel
Return depth data, each push is the full dataPushing Rules
- No user login required
- After subscribing, then the changes will be pushed
Request
Request
{"action":"subscribe","args":["<channel:symbol><@speed>"]}
- channel: Channel name, such as
futures/depthAll20 - symbol: Trading pair, such as
BTCUSDT - speed: Update speed, support
200msor100ms
| Channel Name | Description |
|---|---|
| futures/depthAll5 | 5 Level Depth Channel |
| futures/depthAll20 | 20 Level Depth Channel |
| futures/depthAll50 | 50 Level Depth Channel |
Response
Response
| Field | Type | Description |
|---|---|---|
| symbol | String | Symbol of the contract(like BTCUSDT) |
| asks | List | Asks Depth Array |
| bids | List | Bids Depth Array |
| ms_t | Long | Data push timestamp (in millisecond) |
asks bids details field:
| Field | Type | Description |
|---|---|---|
| price | String | price |
| vol | String | volume |
【Public】Depth-Increase Channel
Return depth data, support the creation of a local full depth cache dataPushing Rules
- No user login required
- After subscribing, the current data will be returned directly, and then the changes will be pushed
Request
Subscribe Request
Full depth snapshot data Request
{"action":"<op>","args":["<channel:symbol><@speed>"]}
- op:
subscribe=Subscribe, You will receive a message that the subscription is successful, and then you will receive incremental depth data pushed in real time.request=Single request for the latest depth snapshot, You will receive a full depth of data immediately. - channel:Channel name, such as
futures/depthIncrease20 - symbol: Trading pair, such as
BTCUSDT - speed: Update speed, support
200msor100ms
| Channel Name | Description |
|---|---|
| futures/depthIncrease5 | 5 Level Depth Channel |
| futures/depthIncrease20 | 20 Level Depth Channel |
| futures/depthIncrease50 | 50 Level Depth Channel |
Response
Full depth snapshot data
Incremental depth data
| Field | Type | Description |
|---|---|---|
| symbol | String | Symbol of the contract (like BTCUSDT) |
| asks | List | Asks Depth Array |
| bids | List | Bids Depth Array |
| ms_t | Long | Data push timestamp (in millisecond) |
| version | Long | data version |
| type | String | data type - snapshot=Full depth snapshot data - update=Incremental depth data |
asks bids details field:
| Field | Type | Description |
|---|---|---|
| price | String | price |
| vol | String | volume |
How to correctly maintain a copy of OrderBook locally:
- First, the client send a subscription request
{"action": "subscribe", "args": ["futures/depthIncrease20:<symbol>"] } - After successful subscription, you will receive two types of messages, type=
snapshot(full data)和type=update(update) - If a type=snapshot type message is received, update the deep snapshot content to the
local cache. If there is nolocal cache, create one. - If a type=update message is received, update the data in the deep snapshot to
local cache. The update rules are as follows:- 4.1 If the field version number in the received new message is less than or equal to the version in the local cache(new version<=local version), this data can be discarded.
- 4.2 If the field version number in the new message received is equal to the version in the local cache plus 1(new version==local version+1), the quantity of the corresponding price will be
updated to the local cache. - 4.3 If the field version number in the new message received is greater than the version in the local cache plus 1(new version>local version+1), please obtain the latest depth snapshot from step 7 and overwrite the
local cache.
- The pending order volume in each returned message represents the
absolute valueof the current pending order volume at this price, rather than the relative change. - How to update local cache? Under the premise of 4.2:
- 6.1 New: If the same price is not already in the local cache, it means that it is a new pending order and needs to be added to the cache.
- 6.2 Modify or Remove: If the same price is already in the local cache, it means that the quantity has changed. If the quantity is 0, it will be directly removed from the cache. Otherwise, just change the quantity.
- Request through request
{"action": "request", "args": ["futures/depthIncrease20:<symbol>"] }to obtain the latest depth snapshot (type=snapshot in the message), and add the depth The content in the snapshot is overwritten to thelocal cache, and then the logic continues from step 2.
- Abnormal Situation:
- Because the depth snapshot has a limit on the number of price tiers, price tiers outside the initial snapshot and without quantity changes will not appear in the incremental depth update information. Therefore, even if all updates from the incremental depth are applied, these price brackets will not be visible in the local order book, so there may be some differences between the local order book and the real order book.
【Public】Individual Symbol Book Ticker Channel
Pushes any update to the best bid or ask’s price or quantity in real-time for a specified symbolPushing Rules
- No user login required
- After subscribing, then the changes will be pushed
- Real-time push
Request
Request
{"action":"subscribe","args":["<channel:symbol>"]}
- actions:
subscribe - channel: Channel name, such as
futures/bookticker - symbol: Trading pair, such as
BTCUSDT
Response
Response
| Field | Type | Description |
|---|---|---|
| symbol | String | Symbol of the contract(like BTCUSDT) |
| best_bid_price | String | Best bid price |
| best_bid_vol | String | Best bid volume |
| best_ask_price | String | Best ask price |
| best_ask_vol | String | Best ask volume |
| ms_t | Long | Data push timestamp (in millisecond) |