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