Parameters
string
required
Trading pair UUID. Get this from
sdk.market.getTradingPairBySymbol('BTC/USDC').'SPOT' | 'MARGIN'
required
Trading mode for the orderbook subscription. Use
'SPOT' for spot markets and 'MARGIN' for perp markets.number
required
Price level grouping magnitude. Valid values:
0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000'BASE' | 'QUOTE'
required
Quantity denomination.
BASE shows quantities in base token, QUOTE multiplies by price.number
default:"10"
Number of price levels to fetch (max: 100)
Return Values
OrderbookEvent | null
Current orderbook snapshot with bids, asks, best prices, and volumesProperties:
tradingPairId: Trading pair ID (UUID)tradingMode: “SPOT” | “MARGIN”bids: Array of{ price, quantity, orderCount }asks: Array of{ price, quantity, orderCount }bestBid: Best bid pricebestAsk: Best ask pricebidVolume: Total bid volumeaskVolume: Total ask volumepriceChange: Price change info (optional) -{ side, oldPrice?, newPrice?, levelRemoved, levelAdded }baseDecimals: Base token decimalsquoteDecimals: Quote token decimalstimestamp: Snapshot timestampsequence: Sequence number for ordering
boolean
Whether currently subscribed to real-time updates
Error | null
Connection or subscription error if any
() => void
Clear the current error
Example
How It Works
- Initial Load: Fetches orderbook snapshot via REST API
- Real-time Updates: Subscribes to WebSocket for live updates
- Auto-cleanup: Unsubscribes when component unmounts or params change

