SDKs
Use the official clients for typed market, order-level, data-quality, and web3 flows that match the API.
Use the official clients for typed requests across market data, order-level routes, data-quality monitoring, and wallet/web3 flows.
Installation
Install the package for your runtime, then make the first REST or WebSocket call.
Python
pip install oxarchiveTypeScript / Node.js
npm install @0xarchive/sdkRust
cargo add oxarchiveREST usage
Begin with one client, one key, and one request. The SDK method names stay close to the REST reference.
# pip install oxarchivefrom oxarchive import Client
client = Client(api_key="0xa_your_api_key")
# Hyperliquid datahl_orderbook = client.hyperliquid.orderbook.get("BTC")print(f"Hyperliquid BTC mid price: {hl_orderbook.mid_price}")
# Lighter.xyz datalighter_orderbook = client.lighter.orderbook.get("BTC")print(f"Lighter BTC mid price: {lighter_orderbook.mid_price}")
# HIP-3 builder perpship3_ob = client.hyperliquid.hip3.orderbook.get("xyz:XYZ100")print(f"HIP-3 XYZ100 mid price: {hip3_ob.mid_price}")
hip3_trades = client.hyperliquid.hip3.trades.recent("xyz:XYZ100", limit=10)print(f"Recent HIP-3 trades: {len(hip3_trades)}")
# Get trades with cursor paginationresult = client.hyperliquid.trades.list("ETH", start="2026-01-01", end="2026-01-02", limit=1000)trades = result.data
# Continue fetching all pageswhile result.next_cursor: result = client.hyperliquid.trades.list( "ETH", start="2026-01-01", end="2026-01-02", cursor=result.next_cursor, limit=1000 ) trades.extend(result.data)WebSocket usage
The same client handles live subscriptions and replay. The SDK examples follow the same connection model as the WebSocket docs.
import asynciofrom oxarchive import OxArchiveWs, WsOptions
async def main(): ws = OxArchiveWs(WsOptions(api_key="0xa_your_api_key"))
# Subscribe to real-time data ws.on_orderbook(lambda coin, data: print(f"{coin}: {data.mid_price}"))
await ws.connect() ws.subscribe_orderbook("BTC")
# Or replay historical data await ws.replay("orderbook", "BTC", start=1704067200000, speed=10)
asyncio.run(main())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 requestfor 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 reconstructiontick_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 gapsgaps = OrderBookReconstructor.detect_gaps(tick_data.deltas)if gaps: print("Gaps detected:", gaps)| Method | Best use | Notes |
|---|---|---|
| iterateTickHistory() | Long windows and production replay | Auto-paginates and handles large delta ranges cleanly. |
| historyTick() | Raw checkpoints and deltas | Single page, maximum 1,000 deltas. |
| historyReconstructed() | Direct reconstructed snapshots | Single page when you need the finished book immediately. |
| detectGaps() | Continuity checks | Use before backtests or downstream reconstruction pipelines. |
Published packages
Pick the package that matches your stack, then use the registry entry for install and versioning.
CLI and examples
Use the CLI for shell automation and the examples repo for working reference projects.