Zum Hauptinhalt springen

L2 Order Book Dataset

Aktualisiert am
10. Juni 2026

Übersicht

Die StreamL2Book stream delivers aggregated price-level depth for a given coin. Each message contains the full L2 snapshot — total size and order count at each price level — refreshed every block.

gRPC : OrderBookStreaming
gRPC : StreamL2Book
Modell aktualisieren: Full snapshot every block — no client-side state management required

So funktioniert es

Instant, ongoing access to the full L2 order book: StreamL2Book delivers a complete L2 snapshot every block. There is no need to:

  • Fetch an initial snapshot from the REST Info endpoint
  • Stitch incremental diffs onto a snapshot
  • Handle race conditions during the snapshot-to-diff transition
  • Re-bootstrap on reconnect

Each message is the full current state of the order book at that block, aggregated by price level.

Datenstruktur

Each L2BookUpdate message contains the full aggregated book at the time of a block:

{
"coin": "BTC",
"time": 1764867600518,
"block_number": 817863403,
"bids": [
{ "px": "95000.0", "sz": "12.5432", "n": 47 },
{ "px": "94999.5", "sz": "8.2100", "n": 23 },
{ "px": "94999.0", "sz": "5.0000", "n": 12 }
],
"asks": [
{ "px": "95000.5", "sz": "10.8900", "n": 38 },
{ "px": "95001.0", "sz": "6.3210", "n": 15 },
{ "px": "95001.5", "sz": "3.7500", "n": 9 }
]
}

Anfrageparameter

FeldTypErforderlichBeschreibung
MünzeZeichenketteJaSymbol für das Abonnement – bei Perpetual-Kontrakten werden Namen verwendet (z. B. „BTC“, „ETH“), beim Spot-Handel das @index-Format (z. B. „@142“)
n_levelsuint32JaMaximum number of price levels to return per side (default 20, max 100)
n_sig_figsuint32NeinSignificant figures for price bucketing (2–5). Omit for exact price-level aggregation.
mantissauint64NeinMantissa for price bucketing (1, 2, or 5). Used with n_sig_figs to control bucket width.

Benennung von Münzen

Die Münze Der Parameter folgt der Namenskonvention Hyperliquid, die Perpetuals eindeutig vom Spot unterscheidet:

  • Unbefristete Verträge: Für Menschen lesbare Namen — „BTC“, „ETH“, „HYPE“, „SOL“
  • Spot-Token: @{index} Format — "@1", „@107“, "@142", "@166"
  • Ergebnismärkte (HIP-4): #N Format. Jedes Ergebnis hat zwei #N Münzen – je eine pro Seite (Ja und Nein). Märkte mit Mehrpreis-Fragen bestehen aus mehreren gruppierten Ergebnissen (Preiskategorien plus einer Ausweichoption), wobei jede Gruppe über ein eigenes Ja/Nein-Münzpaar verfügt. Verwenden Sie die outcomeMeta endpoint Zuordnung von Münzindizes zu Marktbezeichnungen und Seiten.
  • Ausnahme: „PURR/USDC“ ist die einzige Spot-Münze, auf der ein Name zu lesen ist

Es gibt keine Überschneidungen zwischen den Formaten. „BTC“ bezieht sich immer auf den BTC-Perpetual-Kontrakt; der Spot-BTC ist "@142". Um zu entdecken @index Zuordnungen für Spot-Token, Abfrage der Meta oder spotMeta Info-Endpunkte.

Price Bucketing

The optional n_sig_figs und mantissa parameters control how prices are aggregated into buckets. When omitted, each distinct price level is reported individually. When set, orders are grouped into price buckets — for example, bucketing BTC orders into $100 increments instead of exact prices.

  • n_sig_figs (2–5): Number of significant figures in the bucket price
  • mantissa (1, 2, or 5): Mantissa multiplier for the bucket width

Antwortfelder

L2BookUpdate

FeldTypBeschreibung
MünzeZeichenketteSymbol (z. B. „BTC“, „ETH“)
Zeituint64Block-Zeitstempel in Millisekunden
block_numberuint64Block number
GeboteL2Level[]Aggregated bid levels, ordered best (highest) price first
fragtL2Level[]Aggregated ask levels, ordered best (lowest) price first

L2Level

