amount is the absolute quantity for a price level, and if the amount is 0, you should remove the price level from the order book.
Important! In addition to the delta messages, the first message sent upon connection will be a snapshot of the level 2 order book.
Subscription Request
Subscribe method. Must be
subscribeArray of topics to subscribe to. Format:
orderbook/level_2_delta@BASE_QUOTEExample: ["orderbook/level_2_delta@ETH_BRL"]Stream Response
Each WebSocket message includes a sequential numeric id. Each topic has its own unique sequence, and for private topics, the sequence is unique to each topic and user. It’s important to note that some topics will send a “welcome message”, which will have an id value of -1. Additionally, this sequence may be reset between connections, so be sure to update this value locally whenever you reconnect.
Topic name (format:
orderbook/level_2_delta@BASE_QUOTE)Timestamp in milliseconds
Order book delta details object
Subscription Example
Initial Snapshot Response (First Message)
Delta Update Response
Key Characteristics
- Delta Only: Only includes price levels that have changed
- Snapshot First: First message after subscription is a full snapshot
- Amount = 0: Indicates the price level should be removed from your local copy
- Efficient Updates: Reduces bandwidth by only sending changes
- Buildable: You can build a complete order book from delta messages
How to Use Delta Updates
- Receive Snapshot: First message after subscribing is a complete order book snapshot
- Apply Deltas: For subsequent messages, apply the changes to your local copy:
- Update
amountfor each price level in the delta - Remove price levels where
amountis 0 - Keep all other price levels unchanged
- Update
- Maintain State: Your local order book stays in sync with the server
Implementation Example
Usage Notes
- Bandwidth Efficient: Send only changes, not the full book each time
- State Management: You need to maintain local state of the order book
- Price Level Removal: Always check for
amount = 0to remove levels - Hash Verification: Use the hash to verify your local book matches the server
- Error Recovery: If hash mismatch, resubscribe to get a new snapshot
Use Cases
- Real-time Order Book: Build and maintain a real-time order book with minimal bandwidth
- High-Frequency Updates: Efficiently handle rapid order book changes
- Low-Bandwidth Clients: Ideal for mobile or bandwidth-constrained clients
- Order Book Reconstruction: Rebuild order book state from delta stream