oxarchive
Official Rust SDK for 0xArchive — Historical Market Data API.
Supports multiple exchanges:
- Hyperliquid — Perpetuals data from April 2023
- Hyperliquid HIP-3 — Builder-deployed perpetuals (Pro+ only, February 2026+)
- Lighter.xyz — Perpetuals data (August 2025+ for fills, Jan 2026+ for OB, OI, Funding Rate)
Installation
Add to your Cargo.toml:
[]
= "1.1"
= { = "1", = ["rt-multi-thread", "macros"] }
For WebSocket support (real-time streaming, replay, bulk download):
= { = "1.1", = ["websocket"] }
Quick Start
use OxArchive;
async
Configuration
use OxArchive;
use Duration;
let client = builder
.base_url // Optional
.timeout // Optional (default: 30s)
.build?;
REST API Reference
All examples use client.hyperliquid.* but the same methods are available on client.lighter.* for Lighter.xyz data and client.hyperliquid.hip3.* for HIP-3 data.
Order Book
use ;
// Get current order book
let ob = client.hyperliquid.orderbook.get.await?;
println!;
println!;
println!;
// Get with specific timestamp and depth
let ob = client.hyperliquid.orderbook.get.await?;
// Get historical snapshots
let history = client.hyperliquid.orderbook.history.await?;
Orderbook Depth Limits
| Tier | Max Depth |
|---|---|
| Free | 20 |
| Build | 50 |
| Pro | 100 |
| Enterprise | Full Depth |
Note: Hyperliquid source data only contains 20 levels. Higher limits apply to Lighter.xyz data.
Lighter Orderbook Granularity
Lighter.xyz orderbook history supports a granularity parameter for different data resolutions:
use LighterGranularity;
let history = client.lighter.orderbook.history.await?;
| Granularity | Interval | Tier Required | Credit Multiplier |
|---|---|---|---|
Checkpoint |
~60s | Free+ | 1x |
ThirtySeconds |
30s | Build+ | 2x |
TenSeconds |
10s | Build+ | 3x |
OneSecond |
1s | Pro+ | 10x |
Tick |
tick-level | Enterprise | 20x |
Orderbook Reconstruction (Enterprise)
Tick-level orderbook history returns a full checkpoint plus incremental deltas, allowing you to reconstruct the exact state of the order book at every tick. This is the most granular data available and is ideal for backtesting, market microstructure research, and latency analysis.
use OxArchive;
use OrderBookReconstructor;
use ReconstructOptions;
let client = new?;
// Option 1: One-shot — fetch and reconstruct in one call
let snapshots = client.lighter.orderbook.history_reconstructed.await?;
for snapshot in &snapshots
// Option 2: Auto-paginated — fetches all pages automatically
let all_snapshots = client.lighter.orderbook.collect_tick_history.await?;
println!;
// Option 3: Manual control — fetch raw tick data and reconstruct yourself
let tick_data = client.lighter.orderbook.history_tick.await?;
// Check data integrity
let gaps = detect_gaps;
if !gaps.is_empty
// Reconstruct with full control
let mut reconstructor = new;
reconstructor.initialize;
for delta in &tick_data.deltas
// Or get just the final state (most efficient)
let final_state = reconstructor.reconstruct_final;
println!;
Manual Pagination
For large time ranges where memory is a concern, paginate manually instead of using collect_tick_history:
let mut cursor = 1704067200000_i64;
let end = 1704153600000_i64;
while cursor < end
Trades
Cursor-based pagination for efficient retrieval of large datasets.
use GetTradesParams;
// Get trades with pagination
let result = client.hyperliquid.trades.list.await?;
// Paginate through all results
let mut all_trades = result.data;
let mut cursor = result.next_cursor;
while let Some = cursor
// Get recent trades (Lighter only)
let recent = client.lighter.trades.recent.await?;
Note: The recent() method is only available for Lighter.xyz. Hyperliquid does not have a recent trades endpoint — use list() with a time range instead.
Instruments
// List all Hyperliquid instruments
let instruments = client.hyperliquid.instruments.list.await?;
for inst in &instruments
// Get specific instrument
let btc = client.hyperliquid.instruments.get.await?;
// Lighter.xyz instruments (different schema with fees, market IDs)
let lighter_instruments = client.lighter.instruments.list.await?;
for inst in &lighter_instruments
// HIP-3 instruments (derived from live data, includes mark price + OI)
let hip3_instruments = client.hyperliquid.hip3.instruments.list.await?;
for inst in &hip3_instruments
Funding Rates
use FundingHistoryParams;
use OiFundingInterval;
// Get current funding rate
let current = client.hyperliquid.funding.current.await?;
println!;
// Get history with aggregation interval
let history = client.hyperliquid.funding.history.await?;
Aggregation Intervals
| Interval | Description |
|---|---|
5m |
5 minutes |
15m |
15 minutes |
30m |
30 minutes |
1h |
1 hour |
4h |
4 hours |
1d |
1 day |
When omitted, raw ~1 minute data is returned.
Open Interest
use OpenInterestHistoryParams;
use OiFundingInterval;
// Get current open interest
let current = client.hyperliquid.open_interest.current.await?;
println!;
// Get history with aggregation
let history = client.hyperliquid.open_interest.history.await?;
Liquidations (Hyperliquid only)
Historical liquidation events from May 2025 onwards.
use *;
// Get liquidation history
let liquidations = client.hyperliquid.liquidations.history.await?;
// Get liquidations for a specific user
let user_liq = client.hyperliquid.liquidations.by_user.await?;
// Get pre-aggregated liquidation volume (100-1000x less data)
let volume = client.hyperliquid.liquidations.volume.await?;
for bucket in &volume.data
Candles (OHLCV)
use CandleHistoryParams;
use CandleInterval;
let candles = client.hyperliquid.candles.history.await?;
for candle in &candles.data
Available Intervals
1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w
Freshness
Check when each data type was last updated for a specific coin.
let freshness = client.hyperliquid.freshness.await?;
let lighter_freshness = client.lighter.freshness.await?;
let hip3_freshness = client.hyperliquid.hip3.freshness.await?;
Summary
Combined market snapshot — mark/oracle price, funding rate, open interest, 24h volume, and liquidation volumes.
let summary = client.hyperliquid.summary.await?;
let lighter_summary = client.lighter.summary.await?;
let hip3_summary = client.hyperliquid.hip3.summary.await?;
Price History
Mark, oracle, and mid price history. Supports aggregation intervals.
let prices = client.hyperliquid.price_history.await?;
Data Quality Monitoring
Monitor data coverage, incidents, latency, and SLA compliance.
// System health status
let status = client.data_quality.status.await?;
println!;
// Data coverage
let coverage = client.data_quality.coverage.await?;
// Symbol-specific coverage with gap detection
let btc = client.data_quality.symbol_coverage.await?;
// Incidents
let incidents = client.data_quality.list_incidents.await?;
let incident = client.data_quality.get_incident.await?;
// Latency and SLA
let latency = client.data_quality.latency.await?;
let sla = client.data_quality.sla.await?;
Web3 Authentication
Wallet-based authentication using SIWE (Sign-In with Ethereum) and x402 USDC payments.
// Step 1: Get a SIWE challenge
let challenge = client.web3.challenge.await?;
// Step 2: Sign the challenge and register
let result = client.web3.signup.await?;
println!;
// Manage API keys
let keys = client.web3.list_keys.await?;
client.web3.revoke_key.await?;
// Subscribe with x402 USDC payment
let sub = client.web3.subscribe.await?;
WebSocket Client
Requires the websocket feature. Supports three modes on a single connection:
- Real-time — subscribe to live market data
- Replay — replay historical data with timing preserved
- Stream — bulk-download historical data as fast as possible
Real-time Streaming
use ;
let mut ws = new;
ws.connect.await?;
ws.subscribe.await?;
ws.subscribe.await?;
let mut rx = ws.rx.take.expect;
while let Some = rx.recv.await
Historical Replay
// Replay BTC orderbook at 100x speed
ws.replay.await?;
// Control playback
ws.replay_pause.await?;
ws.replay_resume.await?;
ws.replay_seek.await?;
ws.replay_stop.await?;
Bulk Streaming
// Stream trades as fast as possible
ws.stream.await?;
let mut rx = ws.rx.take.expect;
while let Some = rx.recv.await
Available Channels
| Channel | Description | Historical |
|---|---|---|
orderbook |
L2 order book (~1.2s resolution) | Yes |
trades |
Trade/fill updates | Yes |
candles |
OHLCV candle data | Yes |
liquidations |
Liquidation events (May 2025+) | Yes |
open_interest |
Open interest snapshots (May 2023+) | Yes |
funding |
Funding rate snapshots (May 2023+) | Yes |
ticker |
Price and 24h volume | Real-time only |
all_tickers |
All market tickers | Real-time only |
lighter_orderbook |
Lighter.xyz L2 order book | Yes |
lighter_trades |
Lighter.xyz trades | Yes |
lighter_candles |
Lighter.xyz candles | Yes |
lighter_open_interest |
Lighter.xyz open interest | Yes |
lighter_funding |
Lighter.xyz funding rates | Yes |
hip3_orderbook |
HIP-3 L2 order book | Yes |
hip3_trades |
HIP-3 trades | Yes |
hip3_candles |
HIP-3 candles | Yes |
hip3_open_interest |
HIP-3 open interest | Yes |
hip3_funding |
HIP-3 funding rates | Yes |
Tier Limits
| Tier | Max Subscriptions | Max Replay Speed | Max Batch Size |
|---|---|---|---|
| Free | — | — | — |
| Build | 25 | 50x | 2,000 |
| Pro | 100 | 100x | 5,000 |
| Enterprise | 200 | 1000x | 10,000 |
Timestamp Formats
All time parameters accept the Timestamp enum:
use Timestamp;
// Unix milliseconds (i64)
let ts: Timestamp = 1704067200000_i64.into;
// ISO 8601 string
let ts: Timestamp = "2024-01-01T00:00:00Z".into;
// chrono::DateTime<Utc>
let ts: Timestamp = now.into;
Error Handling
use Error;
match client.hyperliquid.orderbook.get.await
Examples
Run the included examples:
# Basic usage
# Cursor-based pagination
# WebSocket (requires websocket feature)
Requirements
- Rust 1.75+
- tokio runtime
License
MIT