Skip to main content
Reconstruction is for applications that need a local book over time instead of independent snapshots.

Pattern

1

Start from a snapshot

Load the initial book state from REST or the first WebSocket snapshot.
2

Apply diffs in timestamp order

Ignore messages older than the snapshot timestamp and apply updates in order.
3

Detect gaps

If replay or live streams emit a gap signal, mark the local book as unsafe until it is rebuilt.
4

Resync when needed

Pull a fresh snapshot and resume from the latest known safe point.

Inputs

Reconstruction needs a trustworthy starting point and ordered changes. The starting point can come from a REST snapshot, a WebSocket snapshot, or a checkpoint route in venue families that expose checkpoints. Changes can come from diffs, replay messages, or a bounded historical stream. Store the source route or channel with every run.

TypeScript Reconstruction Helpers

The TypeScript SDK exposes Lighter tick-history helpers and an OrderBookReconstructor for workflows that need checkpoint plus delta reconstruction.
For larger windows, prefer the SDK’s async iterator helper when the installed package exposes it so pagination and reconstruction state stay together:
Use these helpers only on a venue route that exposes the required depth. Every plan can access the depth exposed by the selected route: L3 is Lighter-only, L4 is Hyperliquid-family-only, and full-depth L2 is available on covered Hyperliquid core and HIP-3 routes. Plans differ in credits, request rate, concurrency, replay speed, query windows, and exports. For other families, keep the same reconstruction discipline but use the documented REST and WebSocket route family for that market.

Python And Rust Helpers

The Python and Rust SDKs also expose reconstruction-oriented types and helpers. Use the package README for exact import paths and method names, then keep the same manifest and gap policy from this page. If a runtime helper is missing for the venue family, use the REST/WebSocket route directly and keep the same reconstruction checklist instead of pretending every SDK has the same method.

Gap Policy

A local book is only as trustworthy as its gap handling. If a replay, diff stream, or checkpoint route reports a missing segment, mark the local state unsafe and rebuild. Do not keep applying newer updates to a state that has an unknown hole. That can produce plausible but wrong depth.

Reconstruction Manifest

Store a manifest beside reconstructed output.

Venue Family Notes

Hyperliquid core, Hyperliquid Spot, HIP-3, HIP-4, and Lighter can expose different depth primitives. Keep the reconstruction code aware of venue family rather than trying to normalize every stream into one generic path. Use Venue coverage and Endpoint Reference pages before sharing reconstruction code across families.

Production Rule

Every reconstruction path needs a resync path. If the local book cannot recover from a missing diff, unavailable checkpoint, or replay gap, do not use it as production reconstruction logic. Verify recovery with a forced gap or closed connection, and record the rebuild trigger beside the manifest.
Last modified on August 13, 2026