@0xarchive/sdk 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -1
- package/dist/index.d.mts +294 -78
- package/dist/index.d.ts +294 -78
- package/dist/index.js +124 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
TypeScript client for 0xArchive market data in Node services, dashboards, coding-agent workflows, and agent backends.
|
|
4
4
|
|
|
5
|
-
0xArchive is granular market data infrastructure for Hyperliquid and Lighter.xyz. HIP-3 builder perps live under the Hyperliquid namespace at `/v1/hyperliquid/hip3` and `client.hyperliquid.hip3`. HIP-4 binary outcome markets live at `/v1/hyperliquid/hip4` and `client.hyperliquid.hip4`.
|
|
5
|
+
0xArchive is granular market data infrastructure for Hyperliquid and Lighter.xyz. HIP-3 builder perps live under the Hyperliquid namespace at `/v1/hyperliquid/hip3` and `client.hyperliquid.hip3`. HIP-4 binary outcome markets live at `/v1/hyperliquid/hip4` and `client.hyperliquid.hip4`. Hyperliquid Spot lives at `/v1/hyperliquid/spot` and `client.spot`.
|
|
6
6
|
|
|
7
7
|
Use this SDK when the integration belongs in TypeScript or JavaScript code and you want typed REST helpers, WebSocket support, replay workflows, and order-book reconstruction utilities.
|
|
8
8
|
|
|
@@ -38,6 +38,11 @@ const hip3Trades = await client.hyperliquid.hip3.trades.recent('km:US500');
|
|
|
38
38
|
const hip3Funding = await client.hyperliquid.hip3.funding.current('xyz:XYZ100');
|
|
39
39
|
const hip3Oi = await client.hyperliquid.hip3.openInterest.current('xyz:XYZ100');
|
|
40
40
|
|
|
41
|
+
// Hyperliquid Spot lives at client.spot. Symbols are dashed canonical (HYPE-USDC).
|
|
42
|
+
const spotPairs = await client.spot.pairs.list();
|
|
43
|
+
const spotOrderbook = await client.spot.orderbook.get('HYPE-USDC');
|
|
44
|
+
const spotTrades = await client.spot.trades.recent('HYPE-USDC');
|
|
45
|
+
|
|
41
46
|
// Get historical order book snapshots
|
|
42
47
|
const history = await client.hyperliquid.orderbook.history('ETH', {
|
|
43
48
|
start: Date.now() - 86400000, // 24 hours ago
|
|
@@ -63,6 +68,8 @@ const history = await client.hyperliquid.orderbook.history('ETH', {
|
|
|
63
68
|
| --- | --- | --- |
|
|
64
69
|
| Hyperliquid | April 2023+ | Perpetuals across the full venue |
|
|
65
70
|
| Hyperliquid HIP-3 | February 2026+ | Free tier: `km:US500`. Build+: all HIP-3 symbols. Pro+: orderbook history. |
|
|
71
|
+
| Hyperliquid HIP-4 | March 2026+ | Outcome markets. Pro+ for orderbook + L4 + orders. |
|
|
72
|
+
| Hyperliquid Spot | March 2025+ for trades; May 2026+ for orderbook, L4, TWAP statuses | 294 dashed pairs (`HYPE-USDC`, `PURR-USDC`). No funding, OI, liquidations, or candles (perp-only constructs). |
|
|
66
73
|
| Lighter.xyz | August 2025+ for fills; January 2026+ for orderbooks, open interest, funding rates | Perpetuals |
|
|
67
74
|
|
|
68
75
|
## Configuration
|
|
@@ -370,6 +377,69 @@ const orders = await client.hyperliquid.hip4.getOrderHistory('0', {
|
|
|
370
377
|
|
|
371
378
|
> **No HIP-4 funding, liquidations, or candles.** These methods do not exist on `client.hyperliquid.hip4` by design. Don't expect them.
|
|
372
379
|
|
|
380
|
+
#### Hyperliquid Spot
|
|
381
|
+
|
|
382
|
+
Spot pairs live at `/v1/hyperliquid/spot` and `client.spot`. Symbols are dashed canonical (`HYPE-USDC`, `PURR-USDC`); the server resolves the dashed form to Hyperliquid's wire formats (`PURR/USDC`, `@107`) internally.
|
|
383
|
+
|
|
384
|
+
Spot has **no funding, no open interest, no liquidations, and no candles** by design. Those are perpetual constructs. The SDK omits those resources from the spot client.
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
// Pairs (one row per dashed symbol)
|
|
388
|
+
const pairs = await client.spot.pairs.list();
|
|
389
|
+
const hype = await client.spot.pairs.get('HYPE-USDC');
|
|
390
|
+
console.log(`${hype.symbol}: mark=${hype.markPrice}, mid=${hype.midPrice}`);
|
|
391
|
+
|
|
392
|
+
// Orderbook (Build+, live from 2026-05-05)
|
|
393
|
+
const ob = await client.spot.orderbook.get('HYPE-USDC');
|
|
394
|
+
console.log(`${ob.coin} mid: ${ob.midPrice}`);
|
|
395
|
+
|
|
396
|
+
// Orderbook history
|
|
397
|
+
const obHistory = await client.spot.orderbook.history('HYPE-USDC', {
|
|
398
|
+
start: Date.now() - 3600000,
|
|
399
|
+
end: Date.now(),
|
|
400
|
+
limit: 100,
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
// Trade history (S3 backfill from 2025-03-22)
|
|
404
|
+
const trades = await client.spot.trades.list('HYPE-USDC', {
|
|
405
|
+
start: Date.now() - 86400000,
|
|
406
|
+
end: Date.now(),
|
|
407
|
+
limit: 1000,
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
// Recent trades (real-time)
|
|
411
|
+
const recent = await client.spot.trades.recent('HYPE-USDC', 100);
|
|
412
|
+
|
|
413
|
+
// L4 reconstruction (Pro+, live from 2026-05-05)
|
|
414
|
+
const l4 = await client.spot.l4Orderbook.get('HYPE-USDC');
|
|
415
|
+
const diffs = await client.spot.l4Orderbook.diffs('HYPE-USDC', {
|
|
416
|
+
start: Date.now() - 3600000,
|
|
417
|
+
end: Date.now(),
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// Order lifecycle events (Pro+)
|
|
421
|
+
const orders = await client.spot.orders.history('HYPE-USDC', {
|
|
422
|
+
start: Date.now() - 86400000,
|
|
423
|
+
end: Date.now(),
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
// TWAP statuses by symbol or by user wallet
|
|
427
|
+
const bySymbol = await client.spot.twap.bySymbol('HYPE-USDC', {
|
|
428
|
+
start: Date.now() - 86400000,
|
|
429
|
+
end: Date.now(),
|
|
430
|
+
});
|
|
431
|
+
const byUser = await client.spot.twap.byUser('0xabc...', {
|
|
432
|
+
start: Date.now() - 86400000,
|
|
433
|
+
end: Date.now(),
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
// Per-symbol freshness across all spot data types
|
|
437
|
+
const fresh = await client.spot.freshness('HYPE-USDC');
|
|
438
|
+
console.log(`Orderbook last updated: ${fresh.orderbook.lastUpdated}`);
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
> **Coverage caveats.** Spot trades go back to 2025-03-22 (the earliest date Hyperliquid published S3 spot fills). Pre-March 2025 spot history is unrecoverable from any free public archive. Spot orderbook, L4, and TWAP data are live-only from 2026-05-05; Hyperliquid does not publish historical spot orderbook data.
|
|
442
|
+
|
|
373
443
|
### Funding Rates
|
|
374
444
|
|
|
375
445
|
```typescript
|
|
@@ -1224,6 +1294,38 @@ ws.onOutcomeSettled((coin, outcomeId, side, value, at) => {
|
|
|
1224
1294
|
});
|
|
1225
1295
|
```
|
|
1226
1296
|
|
|
1297
|
+
#### Hyperliquid Spot Channels
|
|
1298
|
+
|
|
1299
|
+
| Channel | Description | Requires Coin | Mode |
|
|
1300
|
+
|---------|-------------|---------------|-------------------|
|
|
1301
|
+
| `spot_orderbook` | Spot L2 order book snapshots (Build+) | Yes | Real-time only |
|
|
1302
|
+
| `spot_trades` | Spot trade/fill updates (Build+) | Yes | Real-time only |
|
|
1303
|
+
| `spot_l4_diffs` | Spot L4 orderbook diffs (Pro+) | Yes | Real-time only |
|
|
1304
|
+
| `spot_l4_orders` | Spot order lifecycle events (Pro+) | Yes | Real-time only |
|
|
1305
|
+
| `spot_twap` | Spot TWAP statuses (Build+) | Yes | Real-time only |
|
|
1306
|
+
|
|
1307
|
+
Spot symbols are dashed canonical (`HYPE-USDC`, `PURR-USDC`). The server resolves the dashed form to wire format internally. Spot has no funding, no open interest, no liquidations, and no candles by design.
|
|
1308
|
+
|
|
1309
|
+
```typescript
|
|
1310
|
+
ws.onOrderbook((coin, ob) => {
|
|
1311
|
+
console.log(`${coin} mid: ${ob.midPrice}`);
|
|
1312
|
+
});
|
|
1313
|
+
ws.onTrades((coin, trades) => {
|
|
1314
|
+
console.log(`${coin} got ${trades.length} trades`);
|
|
1315
|
+
});
|
|
1316
|
+
|
|
1317
|
+
await ws.connect();
|
|
1318
|
+
ws.subscribeSpot('orderbook', 'HYPE-USDC');
|
|
1319
|
+
ws.subscribeSpot('trades', 'HYPE-USDC');
|
|
1320
|
+
|
|
1321
|
+
// Pro+: L4 channels
|
|
1322
|
+
ws.subscribeSpot('l4_diffs', 'HYPE-USDC');
|
|
1323
|
+
ws.subscribeSpot('l4_orders', 'HYPE-USDC');
|
|
1324
|
+
|
|
1325
|
+
// TWAP statuses
|
|
1326
|
+
ws.subscribeSpot('twap', 'HYPE-USDC');
|
|
1327
|
+
```
|
|
1328
|
+
|
|
1227
1329
|
#### Live Liquidations
|
|
1228
1330
|
|
|
1229
1331
|
```typescript
|