OrderBook

Description

Rate Limit: 10 requests per second per IP for Subscribe and Unsubscribe.

A message with type="all" indicates a full snapshot, while type="update" indicates an incremental update. Upon initial subscription, a full snapshot is sent, followed by incremental updates. The order book should be maintained using seqNum (current sequence number) and preSeqNum (previous sequence number).

Response Packet Protocol: binary

Request

{
    "event": "SUBSCRIBE",
    "arg": [
        {
            "channel": "orderbook",
            "sym": "OKX_PERP_BTC_USDT"
        },
        {  
            "channel":"orderbook",  
            "sym":"BINANCE_SPOT_BTC_USDT"  
        },  
        {  
            "channel":"orderbook",  
            "sym":"OKX_SPOT_BTC_USDT"  
        },{  
            "channel":"orderbook",  
            "sym":"BINANCE_PERP_BTC_USDT"  
        }
    ]  
}
 
Field nameTypeNecessaryRemarks
eventStringYsubscribe / unsubscribe
argArrayYSubscribe param. There can be no more than 50 instId parameters per subscribe.
> channelStringYChannel name: orderbook
> symStringYUnique identifier

Response

{
    "event": "SUBSCRIBE",
    "arg": [
        {
            "channel": "orderbook",
            "sym": "OKX_PERP_BTC_USDT"
        },
        {
            "channel": "orderbook",
            "sym": "BINANCE_SPOT_BTC_USDT"
        },
        {
            "channel": "orderbook",
            "sym": "OKX_SPOT_BTC_USDT"
        },
        {
            "channel": "orderbook",
            "sym": "BINANCE_PERP_BTC_USDT"
        }
    ],
    "code": 0,
    "message": "Success"
}
FieldTypeRemarks
eventStringsubscribe / unsubscribe
codeStringError Code
msgStringError Message
argArraySubscribe param
> channelStringChannel name: orderbook
> symStringUnique identifier

Order book example:

{
    "arg": {
        "channel": "orderbook",
        "sym": "BINANCE_PERP_BTC_USDT"
    },
    "data": {
        "localTs": 1736426510957751300,
        "exchangeTs": 1736426510956000000,
        "seqNum": 5818843132,
        "type": "update",
        "preseqNum": 5818843129,
        "ltp": "93261.400000",
        "ttv": "167880070889.075409",
        "ttq": "1742014.077255",
        "state": "0",
        "bids": [
            [
                "93252.900000",
                "0.000000"
            ],
            [
                "93253.000000",
                "4.086000"
            ],
            [
                "93254.200000",
                "0.003000"
            ],
            [
                "93256.300000",
                "0.055000"
            ],
            [
                "93261.300000",
                "7.568000"
            ]
        ],
        "asks": [
            [
                "93261.400000",
                "1.434000"
            ],
            [
                "93271.700000",
                "0.008000"
            ]
        ]
    }
}
FieldTypeRemarks
channelStringexample: orderbook
symStringUnique identifier
updatetypeStringall/update. Default is all. all : Full snapshot
update : Incremental update
tsStringMarket data generation timestamp (milliseconds)
seqStringSequence number of the current message (used for ordered processing)
seqNumStringSequence number of the previous message (string; appears in incremental updates for continuity validation)
numStringcumulative incremental sequence number for push messages.
BidsStringBid depth data list, with each element being [price, size].
> priceStringPrice
> qtyStringQuantity
AsksStringAsk depth data list, with each element being [price, size].
> priceStringPrice
> qtyStringQuantity