Order Book Delta WebSocket API
Pre-release note: The delta feed and this documentation are subject to change before launch.
Overview
The Order Book Delta feed provides real-time incremental updates for a specified currency pair. Use the first snapshot message as the authoritative starting state, then apply each sequential update message to maintain a synchronized local order book.
This feed uses the same WebSocket connection and subscription model as the existing Order Book feed*. The existing feed publishes full snapshots; the delta feed publishes both snapshot and update messages, with update messages containing only the levels that have changed.
Subscribe
Subscribe using the feed name orderbook.delta.<pair>, where <pair> is the lowercase currency pair.
{
"type": "subscribe",
"feeds": ["orderbook.delta.btcusd"]
}Message format
pair
string
Currency pair for the order book, for example btcusd.
type
string
Message type: snapshot or update.
bids
array
Bid levels. Each level is [price, quantity, liquidity_source].
asks
array
Ask levels. Each level is [price, quantity, liquidity_source].
lu
integer
UNIX timestamp in milliseconds when the order book was last updated.
lp
integer
UNIX timestamp in milliseconds when the order book was last published.
u
integer
Incrementing update ID used to validate message order within the feed.
market_making
object
Separate top-of-book maker quotes, grouped into bids and asks.
Order book level format
[price, quantity, liquidity_source]
Prices and quantities are represented as strings. For normal order book levels, maintain entries by the combination of side, price, and liquidity source.
Snapshot message
A snapshot contains the complete normal and market-making state for the feed. Replace both local books in full and store its update ID for validation of the next update.
Update message
An update includes only levels that changed. Omitted levels and liquidity sources remain unchanged. A quantity of "0" removes the corresponding entry.
Apply normal order book updates
Locate the entry using side, price, and liquidity source.
If quantity is non-zero, insert the level or replace its current quantity.
If quantity is "0", remove the level.
Keep all levels omitted from the message unchanged.
Synchronize with update IDs
Every message includes an update ID in u. Validate update IDs only against messages from the same feed, such as orderbook.delta.btcusd.
When a snapshot is received
Replace the entire local normal order book with the message's bids and asks.
Replace the entire local market-making book with
market_making.bidsandmarket_making.asks.Accept the snapshot regardless of whether its update ID is sequential from the preceding message.
Store the snapshot's update ID and use it to validate the next update.
When an update is received
Confirm that the message's u equals the previously accepted u + 1.
If the update ID is sequential, apply the normal and market-making deltas.
If the update ID is not sequential, do not apply that message or any later updates from the feed.
Unsubscribe and subscribe again to start a new feed, then rebuild local state from a new snapshot.
Important: A gap, duplicate, or out-of-order update means local state can no longer be trusted. Resynchronize before applying further updates.
Market-making book
market_making is a separate top-of-book view. It contains at most one maker bid and one maker ask per liquidity source and is independent from the normal bids and asks arrays.
Market-making prices are maker-fee-adjusted and may differ from the same source's levels in the normal order book.
snapshot
Replace the full bids and asks state.
Replace the full bids and asks maps.
update
Apply only the supplied level changes.
Apply only the supplied source changes.
Maintain market-making state
Maintain separate bid and ask maps keyed by liquidity source, not by price.
On a snapshot, replace both maps in full.
On an update, upsert each supplied source on the indicated side.
If quantity is "0", remove that source's quote on the indicated side.
Sources omitted from an update remain unchanged.
An empty bids or asks array means there were no changes on that side.
Market-making removal example
This update removes the ox market-making bid. The coinbase market-making bid and all market-making asks remain unchanged.
Last updated