0xArchive API Skill
Query historical and real-time crypto market data from 0xArchive using curl. Three exchanges are supported: Hyperliquid (perps DEX), Lighter.xyz (order-book DEX), and HIP-3 (Hyperliquid builder perps). Data types: orderbooks, trades, candles, funding rates, open interest, liquidations, and data quality metrics.
Authentication
All endpoints require the x-api-key header. The key is read from $OXARCHIVE_API_KEY.
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" "https://api.0xarchive.io/v1/..."
Exchanges & Coin Naming
| Exchange |
Path prefix |
Coin format |
Examples |
| Hyperliquid |
/v1/hyperliquid |
UPPERCASE |
BTC, ETH, SOL |
| HIP-3 |
/v1/hyperliquid/hip3 |
Case-sensitive, prefix:NAME |
km:US500, xyz:XYZ100 |
| Lighter |
/v1/lighter |
UPPERCASE |
BTC, ETH |
Hyperliquid and Lighter auto-uppercase the symbol server-side. HIP-3 coin names are passed through as-is.
Timestamps
All timestamps are Unix milliseconds. Use these shell helpers:
NOW=$(( $(date +%s) * 1000 ))
HOUR_AGO=$(( NOW - 3600000 ))
DAY_AGO=$(( NOW - 86400000 ))
WEEK_AGO=$(( NOW - 604800000 ))
Response Format
Every response follows this shape:
{
"success": true,
"data": [ ... ],
"meta": {
"count": 100,
"request_id": "uuid",
"next_cursor": "1706000000000" // present when more pages exist
}
}
Endpoint Reference
Hyperliquid (/v1/hyperliquid)
| Endpoint |
Params |
Notes |
GET /instruments |
-- |
List all instruments |
GET /instruments/{symbol} |
-- |
Single instrument details |
GET /orderbook/{symbol} |
timestamp, depth |
Latest or at timestamp |
GET /orderbook/{symbol}/history |
start, end, limit, cursor, depth |
Historical snapshots |
GET /trades/{symbol} |
start, end, limit, cursor |
Trade history |
GET /candles/{symbol} |
start, end, limit, cursor, interval |
OHLCV candles |
GET /funding/{symbol}/current |
-- |
Current funding rate |
GET /funding/{symbol} |
start, end, limit, cursor, interval |
Funding rate history |
GET /openinterest/{symbol}/current |
-- |
Current open interest |
GET /openinterest/{symbol} |
start, end, limit, cursor, interval |
OI history |
GET /liquidations/{symbol} |
start, end, limit, cursor |
Liquidation events |
GET /liquidations/{symbol}/volume |
start, end, limit, cursor, interval |
Aggregated liquidation volume (USD) |
GET /liquidations/user/{address} |
start, end, limit, cursor, coin |
Liquidations for a user |
GET /freshness/{symbol} |
-- |
Data freshness per data type |
GET /summary/{symbol} |
-- |
Combined market summary (price, funding, OI, volume, liquidations) |
GET /prices/{symbol} |
start, end, limit, cursor, interval |
Mark/oracle/mid price history |
HIP-3 (/v1/hyperliquid/hip3)
Coin names are case-sensitive (e.g., km:US500). No liquidation endpoints. Orderbook requires Pro+ tier.
| Endpoint |
Params |
Notes |
GET /instruments |
-- |
List HIP-3 instruments |
GET /instruments/{coin} |
-- |
Single instrument |
GET /orderbook/{coin} |
timestamp, depth |
Requires Pro+ tier |
GET /orderbook/{coin}/history |
start, end, limit, cursor, depth |
Requires Pro+ tier |
GET /trades/{coin} |
start, end, limit, cursor |
Trade history |
GET /trades/{coin}/recent |
limit |
Recent trades (no time range needed) |
GET /candles/{coin} |
start, end, limit, cursor, interval |
OHLCV candles |
GET /funding/{coin}/current |
-- |
Current funding rate |
GET /funding/{coin} |
start, end, limit, cursor, interval |
Funding history |
GET /openinterest/{coin}/current |
-- |
Current OI |
GET /openinterest/{coin} |
start, end, limit, cursor, interval |
OI history |
GET /freshness/{coin} |
-- |
Data freshness per data type |
GET /summary/{coin} |
-- |
Combined market summary (price, funding, OI) |
GET /prices/{coin} |
start, end, limit, cursor, interval |
Mark/oracle/mid price history |
Lighter (/v1/lighter)
Same data types as Hyperliquid except: no liquidations. Adds granularity on orderbook history and /recent trades.
| Endpoint |
Params |
Notes |
GET /instruments |
-- |
List Lighter instruments |
GET /instruments/{symbol} |
-- |
Single instrument |
GET /orderbook/{symbol} |
timestamp, depth |
Latest or at timestamp |
GET /orderbook/{symbol}/history |
start, end, limit, cursor, depth, granularity |
Default granularity: checkpoint |
GET /trades/{symbol} |
start, end, limit, cursor |
Trade history |
GET /trades/{symbol}/recent |
limit |
Recent trades (no time range needed) |
GET /candles/{symbol} |
start, end, limit, cursor, interval |
OHLCV candles |
GET /funding/{symbol}/current |
-- |
Current funding rate |
GET /funding/{symbol} |
start, end, limit, cursor, interval |
Funding history |
GET /openinterest/{symbol}/current |
-- |
Current OI |
GET /openinterest/{symbol} |
start, end, limit, cursor, interval |
OI history |
GET /freshness/{symbol} |
-- |
Data freshness per data type |
GET /summary/{symbol} |
-- |
Combined market summary (price, funding, OI) |
GET /prices/{symbol} |
start, end, limit, cursor, interval |
Mark/oracle price history |
Data Quality (/v1/data-quality)
| Endpoint |
Params |
Notes |
GET /status |
-- |
System health status |
GET /coverage |
-- |
Coverage summary, all exchanges |
GET /coverage/{exchange} |
-- |
Coverage for one exchange |
GET /coverage/{exchange}/{symbol} |
from, to |
Symbol-level coverage + gaps |
GET /incidents |
status, exchange, since, limit, offset |
List incidents |
GET /incidents/{id} |
-- |
Single incident |
GET /latency |
-- |
Ingestion latency metrics |
GET /sla |
year, month |
SLA compliance report |
Web3 Authentication (/v1)
Get API keys programmatically using an Ethereum wallet (SIWE). No API key required for these endpoints.
| Endpoint |
Params |
Notes |
POST /auth/web3/challenge |
address (wallet address) |
Returns SIWE message to sign |
POST /web3/signup |
message, signature |
Returns free-tier API key |
POST /web3/keys |
message, signature |
List all keys for wallet |
POST /web3/keys/revoke |
message, signature, key_id |
Revoke a key |
POST /web3/subscribe |
tier (build or pro), payment-signature header |
x402 USDC subscription (see flow below) |
Free-tier flow: Call /auth/web3/challenge with wallet address → sign the returned message with personal_sign (EIP-191) → submit to /web3/signup with the message and signature → receive API key.
Paid-tier flow (x402):
POST /web3/subscribe with { "tier": "build" } → server returns 402 with payment.amount (micro-USDC), payment.pay_to (treasury address), payment.network.
- Sign an EIP-712
TransferWithAuthorization (EIP-3009) on USDC Base:
- Domain:
{ name: "USD Coin", version: "2", chainId: 8453, verifyingContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" }
- Type:
TransferWithAuthorization(address from, address to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 nonce)
- Message:
{ from: <wallet>, to: <pay_to>, value: <amount>, validAfter: 0, validBefore: <now+3600>, nonce: <32 random bytes hex> }
- Build x402 v2 payment payload:
{
"x402Version": 2,
"payload": {
"signature": "0x<EIP-712 signature hex>",
"authorization": {
"from": "0x<wallet>",
"to": "0x<pay_to from step 1>",
"value": "<amount as string>",
"validAfter": "0",
"validBefore": "<unix timestamp as string>",
"nonce": "0x<64 hex chars>"
}
}
}
- Base64-encode the JSON and retry:
POST /web3/subscribe with { "tier": "build" } and header payment-signature: <base64 payload> → receive API key + subscription.
Important: All authorization values (value, validAfter, validBefore) must be strings, not numbers. See scripts/web3_subscribe.py for a complete working Python implementation.
Common Parameters
| Param |
Type |
Description |
start |
int |
Start timestamp (Unix ms). Defaults to 24h ago. |
end |
int |
End timestamp (Unix ms). Defaults to now. |
limit |
int |
Max records. Default 100, max 1000 (max 10000 for candles). |
cursor |
string |
Pagination cursor from meta.next_cursor. |
interval |
string |
Candle interval: 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w. Default: 1h. For OI/funding: 5m, 15m, 30m, 1h, 4h, 1d. Omit for raw data. |
depth |
int |
Orderbook depth (number of price levels per side). |
granularity |
string |
Lighter orderbook resolution: checkpoint (default), 30s, 10s, 1s, tick. |
Smart Defaults
When the user does not specify a time range, default to the last 24 hours:
NOW=$(( $(date +%s) * 1000 ))
DAY_AGO=$(( NOW - 86400000 ))
For candles with no explicit range, default to a range that makes sense for the interval (e.g., last 7 days for 4h candles, last 30 days for 1d candles).
Pagination
When meta.next_cursor is present in the response, more data is available. Append &cursor=VALUE to fetch the next page:
# First page
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/trades/BTC?start=$START&end=$END&limit=1000"
# Next page (use next_cursor from previous response)
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/trades/BTC?start=$START&end=$END&limit=1000&cursor=1706000000000_12345"
Tier Limits
| Tier |
Price |
Coins |
Orderbook Depth |
Lighter Granularity |
Historical Depth |
Rate Limit |
| Free |
$0 |
BTC only (HIP-3: km:US500 only) |
20 levels |
-- |
30 days |
15 RPS |
| Build |
$49/mo |
All |
50 levels |
checkpoint, 30s, 10s |
1 year |
50 RPS |
| Pro |
$199/mo |
All |
100 levels |
+ 1s |
Full history |
150 RPS |
| Enterprise |
Custom |
All |
Full depth |
+ tick |
Full history |
Custom |
Error Handling
| HTTP Status |
Meaning |
Action |
| 400 |
Bad request / validation error |
Check params (missing start/end, invalid interval) |
| 401 |
Missing or invalid API key |
Set $OXARCHIVE_API_KEY |
| 403 |
Tier restriction |
Upgrade plan (e.g., non-BTC coin on Free tier) |
| 404 |
Symbol not found |
Check coin name spelling and exchange |
| 429 |
Rate limited |
Back off and retry |
Error responses return { "code": 400, "error": "description" }.
Example Queries
# List Hyperliquid instruments
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/instruments" | jq '.data | length'
# Current BTC orderbook (top 10 levels)
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/orderbook/BTC?depth=10" | jq '.data'
# ETH trades from the last hour
NOW=$(( $(date +%s) * 1000 )); HOUR_AGO=$(( NOW - 3600000 ))
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/trades/ETH?start=$HOUR_AGO&end=$NOW&limit=100" | jq '.data'
# SOL 4h candles for the last week
NOW=$(( $(date +%s) * 1000 )); WEEK_AGO=$(( NOW - 604800000 ))
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/candles/SOL?start=$WEEK_AGO&end=$NOW&interval=4h" | jq '.data'
# Current BTC funding rate
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/funding/BTC/current" | jq '.data'
# BTC open interest aggregated to 1h intervals (last week)
NOW=$(( $(date +%s) * 1000 )); WEEK_AGO=$(( NOW - 604800000 ))
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/openinterest/BTC?start=$WEEK_AGO&end=$NOW&interval=1h" | jq '.data'
# ETH funding rates aggregated to 4h intervals (last 30 days)
NOW=$(( $(date +%s) * 1000 )); MONTH_AGO=$(( NOW - 2592000000 ))
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/funding/ETH?start=$MONTH_AGO&end=$NOW&interval=4h" | jq '.data'
# HIP-3 km:US500 candles (last 24h, 1h interval)
NOW=$(( $(date +%s) * 1000 )); DAY_AGO=$(( NOW - 86400000 ))
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/hip3/candles/km:US500?start=$DAY_AGO&end=$NOW&interval=1h" | jq '.data'
# Lighter BTC orderbook history (30s granularity, last hour)
NOW=$(( $(date +%s) * 1000 )); HOUR_AGO=$(( NOW - 3600000 ))
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/lighter/orderbook/BTC/history?start=$HOUR_AGO&end=$NOW&granularity=30s&limit=100" | jq '.data'
# System health status
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/data-quality/status" | jq '.'
# SLA report for current month
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/data-quality/sla" | jq '.'
# BTC market summary (price, funding, OI, volume, liquidations in one call)
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/summary/BTC" | jq '.data'
# BTC data freshness (lag per data type)
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/freshness/BTC" | jq '.data'
# BTC price history (mark/oracle/mid) aggregated to 1h
NOW=$(( $(date +%s) * 1000 )); DAY_AGO=$(( NOW - 86400000 ))
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/prices/BTC?start=$DAY_AGO&end=$NOW&interval=1h" | jq '.data'
# BTC liquidation volume aggregated to 4h buckets
NOW=$(( $(date +%s) * 1000 )); WEEK_AGO=$(( NOW - 604800000 ))
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/hyperliquid/liquidations/BTC/volume?start=$WEEK_AGO&end=$NOW&interval=4h" | jq '.data'
# Data coverage for Hyperliquid BTC
curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
"https://api.0xarchive.io/v1/data-quality/coverage/hyperliquid/BTC" | jq '.'
1---
2name: 0xarchive
3version: 1.3.0
4description: >
5 Query historical crypto market data from 0xArchive across Hyperliquid, Lighter.xyz, and HIP-3.
6 Covers orderbooks, trades, candles, funding rates, open interest, liquidations, and data quality.
7 Use when the user asks about crypto market data, orderbooks, trades, funding rates, or historical prices on Hyperliquid, Lighter.xyz, or HIP-3.
8allowed-tools: Bash
9argument-hint: "query, e.g. 'BTC funding rate' or 'ETH 4h candles last week'"
10metadata:
11 source: https://skillmd.com/skills/modbender/0xarchive
12 openclaw:
13 requires:
14 env:
15 - OXARCHIVE_API_KEY
16 primaryEnv: OXARCHIVE_API_KEY
17---
18
19# 0xArchive API Skill
20
21Query historical and real-time crypto market data from **0xArchive** using `curl`. Three exchanges are supported: **Hyperliquid** (perps DEX), **Lighter.xyz** (order-book DEX), and **HIP-3** (Hyperliquid builder perps). Data types: orderbooks, trades, candles, funding rates, open interest, liquidations, and data quality metrics.
22
23## Authentication
24
25All endpoints require the `x-api-key` header. The key is read from `$OXARCHIVE_API_KEY`.
26
27```bash
28curl -s -H "x-api-key: $OXARCHIVE_API_KEY" "https://api.0xarchive.io/v1/..."
29```
30
31## Exchanges & Coin Naming
32
33| Exchange | Path prefix | Coin format | Examples |
34|----------|-------------|-------------|---------|
35| Hyperliquid | `/v1/hyperliquid` | UPPERCASE | `BTC`, `ETH`, `SOL` |
36| HIP-3 | `/v1/hyperliquid/hip3` | Case-sensitive, `prefix:NAME` | `km:US500`, `xyz:XYZ100` |
37| Lighter | `/v1/lighter` | UPPERCASE | `BTC`, `ETH` |
38
39Hyperliquid and Lighter auto-uppercase the symbol server-side. HIP-3 coin names are passed through as-is.
40
41## Timestamps
42
43All timestamps are **Unix milliseconds**. Use these shell helpers:
44
45```bash
46NOW=$(( $(date +%s) * 1000 ))
47HOUR_AGO=$(( NOW - 3600000 ))
48DAY_AGO=$(( NOW - 86400000 ))
49WEEK_AGO=$(( NOW - 604800000 ))
50```
51
52## Response Format
53
54Every response follows this shape:
55
56```json
57{
58 "success": true,
59 "data": [ ... ],
60 "meta": {
61 "count": 100,
62 "request_id": "uuid",
63 "next_cursor": "1706000000000" // present when more pages exist
64 }
65}
66```
67
68## Endpoint Reference
69
70### Hyperliquid (`/v1/hyperliquid`)
71
72| Endpoint | Params | Notes |
73|----------|--------|-------|
74| `GET /instruments` | -- | List all instruments |
75| `GET /instruments/{symbol}` | -- | Single instrument details |
76| `GET /orderbook/{symbol}` | `timestamp`, `depth` | Latest or at timestamp |
77| `GET /orderbook/{symbol}/history` | `start`, `end`, `limit`, `cursor`, `depth` | Historical snapshots |
78| `GET /trades/{symbol}` | `start`, `end`, `limit`, `cursor` | Trade history |
79| `GET /candles/{symbol}` | `start`, `end`, `limit`, `cursor`, `interval` | OHLCV candles |
80| `GET /funding/{symbol}/current` | -- | Current funding rate |
81| `GET /funding/{symbol}` | `start`, `end`, `limit`, `cursor`, `interval` | Funding rate history |
82| `GET /openinterest/{symbol}/current` | -- | Current open interest |
83| `GET /openinterest/{symbol}` | `start`, `end`, `limit`, `cursor`, `interval` | OI history |
84| `GET /liquidations/{symbol}` | `start`, `end`, `limit`, `cursor` | Liquidation events |
85| `GET /liquidations/{symbol}/volume` | `start`, `end`, `limit`, `cursor`, `interval` | Aggregated liquidation volume (USD) |
86| `GET /liquidations/user/{address}` | `start`, `end`, `limit`, `cursor`, `coin` | Liquidations for a user |
87| `GET /freshness/{symbol}` | -- | Data freshness per data type |
88| `GET /summary/{symbol}` | -- | Combined market summary (price, funding, OI, volume, liquidations) |
89| `GET /prices/{symbol}` | `start`, `end`, `limit`, `cursor`, `interval` | Mark/oracle/mid price history |
90
91### HIP-3 (`/v1/hyperliquid/hip3`)
92
93Coin names are **case-sensitive** (e.g., `km:US500`). No liquidation endpoints. Orderbook requires Pro+ tier.
94
95| Endpoint | Params | Notes |
96|----------|--------|-------|
97| `GET /instruments` | -- | List HIP-3 instruments |
98| `GET /instruments/{coin}` | -- | Single instrument |
99| `GET /orderbook/{coin}` | `timestamp`, `depth` | Requires Pro+ tier |
100| `GET /orderbook/{coin}/history` | `start`, `end`, `limit`, `cursor`, `depth` | Requires Pro+ tier |
101| `GET /trades/{coin}` | `start`, `end`, `limit`, `cursor` | Trade history |
102| `GET /trades/{coin}/recent` | `limit` | Recent trades (no time range needed) |
103| `GET /candles/{coin}` | `start`, `end`, `limit`, `cursor`, `interval` | OHLCV candles |
104| `GET /funding/{coin}/current` | -- | Current funding rate |
105| `GET /funding/{coin}` | `start`, `end`, `limit`, `cursor`, `interval` | Funding history |
106| `GET /openinterest/{coin}/current` | -- | Current OI |
107| `GET /openinterest/{coin}` | `start`, `end`, `limit`, `cursor`, `interval` | OI history |
108| `GET /freshness/{coin}` | -- | Data freshness per data type |
109| `GET /summary/{coin}` | -- | Combined market summary (price, funding, OI) |
110| `GET /prices/{coin}` | `start`, `end`, `limit`, `cursor`, `interval` | Mark/oracle/mid price history |
111
112### Lighter (`/v1/lighter`)
113
114Same data types as Hyperliquid except: no liquidations. Adds `granularity` on orderbook history and `/recent` trades.
115
116| Endpoint | Params | Notes |
117|----------|--------|-------|
118| `GET /instruments` | -- | List Lighter instruments |
119| `GET /instruments/{symbol}` | -- | Single instrument |
120| `GET /orderbook/{symbol}` | `timestamp`, `depth` | Latest or at timestamp |
121| `GET /orderbook/{symbol}/history` | `start`, `end`, `limit`, `cursor`, `depth`, `granularity` | Default granularity: `checkpoint` |
122| `GET /trades/{symbol}` | `start`, `end`, `limit`, `cursor` | Trade history |
123| `GET /trades/{symbol}/recent` | `limit` | Recent trades (no time range needed) |
124| `GET /candles/{symbol}` | `start`, `end`, `limit`, `cursor`, `interval` | OHLCV candles |
125| `GET /funding/{symbol}/current` | -- | Current funding rate |
126| `GET /funding/{symbol}` | `start`, `end`, `limit`, `cursor`, `interval` | Funding history |
127| `GET /openinterest/{symbol}/current` | -- | Current OI |
128| `GET /openinterest/{symbol}` | `start`, `end`, `limit`, `cursor`, `interval` | OI history |
129| `GET /freshness/{symbol}` | -- | Data freshness per data type |
130| `GET /summary/{symbol}` | -- | Combined market summary (price, funding, OI) |
131| `GET /prices/{symbol}` | `start`, `end`, `limit`, `cursor`, `interval` | Mark/oracle price history |
132
133### Data Quality (`/v1/data-quality`)
134
135| Endpoint | Params | Notes |
136|----------|--------|-------|
137| `GET /status` | -- | System health status |
138| `GET /coverage` | -- | Coverage summary, all exchanges |
139| `GET /coverage/{exchange}` | -- | Coverage for one exchange |
140| `GET /coverage/{exchange}/{symbol}` | `from`, `to` | Symbol-level coverage + gaps |
141| `GET /incidents` | `status`, `exchange`, `since`, `limit`, `offset` | List incidents |
142| `GET /incidents/{id}` | -- | Single incident |
143| `GET /latency` | -- | Ingestion latency metrics |
144| `GET /sla` | `year`, `month` | SLA compliance report |
145
146### Web3 Authentication (`/v1`)
147
148Get API keys programmatically using an Ethereum wallet (SIWE). No API key required for these endpoints.
149
150| Endpoint | Params | Notes |
151|----------|--------|-------|
152| `POST /auth/web3/challenge` | `address` (wallet address) | Returns SIWE message to sign |
153| `POST /web3/signup` | `message`, `signature` | Returns free-tier API key |
154| `POST /web3/keys` | `message`, `signature` | List all keys for wallet |
155| `POST /web3/keys/revoke` | `message`, `signature`, `key_id` | Revoke a key |
156| `POST /web3/subscribe` | `tier` (`build` or `pro`), `payment-signature` header | x402 USDC subscription (see flow below) |
157
158**Free-tier flow:** Call `/auth/web3/challenge` with wallet address → sign the returned message with `personal_sign` (EIP-191) → submit to `/web3/signup` with the message and signature → receive API key.
159
160**Paid-tier flow (x402):**
161
1621. `POST /web3/subscribe` with `{ "tier": "build" }` → server returns 402 with `payment.amount` (micro-USDC), `payment.pay_to` (treasury address), `payment.network`.
1632. Sign an EIP-712 `TransferWithAuthorization` (EIP-3009) on USDC Base:
164 - Domain: `{ name: "USD Coin", version: "2", chainId: 8453, verifyingContract: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" }`
165 - Type: `TransferWithAuthorization(address from, address to, uint256 value, uint256 validAfter, uint256 validBefore, bytes32 nonce)`
166 - Message: `{ from: <wallet>, to: <pay_to>, value: <amount>, validAfter: 0, validBefore: <now+3600>, nonce: <32 random bytes hex> }`
1673. Build x402 v2 payment payload:
168 ```json
169 {
170 "x402Version": 2,
171 "payload": {
172 "signature": "0x<EIP-712 signature hex>",
173 "authorization": {
174 "from": "0x<wallet>",
175 "to": "0x<pay_to from step 1>",
176 "value": "<amount as string>",
177 "validAfter": "0",
178 "validBefore": "<unix timestamp as string>",
179 "nonce": "0x<64 hex chars>"
180 }
181 }
182 }
183 ```
1844. Base64-encode the JSON and retry: `POST /web3/subscribe` with `{ "tier": "build" }` and header `payment-signature: <base64 payload>` → receive API key + subscription.
185
186**Important:** All `authorization` values (`value`, `validAfter`, `validBefore`) must be strings, not numbers. See `scripts/web3_subscribe.py` for a complete working Python implementation.
187
188## Common Parameters
189
190| Param | Type | Description |
191|-------|------|-------------|
192| `start` | int | Start timestamp (Unix ms). Defaults to 24h ago. |
193| `end` | int | End timestamp (Unix ms). Defaults to now. |
194| `limit` | int | Max records. Default 100, max 1000 (max 10000 for candles). |
195| `cursor` | string | Pagination cursor from `meta.next_cursor`. |
196| `interval` | string | Candle interval: `1m`, `5m`, `15m`, `30m`, `1h`, `4h`, `1d`, `1w`. Default: `1h`. For OI/funding: `5m`, `15m`, `30m`, `1h`, `4h`, `1d`. Omit for raw data. |
197| `depth` | int | Orderbook depth (number of price levels per side). |
198| `granularity` | string | Lighter orderbook resolution: `checkpoint` (default), `30s`, `10s`, `1s`, `tick`. |
199
200## Smart Defaults
201
202When the user does not specify a time range, default to the **last 24 hours**:
203
204```bash
205NOW=$(( $(date +%s) * 1000 ))
206DAY_AGO=$(( NOW - 86400000 ))
207```
208
209For candles with no explicit range, default to a range that makes sense for the interval (e.g., last 7 days for 4h candles, last 30 days for 1d candles).
210
211## Pagination
212
213When `meta.next_cursor` is present in the response, more data is available. Append `&cursor=VALUE` to fetch the next page:
214
215```bash
216# First page
217curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
218 "https://api.0xarchive.io/v1/hyperliquid/trades/BTC?start=$START&end=$END&limit=1000"
219
220# Next page (use next_cursor from previous response)
221curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
222 "https://api.0xarchive.io/v1/hyperliquid/trades/BTC?start=$START&end=$END&limit=1000&cursor=1706000000000_12345"
223```
224
225## Tier Limits
226
227| Tier | Price | Coins | Orderbook Depth | Lighter Granularity | Historical Depth | Rate Limit |
228|------|-------|-------|-----------------|---------------------|------------------|------------|
229| Free | $0 | BTC only (HIP-3: km:US500 only) | 20 levels | -- | 30 days | 15 RPS |
230| Build | $49/mo | All | 50 levels | checkpoint, 30s, 10s | 1 year | 50 RPS |
231| Pro | $199/mo | All | 100 levels | + 1s | Full history | 150 RPS |
232| Enterprise | Custom | All | Full depth | + tick | Full history | Custom |
233
234## Error Handling
235
236| HTTP Status | Meaning | Action |
237|-------------|---------|--------|
238| 400 | Bad request / validation error | Check params (missing start/end, invalid interval) |
239| 401 | Missing or invalid API key | Set `$OXARCHIVE_API_KEY` |
240| 403 | Tier restriction | Upgrade plan (e.g., non-BTC coin on Free tier) |
241| 404 | Symbol not found | Check coin name spelling and exchange |
242| 429 | Rate limited | Back off and retry |
243
244Error responses return `{ "code": 400, "error": "description" }`.
245
246## Example Queries
247
248```bash
249# List Hyperliquid instruments
250curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
251 "https://api.0xarchive.io/v1/hyperliquid/instruments" | jq '.data | length'
252
253# Current BTC orderbook (top 10 levels)
254curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
255 "https://api.0xarchive.io/v1/hyperliquid/orderbook/BTC?depth=10" | jq '.data'
256
257# ETH trades from the last hour
258NOW=$(( $(date +%s) * 1000 )); HOUR_AGO=$(( NOW - 3600000 ))
259curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
260 "https://api.0xarchive.io/v1/hyperliquid/trades/ETH?start=$HOUR_AGO&end=$NOW&limit=100" | jq '.data'
261
262# SOL 4h candles for the last week
263NOW=$(( $(date +%s) * 1000 )); WEEK_AGO=$(( NOW - 604800000 ))
264curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
265 "https://api.0xarchive.io/v1/hyperliquid/candles/SOL?start=$WEEK_AGO&end=$NOW&interval=4h" | jq '.data'
266
267# Current BTC funding rate
268curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
269 "https://api.0xarchive.io/v1/hyperliquid/funding/BTC/current" | jq '.data'
270
271# BTC open interest aggregated to 1h intervals (last week)
272NOW=$(( $(date +%s) * 1000 )); WEEK_AGO=$(( NOW - 604800000 ))
273curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
274 "https://api.0xarchive.io/v1/hyperliquid/openinterest/BTC?start=$WEEK_AGO&end=$NOW&interval=1h" | jq '.data'
275
276# ETH funding rates aggregated to 4h intervals (last 30 days)
277NOW=$(( $(date +%s) * 1000 )); MONTH_AGO=$(( NOW - 2592000000 ))
278curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
279 "https://api.0xarchive.io/v1/hyperliquid/funding/ETH?start=$MONTH_AGO&end=$NOW&interval=4h" | jq '.data'
280
281# HIP-3 km:US500 candles (last 24h, 1h interval)
282NOW=$(( $(date +%s) * 1000 )); DAY_AGO=$(( NOW - 86400000 ))
283curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
284 "https://api.0xarchive.io/v1/hyperliquid/hip3/candles/km:US500?start=$DAY_AGO&end=$NOW&interval=1h" | jq '.data'
285
286# Lighter BTC orderbook history (30s granularity, last hour)
287NOW=$(( $(date +%s) * 1000 )); HOUR_AGO=$(( NOW - 3600000 ))
288curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
289 "https://api.0xarchive.io/v1/lighter/orderbook/BTC/history?start=$HOUR_AGO&end=$NOW&granularity=30s&limit=100" | jq '.data'
290
291# System health status
292curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
293 "https://api.0xarchive.io/v1/data-quality/status" | jq '.'
294
295# SLA report for current month
296curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
297 "https://api.0xarchive.io/v1/data-quality/sla" | jq '.'
298
299# BTC market summary (price, funding, OI, volume, liquidations in one call)
300curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
301 "https://api.0xarchive.io/v1/hyperliquid/summary/BTC" | jq '.data'
302
303# BTC data freshness (lag per data type)
304curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
305 "https://api.0xarchive.io/v1/hyperliquid/freshness/BTC" | jq '.data'
306
307# BTC price history (mark/oracle/mid) aggregated to 1h
308NOW=$(( $(date +%s) * 1000 )); DAY_AGO=$(( NOW - 86400000 ))
309curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
310 "https://api.0xarchive.io/v1/hyperliquid/prices/BTC?start=$DAY_AGO&end=$NOW&interval=1h" | jq '.data'
311
312# BTC liquidation volume aggregated to 4h buckets
313NOW=$(( $(date +%s) * 1000 )); WEEK_AGO=$(( NOW - 604800000 ))
314curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
315 "https://api.0xarchive.io/v1/hyperliquid/liquidations/BTC/volume?start=$WEEK_AGO&end=$NOW&interval=4h" | jq '.data'
316
317# Data coverage for Hyperliquid BTC
318curl -s -H "x-api-key: $OXARCHIVE_API_KEY" \
319 "https://api.0xarchive.io/v1/data-quality/coverage/hyperliquid/BTC" | jq '.'
320```
321