FeldTypBeschreibung
pxZeichenkettePrice as a decimal string
szZeichenketteTotal size across all orders at this price level, as a decimal string
nuint32Number of individual orders at this price level

Proto-Definition

StreamL2Book ist definiert in orderbook.proto:

service OrderBookStreaming {
rpc StreamL2Book (L2BookRequest) returns (stream L2BookUpdate);
}

message L2BookRequest {
string coin = 1;
uint32 n_levels = 2;
optional uint32 n_sig_figs = 3;
optional uint64 mantissa = 4;
}

message L2BookUpdate {
string coin = 1;
uint64 time = 2;
uint64 block_number = 3;
repeated L2Level bids = 4;
repeated L2Level asks = 5;
}

message L2Level {
string px = 1;
string sz = 2;
uint32 n = 3;
}

Beispiele für Aktualisierungen

Full L2 Snapshot (top 5 levels)
{
"coin": "BTC",
"time": 1764867600518,
"block_number": 817863403,
"bids": [
{ "px": "95000.0", "sz": "12.5432", "n": 47 },
{ "px": "94999.5", "sz": "8.2100", "n": 23 },
{ "px": "94999.0", "sz": "5.0000", "n": 12 },
{ "px": "94998.0", "sz": "3.1250", "n": 8 },
{ "px": "94997.5", "sz": "1.7500", "n": 5 }
],
"asks": [
{ "px": "95000.5", "sz": "10.8900", "n": 38 },
{ "px": "95001.0", "sz": "6.3210", "n": 15 },
{ "px": "95001.5", "sz": "3.7500", "n": 9 },
{ "px": "95002.0", "sz": "2.5000", "n": 6 },
{ "px": "95003.0", "sz": "1.2000", "n": 3 }
]
}
L2 Snapshot with Price Bucketing

When using n_sig_figs=3 und mantissa=1, prices are aggregated into broader buckets:

{
"coin": "BTC",
"time": 1764867600518,
"block_number": 817863403,
"bids": [
{ "px": "95000.0", "sz": "25.8782", "n": 82 },
{ "px": "94900.0", "sz": "18.4300", "n": 61 },
{ "px": "94800.0", "sz": "12.1000", "n": 34 }
],
"asks": [
{ "px": "95100.0", "sz": "21.0110", "n": 62 },
{ "px": "95200.0", "sz": "14.7210", "n": 40 },
{ "px": "95300.0", "sz": "8.9500", "n": 18 }
]
}

API-Nutzung

gRPC
// Perp order book
const request = {
coin: 'BTC',
n_levels: 20
};

// Spot order book (@ index format)
const spotRequest = {
coin: '@142',
n_levels: 20
};

// With price bucketing
const bucketedRequest = {
coin: 'BTC',
n_levels: 20,
n_sig_figs: 3,
mantissa: 1
};

gRPC

StreamL2Book ist nur über die gRPC -API verfügbar (OrderBookStreaming Dienst). Er ist nicht über JSON-RPC oder WebSocket verfügbar.

Comparison with Book Updates Dataset

FunktionStreamL2BookBOOK_UPDATES (StreamData)
Includes current book stateYes — every message is a full snapshotNo — forward-only diffs from subscribe time
Erfordert REST-BootstrapNeinYes (Info endpoint l2Book)
Client-side state managementKeineBuild and maintain local book from diffs
Data granularityNach Preisniveau zusammengefasstEinzelne Abweichungen auf Auftragsebene
Reconnect handlingAutomatic — full snapshot resumesMust re-bootstrap from REST
Price bucketingSupported (n_sig_figs, mantissa)Not available

Wichtige Hinweise


  • Full snapshot every block: Each L2BookUpdate is a complete snapshot — no need to track state across messages
  • zstd compression recommended: Enable zstd compression on your gRPC channel to reduce bandwidth, especially when streaming multiple coins

  • StreamL4Book - Individual order granularity with user, oid, size, triggers, and timestamps
  • StreamBboBook - Top-of-book best bid/ask, emitted only when the BBO changes
  • StreamL2BookDiff - Incremental L2 price-level changes with sequence numbers
  • Book Updates - Forward-only incremental diffs via StreamData
  • Aufträge - Ereignisse im Auftragslebenszyklus (eröffnet, ausgeführt, storniert usw.)
  • Transaktionen - Daten zu ausgeführten Geschäften mit Maker-/Taker-Informationen