Skip to content

Order Book

WebSocket Order Book

Subscribe

Request Format

{
  "op":"subscribe",
  "args":[
    "<topic 1>",
    "<topic 2>",
    "...",
    "<topic n>"
  ]
}

Topic Description

  • Topic format: "usdt/orderBook.{instrument_id}.[depth]"
Name Type Mandatory Description
instrument_id string YES contract abbreviation, such as BTC-SWAP.
depth integer NO order book depth. 5、10、50、100、200

Request Example

{
    "op": "subscribe",
    "args": [
        "usdt/orderBook.BTC-SWAP.5",
        "usdt/orderBook.ETH-SWAP"
    ]
}

Response Example

{
    "topic": "usdt/orderBook.BTC-SWAP",
    "action": "update", // At the first time , action = insert, then ,action = update, means appended data.
    "data": [
        {
            // Bid levels are sorted from highest to lowest price.
            "bids": [
                [
                    "29953.9", // Price
                    "18167"    // Quantity
                ],
                [
                    "29953.6",
                    "0"
                ],
                [
                    "29953.5",
                    "0"
                ],
                [
                    "29953.3",
                    "6419"
                ],
                [
                    "29953.0",
                    "3776"
                ],
                [
                    "29953.4",
                    "6795"
                ],
                [
                    "29952.9",
                    "35043"
                ]
            ],
            // Ask levels are sorted from lowest to highest price.
            "asks": [
                [
                    "29954.2", // Price
                    "18862"    // Quantity
                ],
                [
                    "29954.3",
                    "4168"
                ],
                [
                    "29954.4",
                    "3738"
                ],
                [
                    "29954.5",
                    "0"
                ],
                [
                    "29954.6",
                    "23650"
                ],
                [
                    "29954.7",
                    "3746"
                ]
            ],
            "version": 46165145,   // This field is strictly increasing value. It can be used to check the continuity of new data.
            "timestamp": 1681273582128
        }
    ]
}

Unsubscribe

Request Format

{
  "op":"unsubscribe",
  "args":[
    "<topic 1>",
    "<topic 2>",
    "...",
    "<topic n>"
  ]
}

Topic Description

  • Topic format: "usdt/orderBook.{instrument_id}.[depth]"
Name Type Mandatory Description
instrument_id string YES contract abbreviation, such as BTC-SWAP.
depth integer NO order book depth.

Request Example

{
    "op": "unsubscribe",
    "args": [
        "usdt/orderBook.BTC-SWAP.5",
        "usdt/orderBook.ETH-SWAP"
    ]
}