Skip to main content

Orderbook Incremental Updates

WSProductionwss://ws.btse.com/ws/oss/futuresTestnetwss://testws.btse.io/ws/oss/futures

Subscribe to orderbook incremental updates through the update topic. Topic format: update:<symbol>_<grouping> (e.g. update:BTC-PERP_0)

The _grouping suffix represents the granularity of price-level aggregation. Valid values are 0 to 8. If the suffix is omitted (e.g. update:BTC-PERP), _0 is used by default. Different grouping values produce independent topic subscriptions and caches.

The first response received will be a snapshot of the current orderbook (indicated by the type field) with up to 50 levels. Incremental updates will be sent in subsequent packets with type delta.

Bids and asks will be sent in price and size tuples. The size sent will be the new updated size for the price. If a value of "0" is sent, the price should be removed from the local copy of the orderbook.

To ensure that the updates are received in sequence, seqNum indicates the current sequence and prevSeqNum refers to the packet before. seqNum will always be one after the prevSeqNum. If the sequence is out of order, unsubscribe and re-subscribe to the topic again.

Also, if a crossed orderbook ever occurs (best bid is higher than or equal to best ask), unsubscribe and re-subscribe to the topic again.

Response Content​

NameTypeRequiredDescription
topicStringYesWebSocket topic
dataObjectYesData object

Data Object:

NameTypeRequiredDescription
bidsString[][]YesBid quotes
asksString[][]YesAsk quotes
seqNumIntegerYesCurrent sequence number
prevSeqNumIntegerYesPrevious sequence number
typeStringYessnapshot β€” Snapshot of the orderbook with a maximum of 50 levels; delta β€” Updates of the orderbook
timestampLongYesTimestamp of the orderbook
symbolStringYesOrderbook symbol
example

Request

{
"op": "subscribe",
"args": [
"update:BTC-PERP_0"
]
}

Request

{
"op": "unsubscribe",
"args": [
"update:BTC-PERP_0"
]
}

Response

{
"topic": "update:BTC-PERP_0",
"data": {
"bids": [
[
"122160.1",
"69350"
],
[
"122159.9",
"226150"
],
[
"122159.5",
"63050"
],
[
"122159.3",
"109800"
],
[
"122159.2",
"104050"
]
],
"asks": [
[
"122133.3",
"1000"
],
[
"122124.0",
"343410"
],
[
"122123.9",
"78500"
],
[
"122123.8",
"98500"
]
],
"seqNum": 628282,
"prevSeqNum": 628281,
"type": "snapshot",
"timestamp": 1565135165600,
"symbol": "BTC-PERP"
}
}

Response

{
"topic": "update:BTC-PERP_0",
"data": {
"bids": [],
"asks": [
[
"122123.9",
"78500"
],
[
"122123.8",
"98500"
]
],
"seqNum": 628283,
"prevSeqNum": 628282,
"type": "delta",
"timestamp": 1565135165600,
"symbol": "BTC-PERP"
}
}