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

Push Data

Full snapshot (updatetype: "all") — sent once on subscribe:

{
    "arg": { "channel": "orderbook", "sym": "BINANCE_PERP_BTC_USDT", "updatetype": "all" },
    "data": {
        "ts": "1597026383085",
        "seq": "1000",
        "pre_seq": "0",
        "num": 1,
        "Bids": [["70283.2", "0.004"], ["70282.8", "0.005"]],
        "Asks": [["70296.1", "0.095"], ["70296.2", "0.126"]]
    }

Incremental update (updatetype: "update") — all subsequent pushes:


{
    "arg": { "channel": "orderbook", "sym": "BINANCE_PERP_BTC_USDT", "updatetype": "update" },
    "data": {
        "ts": "1597026383085",
        "seq": "1000",
        "pre_seq": "0",
        "num": 1,
        "Bids": [["70283.2", "0.004"], ["70282.8", "0.005"]],
        "Asks": [["70296.1", "0.095"], ["70296.2", "0.126"]]
    }

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)
pre_seqStringPrevious sequence number
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