[price, amount] tuples. The server pushes incremental deltas every 100ms; if 10 seconds pass without an emitted depth_update on this subscription, a full snapshot is sent as a keepalive. Use this channel to maintain a live local order book for trading logic or display.
Connect to
wss://api.whitebit.com/ws — see WebSocket Overview for protocol details and keepalive requirements.Rate limits
Query order book depth (one-time)
Fetch a single order book snapshot without subscribing to updates. Request ResponseSubscribe to order book depth
Public
depth updates exclude Retail Price Improvement (RPI) orders. The stream includes only regular order book liquidity.Including RPI orders in a local order book
Publicdepth excludes RPI orders by design, so they never appear in this stream. RPI resting liquidity is not published on any market-data feed — it is visible only in private active orders and in the exchange UI order book.
To display an account’s own RPI orders alongside the public book, overlay its private active orders onto the local depth book. Subscribe to ordersPending (private) alongside depth_subscribe, then merge:
- Overlay only orders with
rpi: true. Non-RPI orders already appear in the publicdepthaggregate — overlaying every order double-counts them. - Aggregate by price before merging. Public
depthlevels are price-aggregated[price, total amount], while the private stream is per-order. Sum the RPI orders by price level, and use each order’sleft(remaining amount), notamount(original size). - Map the side. Order
side1(sell) → ask;2(buy) → bid. - Upsert by
order_id. Add or update onevent_id1(new) and2(update); remove on3(finish).order_idchanges on modify — correlate withclient_order_id. Stop-order activation emits a secondevent_id=1for the sameorder_id, so upsert rather than append. - Filter by
marketto match the depth subscription.
Update frequency
The server pushes updates every 100ms when the order book changes within the subscribed depth. If 10 seconds pass without an emitteddepth_update on this subscription, a full snapshot is sent as a keepalive.
Error codes
Maintaining a local order book
To maintain an accurate local order book:- Subscribe and wait for the first message (
params[0]istrue) — initialize order book from snapshot - For each incremental update: if amount is
"0"remove the price level; otherwise update or insert at the correct sorted position - Keep asks sorted ascending, bids sorted descending
- Truncate to the configured limit after each update
Update model
First message (past_update_id absent): Full order book snapshot. Replace any existing local state.
Subsequent messages (past_update_id present): Incremental deltas. Apply each price level change to the local book.
Ordering guarantees
- Updates arrive in
update_idorder. Each incremental message’spast_update_idmatches the previous message’supdate_id. - If 10 seconds pass without an emitted
depth_updateon this subscription, the server sends a full snapshot (params[0]istrue, nopast_update_id) as a keepalive. Treat this as a full reset. update_idreflects changes to the full order book for this market. A keepalive snapshot may carry anupdate_idgreater than the last delta’supdate_id— this is expected and reflects book activity that did not produce adepth_updateon this subscription, not a missed message.- A gap between an incremental delta’s
past_update_idand the storedupdate_idindicates a missed message — re-subscribe to resync.