Présentation générale
Le StreamBboBook stream delivers the best bid and best ask (top of book) for one or more coins. An update is emitted only when the best bid or ask changes for a coin, making it the lightweight feed for clients that just need live prices and spread without order book depth.
gRPC : OrderBookStreaming
gRPC : StreamBboBook
Modèle de mise à jour : Emit-on-change: one message per coin whose best bid or ask changed
Comment ça marche ?
StreamBboBook watches the top of the book for every subscribed coin and emits a message whenever the best bid or best ask changes, including size changes at the same best price. Compared to consuming full StreamL2Book snapshots:
- Each message carries only the best bid and best ask, not full depth
- Messages are emitted only on change, not every block
- A single stream can cover multiple coins (or all coins with an empty
coinslist) - No client-side state management is required, since each message is the current top of book
Each message covers exactly one coin. If a side of the book is empty, the corresponding bid ou ask field is absent.
Structure de données
Each BboBookUpdate message contains the current best bid and ask for a single coin:
{
"coin": "BTC",
"time": 1781109022243,
"block_number": 586404610,
"bid": { "px": "62990", "sz": "0.001", "n": 1 },
"ask": { "px": "63054", "sz": "0.00008", "n": 1 }
}
Paramètres de requête
| Champ | Type | Obligatoire | Description |
|---|---|---|---|
| coins | repeated string | Non | List of symbols to subscribe to (e.g., "BTC", "ETH"). Empty means all coins |
Dénomination des pièces
Le coins Ce paramètre respecte la convention de nommage Hyperliquid, qui distingue sans ambiguïté les contrats à durée indéterminée des contrats au comptant :
- Titre perpétuel: Human-readable names, such as
« BTC »,« ETH »,« HYPE »,« SOL » - Jetons au comptant:
@{index}format, such as« @1 »,« @107 »,« @142 »,« @166 » - Marchés des résultats (HIP-4):
#Nformat. Chaque résultat comporte deux#Ncoins, one per side (Yes and No). Multi-price question markets consist of multiple grouped outcomes (price buckets plus a fallback), each with its own Yes/No coin pair. Use theoutcomeMetaendpoint mettre en correspondance les indices des cryptomonnaies avec les noms et les côtés du marché. - Exception:
« PURR/USDC »C'est la seule pièce de monnaie dont le nom est lisible.
Il n'y a pas de chevauchement entre les formats. « BTC » fait toujours référence au contrat à terme perpétuel sur BTC ; le BTC au comptant est « @142 ». Pour découvrir @index mappages pour les jetons ponctuels, interroger le méta ou spotMeta points de terminaison d'information.
Champs de réponse
BboBookUpdate
| Champ | Type | Description |
|---|---|---|
| pièce de monnaie | chaîne de caractères | Symbole (par exemple, « BTC », « ETH ») |
| temps | uint64 | Horodatage du bloc en millisecondes |
| block_number | uint64 | Numéro de bloc |
| bid | L2Level | Best bid level. Absent if there is no resting bid |
| ask | L2Level | Best ask level. Absent if there is no resting ask |
L2Level
| Champ | Type | Description |
|---|---|---|
| px | chaîne de caractères | Price as a decimal string |
| sz | chaîne de caractères | Total size across all orders at this price level, as a decimal string |
| n | uint32 | Number of individual orders at this price level |
Définition de « proto »
StreamBboBook est défini dans orderbook.proto:
service OrderBookStreaming {
rpc StreamBboBook (BboBookRequest) returns (stream BboBookUpdate);
}
message BboBookRequest {
repeated string coins = 1;
}
message BboBookUpdate {
string coin = 1;
uint64 time = 2;
uint64 block_number = 3;
L2Level bid = 4;
L2Level ask = 5;
}
message L2Level {
string px = 1;
string sz = 2;
uint32 n = 3;
}
Exemples de mises à jour
BBO Update (single coin)
{
"coin": "BTC",
"time": 1781109022243,
"block_number": 586404610,
"bid": { "px": "62990", "sz": "0.001", "n": 1 },
"ask": { "px": "63054", "sz": "0.00008", "n": 1 }
}
Consecutive Updates (emit-on-change)
Consecutive ETH updates demonstrating the emit-on-change model. A size change at the same best price triggers an update:
{ "coin": "ETH", "time": 1781109213042, "block_number": 586405802,
"bid": { "px": "1701.1", "sz": "0.015", "n": 1 },
"ask": { "px": "1701.2", "sz": "0.0176", "n": 2 } }
{ "coin": "ETH", "time": 1781109220213, "block_number": 586405844,
"bid": { "px": "1701.1", "sz": "0.015", "n": 1 },
"ask": { "px": "1701.2", "sz": "0.0105", "n": 1 } }
{ "coin": "ETH", "time": 1781109221825, "block_number": 586405854,
"bid": { "px": "1701.1", "sz": "0.0079", "n": 1 },
"ask": { "px": "1701.2", "sz": "0.0105", "n": 1 } }
Utilisation de l'API
gRPC
// Single coin
const request = {
coins: ['BTC']
};
// Multiple coins in one stream
const multiRequest = {
coins: ['BTC', 'ETH', 'HYPE']
};
// All coins
const allCoinsRequest = {
coins: []
};
StreamBboBook n'est disponible que via l'API gRPC (OrderBookStreaming service). Il n'est pas disponible via JSON-RPC ou WebSocket.
Comparison with StreamL2Book
| Fonctionnalité | StreamBboBook | StreamL2Book |
|---|---|---|
| Data per message | Best bid and best ask only | Full depth snapshot (up to n_levels per side) |
| Message cadence | Only when the BBO changes | Every block |
| Coins per stream | Multiple (or all coins) | One coin per stream |
| Client-side state management | Aucun | Aucun |
| Bande passante | Lowest (top-of-book only) | Moyen (limité à n_levels) |
| Idéal pour | Live prices, spread monitoring, tickers | Market depth, analytics dashboards |
Remarques importantes
- Emit-on-change: Updates are sent only when the best bid or ask changes for a coin, including size changes at the same best price
- One coin per message: Each
BboBookUpdatecovers a single coin; subscribe to multiple coins (or all coins) on one stream and demultiplex by thepièce de monnaiefield - Absent sides: If a side of the book is empty, the
bidouaskfield is absent. Check for presence before reading it - zstd compression recommended: Enable zstd compression on your gRPC channel to reduce bandwidth, especially when streaming all coins
Streams associés
- StreamL2Book - Aggregated price-level depth, full snapshot every block
- StreamL2BookDiff - Incremental L2 price-level changes with sequence numbers
- Transactions - Données relatives aux transactions exécutées, avec informations sur les « makers » et les « takers »