Order Book Reconstruction

Enterprise helpers rebuild Lighter order books from checkpoints and deltas.

Tier
Enterprise
For
Tick-level Lighter history
Path
Iterator-first helpers

Use the official clients for typed requests across market data, order-level routes, data-quality monitoring, and wallet/web3 flows.

Order book reconstruction

Enterprise helpers rebuild Lighter tick history from checkpoints and deltas.

Tier
Enterprise
For
Tick-level Lighter order book history
Preferred path
Auto-paginating iterator
# Orderbook Reconstruction (Enterprise tier only)
from oxarchive import Client, OrderBookReconstructor
client = Client(api_key="0xa_your_api_key")
# Option 1: Auto-paginating iterator (recommended for large time ranges)
# Automatically handles pagination, fetching up to 1,000 deltas per request
for snapshot in client.lighter.orderbook.iterate_tick_history(
"BTC",
start="2026-01-01T00:00:00Z",
end="2026-01-01T12:00:00Z" # 12 hours of data
):
print(f"{snapshot.timestamp}: mid={snapshot.mid_price}")
if some_condition:
break # Early exit supported
# Option 2: Get fully reconstructed snapshots (single page)
snapshots = client.lighter.orderbook.history_reconstructed(
"BTC",
start="2026-01-01T00:00:00Z",
end="2026-01-01T01:00:00Z"
)
for ob in snapshots:
print(f"{ob.timestamp}: bid={ob.bids[0].px} ask={ob.asks[0].px}")
# Option 3: Get raw tick data for custom reconstruction
tick_data = client.lighter.orderbook.history_tick("BTC", start=start, end=end)
print(f"Checkpoint: {len(tick_data.checkpoint.bids)} bids")
print(f"Deltas: {len(tick_data.deltas)} updates")
# Check for sequence gaps
gaps = OrderBookReconstructor.detect_gaps(tick_data.deltas)
if gaps:
print("Gaps detected:", gaps)
MethodBest useNotes
iterateTickHistory()Long windows and production replayAuto-paginates and handles large delta ranges cleanly.
historyTick()Raw checkpoints and deltasSingle page, maximum 1,000 deltas.
historyReconstructed()Direct reconstructed snapshotsSingle page when you need the finished book immediately.
detectGaps()Continuity checksUse before backtests or downstream reconstruction pipelines.

Where to take the SDK next