---
title: "0xArchive CLI and Rust SDK Now Available | 0xArchive"
description: "Use the 0xArchive CLI for JSON-first shell workflows and the Rust SDK for typed async market-data clients with optional WebSocket support."
canonical_url: "https://www.0xarchive.io/blog/cli-rust-sdk/"
markdown_url: "https://www.0xarchive.io/blog/cli-rust-sdk.md"
route: "/blog/cli-rust-sdk"
robots: "index, follow"
generated_from: "prerendered_html"
---

# 0xArchive CLI and Rust SDK Now Available | 0xArchive
Use the 0xArchive CLI for JSON-first shell workflows and the Rust SDK for typed async market-data clients with optional WebSocket support.
## Two New Ways to Access Market Data

We just shipped two new ways to access historical perpetual market data: a command-line interface and a native Rust SDK.

Both give you direct access to 34B+ orderbook snapshots, 3B+ fills, and funding/OI data across Hyperliquid, Hyperliquid HIP-3, and Lighter.xyz - the same data that powers our REST API, now available from your terminal and in native Rust.

> **Editor's note (March 25, 2026):**
> 0xArchive exposes two top-level venue APIs, Hyperliquid and Lighter.xyz. HIP-3 markets live under the Hyperliquid namespace, even though the CLI accepts
> `--exchange hip3`
> as a convenience scope.

## The CLI

The `oxa` CLI outputs JSON to stdout, errors to stderr, and uses deterministic exit codes. It's built for AI agents, shell scripts, and CI/CD pipelines - anything that benefits from structured, pipeable data.

### Install

```
npm install -g @0xarchive/cli
```

Or run without installing:

```
npx @0xarchive/cli auth test
```

### Authenticate

```
export OXA_API_KEY="0xa_your_api_key"
oxa auth test
```

### Quick Start

```
# Market summary - price, funding, OI, volume in one call
oxa summary --exchange hyperliquid --symbol BTC

# 4h candles for backtesting
oxa candles --exchange hyperliquid --symbol ETH \
  --start 2026-02-01T00:00:00Z --end 2026-03-01T00:00:00Z --interval 4h

# Current funding rate
oxa funding current --exchange hyperliquid --symbol BTC

# L2 orderbook snapshot
oxa orderbook get --exchange hyperliquid --symbol BTC

# Recent trades from Lighter.xyz
oxa trades fetch --exchange lighter --symbol BTC --limit 50

# List every available instrument
oxa instruments --exchange hyperliquid

# Check data freshness before acting
oxa freshness --exchange hyperliquid --symbol BTC
```

Every command works across Hyperliquid core, Hyperliquid HIP-3, and Lighter.xyz. In the CLI, switch `--exchange` between `hyperliquid`, `lighter`, and `hip3`.

### Commands

```
oxa auth test          # Verify API key
oxa orderbook get      # L2 orderbook snapshot
oxa trades fetch       # Trade history with cursor pagination
oxa candles            # OHLCV candle data (1m to 1w intervals)
oxa funding current    # Current funding rate
oxa funding history    # Funding rate history
oxa oi current         # Current open interest
oxa oi history         # Open interest history
oxa instruments        # List available instruments/coins
oxa liquidations       # Liquidation history (Hyperliquid only)
oxa summary            # Multi-signal snapshot in one call
oxa prices             # Mark/oracle/mid price history
oxa freshness          # Data freshness per data type
```

### Why a CLI?

Because your trading bot shouldn't need an HTTP client to check funding rates. Your AI agent shouldn't parse HTML to get orderbook state. Your backtest pipeline shouldn't import a library just to pull candles.

The CLI speaks JSON natively. Pipe it into `jq`, feed it to an LLM, or wire it into a shell script:

```
# Extract BTC mid price
oxa summary --exchange hyperliquid --symbol BTC | jq '.markPrice'

# Gate on data freshness before a trade
oxa freshness --exchange hyperliquid --symbol BTC \
  | jq '.orderbook.lagMs < 5000'

# Scan all symbols
oxa instruments --exchange hyperliquid | jq '.[].name'

# Fetch candles and write to file
oxa candles --exchange hyperliquid --symbol ETH \
  --start 2026-01-01T00:00:00Z --end 2026-02-01T00:00:00Z \
  --interval 4h --out candles.json
```

Exit codes are deterministic: `0` success, `2` validation error, `3` auth error, `4` network/API error, `5` internal error. Agents can branch on them without parsing output.

## The Rust SDK

