depth:SYMBOL WebSocket stream when your application must maintain a live local copy.
Read a snapshot
Combine the snapshot and stream
The depth stream contains only levels that changed, so it cannot initialize a complete book by itself.1
Subscribe and buffer
Connect to WebSocket streams, subscribe to
depth:SYMBOL, and buffer every
message without applying it yet.2
Fetch a snapshot
Request
GET /markets/:symbol/orderbook while buffering continues.3
Discard covered updates
Discard buffered messages whose
lastUpdateId is less than or equal to the snapshot’s
lastUpdateId.4
Apply the remainder
Apply the remaining buffered messages in arrival order, then apply new messages as they arrive.