Multi-Order Book
This allows simultaneous subscriptions to multiple L1 and L2 order books of different markets.
The order books of different markets to be subscribed are controlled by the parameters in the subscription message listed below.
/trading-api/v1/market-data/orderbook
Operations
SEND/trading-api/v1/market-data/orderbook
Subscribe
Multiple subscriptions could be opened within the same websocket.
The order book of different markets to be subscribed are controlled by the parameters in the subscription message listed below.
See connect to multi-order book WebSocket for a sample Python script.
Accepts the following message:
Let you subscribe to a given topic
Examples
{
"method": "subscribe",
"id": "1611082473000",
"jsonrpc": "2.0",
"type": "command",
"params": {
"topic": "l1Orderbook",
"symbol": "BTCUSD"
}
}
This example has been generated automatically.
RECEIVE/trading-api/v1/market-data/orderbook
After subscribing, the server sends :
- an acknowledgement
Then (L1 / L2 depending on your topic):
- an initial snapshot
- followed by incremental updates
Sends one of the following messages:
- #1Acknowledgment
Confirm the topic being subscribed
objectExamples
{"id": "1611082473000","jsonrpc": "2.0","result": {"responseCodeName": "OK","responseCode": "200","message": "Successfully subscribed ( BTCUSD 1)"}}This example has been generated automatically.
- #2Snapshot/Update for L1
Latest update for L1
objectExamples
{"type": "update","dataType": "V1TALevel1","data": {"sequenceNumber": "8","symbol": "BTCUSD","timestamp": "1719642590000","bid": ["5199.5000","61.95995262"],"ask": ["5199.6000","96.59626782"]}}This example has been generated automatically.
- #3Snapshot/Update for L2
Latest update for L2
objectExamples
{"type": "snapshot","dataType": "V1TALevel2","data": {"symbol": "BTCUSD","bids": ["5199.5000","61.95995262","5199.4000","20.92470365"],"asks": ["5199.6000","96.59626782","5199.7000","0.92465082"],"sequenceNumberRange": [1370055970,1370055970],"datetime": "2024-06-29T06:29:50.500Z","timestamp": "1719642590000","publishedAtTimestamp": "1719642590000"}}This example has been generated automatically.
RECEIVE/trading-api/v1/market-data/orderbook
In case of invalid subscription message, an error rejection would be sent.
Sends the following message:
Explain why the topic could not be subscribed
Examples
{
"id": "1611082473000",
"jsonrpc": "2.0",
"error": {
"code": "-32602",
"errorCode": "29013",
"errorCodeName": "'abcde' is not a valid topic"
}
}
This example has been generated automatically.
SEND/trading-api/v1/market-data/orderbook
Keepalive
In case nothing is subscribed to, keep the websocket connection alive.
Accepts the following message:
Examples
{
"method": "keepalivePing",
"params": {},
"id": "1611082473000",
"jsonrpc": "2.0",
"type": "command"
}
This example has been generated automatically.
RECEIVE/trading-api/v1/market-data/orderbook
Acknowledgement returned by the server in response to a keepalive-ping.
Sends the following message:
Examples
{
"id": "1611082473000",
"jsonrpc": "2.0",
"result": {
"responseCodeName": "OK",
"responseCode": 200,
"message": "Keep alive pong"
}
}
This example has been generated automatically.
SEND/trading-api/v1/market-data/orderbook
Unsubscribe
Let you unsubscribe a specific topic while keeping your websocket opened.
Accepts the following message:
Let you unsubscribe to a given index
Examples
{
"method": "unsubscribe",
"id": "1611082473000",
"jsonrpc": "2.0",
"type": "command",
"params": {
"topic": "l1Orderbook",
"symbol": "BTCUSD"
}
}
This example has been generated automatically.
RECEIVE/trading-api/v1/market-data/orderbook
After unsubscribing, the server sends an acknowledgement.
Sends the following message:
Confirm the topic being unsubscribed
Examples
{
"id": "1611082473000",
"jsonrpc": "2.0",
"result": {
"responseCodeName": "OK",
"responseCode": "200",
"message": "Successfully unsubscribed ( BTCUSD 1)"
}
}
This example has been generated automatically.
RECEIVE/trading-api/v1/market-data/orderbook
In case of invalid unsubscription message, an error rejection would be sent.
Sends the following message:
Explain why the topic could not be unsubscribed
Examples
{
"id": "1611082473000",
"jsonrpc": "2.0",
"error": {
"code": "-32602",
"errorCode": "29013",
"errorCodeName": "'abcde' is not a valid topic"
}
}