Docs

BBO (Best Bid/Offer) - Top of Book

Stream the best bid and best ask for any Hyperliquid trading pair. BBO gives you the top-of-book price with minimal bandwidth — ideal for price tracking, execution triggers, and spread monitoring.

How It Works

There is no dedicated BBO method or channel. To get best-bid/best-ask data, you subscribe to l2Book with nLevels=1. This returns exactly one bid and one ask level — functionally identical to a BBO feed. Everything on this page uses the standard l2Book subscription; the only difference from a full order book is setting nLevels to 1.

Stream the best bid and best ask for any trading pair with minimal bandwidth — ideal for price tracking, execution triggers, and spread monitoring. The nLevels parameter is a Dwellir-specific optimisation not available on the public Hyperliquid API.

Code Examples Repository

How to Subscribe

Send a subscription message to the WebSocket endpoint:

JSON
{
  "method": "subscribe",
  "subscription": {
    "type": "l2Book",
    "coin": "BTC",
    "nSigFigs": 5,
    "nLevels": 1
  }
}

Subscription Parameters

ParameterTypeRequiredDefaultDescription
typestringYes-Must be "l2Book"
coinstringYes-Trading pair symbol (e.g., "BTC", "ETH", "xyz:MSTR", "@150")
nSigFigsnumberNo5Price precision: use 5 for full granularity (recommended for BBO)
nLevelsnumberNo20Set to 1 to receive only the best bid and best ask

HIP3 Markets

For HIP3 (permissionless perpetuals) markets, use the full coin label format with the xyz: prefix. For example, use "xyz:MSTR" for the MicroStrategy perpetual, not just "MSTR". Standard perpetuals like BTC and ETH do not require a prefix.

Spot Markets

For spot markets, use the @{index} format where the index is the spot asset index. For example, use "@150" for a specific spot market.

Why nSigFigs=5 for BBO

nSigFigs=5 gives full price precision with no rounding or aggregation. This matches what the public Hyperliquid bbo channel returns natively. Lower values aggregate prices and may not reflect the true best level.

nSigFigsBTC ExampleEffect
5$106,217Most granular - individual price points
4$106,200Moderate aggregation
3$106,000Coarse aggregation
2$110,000Very coarse - major levels only

For BBO use cases, always use nSigFigs=5 to ensure you receive the true best bid and ask.

The first websocket message after subscribing is a subscriptionResponse; subsequent messages carry the l2Book payloads.

Response Field Reference

FieldTypeDescription
channelstringAlways "l2Book" for this subscription type
data.coinstringTrading pair symbol
data.timenumberUnix timestamp in milliseconds
data.levelsarrayTwo-element array: [bids, asks] — each containing exactly one level object
levels[0]arrayBest bid (highest buy price)
levels[1]arrayBest ask (lowest sell price)

Level Object Fields

FieldTypeDescription
pxstringPrice level
szstringTotal size at this price level
nnumberNumber of orders aggregated at this level

Dwellir BBO vs Public Hyperliquid BBO

The public Hyperliquid API has a dedicated bbo WebSocket channel, but our approach uses l2Book with nLevels=1 which produces equivalent results.

The public API does not support nLevels on l2Book — it always returns all 20 levels. nLevels is a Dwellir-specific parameter.

We tested l2Book(nLevels=1, nSigFigs=5) against the public bbo channel and confirmed 100% price match across BTC, ETH, and SOL.

Sourcebid_pxask_pxFormat
Dwellir l2Book(nLevels=1)"85.426""85.427"Same
Public Hyperliquid bbo"85.426""85.427"Same
Public Hyperliquid l2Book (top)"85.426""85.427"Same

Size Differences

Sizes (sz) may differ slightly between any two connections due to update timing — this is expected and applies to any two independent WebSocket connections.

Use Cases

Price Feeds & Tickers

Display live mid-price or last price with minimal data overhead.

Spread Monitoring

Track bid-ask spread in real-time for market quality assessment.

Execution Triggers

Fire orders when the best bid or ask crosses a threshold.

Multi-Coin Dashboards

Subscribe to BBO for many coins simultaneously with low bandwidth (1 level per coin vs 20).

Latency-Sensitive Strategies

Smaller payloads = faster parsing. BBO messages are ~10x smaller than full 20-level book updates.

Subscription Management

Switching Between BBO and Full Depth

Python
# Subscribe to BBO
await websocket.send(json.dumps({
    "method": "subscribe",
    "subscription": {"type": "l2Book", "coin": "BTC", "nSigFigs": 5, "nLevels": 1}
}))

# Later, switch to full depth (20 levels)
await websocket.send(json.dumps({
    "method": "unsubscribe",
    "subscription": {"type": "l2Book", "coin": "BTC", "nLevels": 1}
}))

await websocket.send(json.dumps({
    "method": "subscribe",
    "subscription": {"type": "l2Book", "coin": "BTC", "nSigFigs": 5, "nLevels": 20}
}))

Get Access

Ready to integrate real-time Hyperliquid BBO data?


Stream institutional-grade Hyperliquid order book data with Dwellir's ultra-low latency infrastructure.