The `oxarchive` crate is available on crates.io. Async by default, full type safety, and optional WebSocket support.

### Install

Add to your `Cargo.toml`:

```
[dependencies]
oxarchive = "1.3"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
```

### Quick Start

```
use oxarchive::OxArchive;

#[tokio::main]
async fn main() -> oxarchive::Result<()> {
    let client = OxArchive::new("0xa_your_api_key")?;

    // Hyperliquid orderbook
    let ob = client.hyperliquid.orderbook.get("BTC", None).await?;
    println!("Hyperliquid BTC mid price: {:?}", ob.mid_price);

    // Lighter.xyz orderbook
    let lighter_ob = client.lighter.orderbook.get("BTC", None).await?;
    println!("Lighter BTC mid price: {:?}", lighter_ob.mid_price);

    // HIP-3 builder perps (Pro tier required)
    let hip3_ob = client.hyperliquid.hip3.orderbook.get("xyz:XYZ100", None).await?;
    println!("HIP-3 XYZ100 mid price: {:?}", hip3_ob.mid_price);

    Ok(())
}
```

### Trades with Cursor Pagination

```
use oxarchive::{OxArchive, resources::trades::GetTradesParams};

#[tokio::main]
async fn main() -> oxarchive::Result<()> {
    let client = OxArchive::new("0xa_your_api_key")?;

    let mut result = client.hyperliquid.trades.list("ETH", GetTradesParams {
        start: 1767225600000_i64.into(),  // 2026-01-01
        end: 1767312000000_i64.into(),    // 2026-01-02
        limit: Some(1000),
        cursor: None,
        side: None,
    }).await?;
    let mut trades = result.data;

    while let Some(cursor) = result.next_cursor {
        result = client.hyperliquid.trades.list("ETH", GetTradesParams {
            start: 1767225600000_i64.into(),
            end: 1767312000000_i64.into(),
            cursor: Some(cursor),
            limit: Some(1000),
            side: None,
        }).await?;
        trades.extend(result.data);
    }

    println!("Fetched {} trades", trades.len());
    Ok(())
}
```

### WebSocket Historical Replay

Enable with the `websocket` feature flag:

```
oxarchive = { version = "1.3", features = ["websocket"] }
```

```
// Replay orderbook data at 10x speed
ws.replay("orderbook", "BTC", 1767225600000, None, Some(10.0)).await?;

// Messages arrive through the same rx channel
while let Some(msg) = rx.recv().await {
    match msg {
        ServerMsg::HistoricalData { channel, coin, timestamp, data } => {
            println!("[{timestamp}] {channel} {coin:?}: {data}");
        }
        ServerMsg::ReplayCompleted { .. } => break,
        _ => {}
    }
}
```

## Full SDK Lineup

This brings us to four official interfaces:

- **CLI** - `npm i -g @0xarchive/cli` - JSON stdout, deterministic exit codes
- **Rust** - `cargo add oxarchive` - async (tokio), WebSocket via feature flag, native types
- **Python** - `pip install oxarchive` - sync + async, WebSocket via optional extra, Pydantic models
- **TypeScript** - `npm i @0xarchive/sdk` - async/await, WebSocket built-in, full TypeScript types

Same data. Same API. Pick your language.

## What's Behind the API

- **Hyperliquid:** 22.9B orderbook snapshots, 2.2B fills, 213M funding rates, 210M OI records - continuous coverage from April 2023
- **Hyperliquid HIP-3:** 29M orderbook snapshots, 12M fills, 1.5M OI/funding records - builder perps from February 2026
- **Lighter.xyz:** 11.7B orderbook deltas, 1B+ fills, 3B+ OI records, 3B+ funding rates - checkpoint history from January 29, 2026, 30s/10s/1s from January 30, 2026, and Enterprise tick reconstruction

All live-ingested with sub-second freshness on orderbooks. Hyperliquid fills backfilled hourly.

## Get Started

1. [Sign up](https://www.0xarchive.io/signup/) for a free account
2. Generate an API key from the [dashboard](https://www.0xarchive.io/dashboard/)
3. Pick your tool:

```
# CLI - first data in 30 seconds
npm i -g @0xarchive/cli
export OXA_API_KEY="0xa_your_api_key"
oxa summary --exchange hyperliquid --symbol BTC

# Rust
cargo add oxarchive tokio

# Python
pip install oxarchive

# TypeScript
npm i @0xarchive/sdk
```

[Read the docs](https://www.0xarchive.io/docs/) to dive deeper.
