Skip to main content
Use the L2 methods to read complete reconstructed books or the original stored order book updates. The SDKs support legacy snapshots and deltas alongside unified v2 orderbook events.

Choose an L2 method

Method signatures

Parameters

If either time boundary is omitted, the SDK resolves a bounded range from catalog metadata. Explicitly bounded ranges can replay from complete local coverage without a network request.

Event versions and time

Legacy rows retain their original orderbook, orderbook_snapshot, l2_snapshot, or orderbook_delta type and use timestamp. V2 uses only type: "orderbook", uses data.is_snapshot to classify the update, and uses collector_timestamp as the SDK event time. Nullable exchange_timestamp remains venue-time provenance. A snapshot replaces both sides of the book. A delta replaces the quantity at each listed price, and quantity zero removes that price. A legacy delta can omit an unchanged side; v2 provides both side arrays.

Complete L2 snapshots

l2_snapshots() and l2Snapshots() reconstruct complete books by default. Python and Rust return single-pass streams; TypeScript returns an array. Materialized L2 rows use the standard event envelope with type: "orderbook" and these fields under data:
  • data.bids: bid levels sorted from highest to lowest price
  • data.asks: ask levels sorted from lowest to highest price
  • data.is_snapshot: v2 origin flag; true replaces the book and false applies absolute updates
Materialized v2 deltas retain data.is_snapshot: false even though their bids and asks contain the complete current book. This lets you identify the stored update that produced the materialized state.

Reconstruction lifecycle

  1. A snapshot initializes or replaces the complete book.
  2. A delta updates only its listed price levels.
  3. A zero-quantity update deletes its price level.
  4. A coverage gap or reconnect clears reconstructed state.
  5. Following deltas are skipped until another snapshot initializes the book.

Raw L2 updates

l2_updates() and l2Updates() return the original snapshots and sparse deltas without constructing a complete book for every update. Use them for execution replay, custom sampling, or application-managed order book state. A v2 snapshot has data.is_snapshot: true; a v2 delta has data.is_snapshot: false:

Build complete books on demand

Use OrderbookBuilder.update() to maintain native book state without allocating a complete result after every update. Call snapshot() only when you need sorted bid and ask levels. Builder state is isolated by (source, market).
update() returns false for a delta received before its first snapshot. snapshot(source, market) returns None or undefined until that book has been initialized.

Builder methods

Use update() in high-frequency loops. Use apply() only when every update must immediately produce a complete book. When apply() materializes a v2 delta, the output deliberately retains data.is_snapshot: false.
Do not carry reconstructed state across a known coverage gap. Keep allow_gaps=False for continuous books, or process each covered interval separately and clear the builder before the next interval.

How it works

Both L2 methods use snapshot-first historical replay. See Snapshots for the full flow. Raw update iteration stays bounded in memory.