@0xarchive/sdk 0.3.10 → 0.4.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 +43 -18
- package/dist/index.d.mts +203 -97
- package/dist/index.d.ts +203 -97
- package/dist/index.js +144 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# @0xarchive/sdk
|
|
2
2
|
|
|
3
|
-
Official TypeScript/JavaScript SDK for [0xarchive](https://0xarchive.io) -
|
|
3
|
+
Official TypeScript/JavaScript SDK for [0xarchive](https://0xarchive.io) - Historical Market Data API.
|
|
4
|
+
|
|
5
|
+
Supports multiple exchanges:
|
|
6
|
+
- **Hyperliquid** - Perpetuals data from April 2023
|
|
7
|
+
- **Lighter.xyz** - Perpetuals data with orderbook reconstruction
|
|
4
8
|
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
@@ -19,12 +23,16 @@ import { OxArchive } from '@0xarchive/sdk';
|
|
|
19
23
|
|
|
20
24
|
const client = new OxArchive({ apiKey: 'ox_your_api_key' });
|
|
21
25
|
|
|
22
|
-
//
|
|
23
|
-
const
|
|
24
|
-
console.log(`BTC mid price: ${
|
|
26
|
+
// Hyperliquid data
|
|
27
|
+
const hlOrderbook = await client.hyperliquid.orderbook.get('BTC');
|
|
28
|
+
console.log(`Hyperliquid BTC mid price: ${hlOrderbook.midPrice}`);
|
|
29
|
+
|
|
30
|
+
// Lighter.xyz data
|
|
31
|
+
const lighterOrderbook = await client.lighter.orderbook.get('BTC');
|
|
32
|
+
console.log(`Lighter BTC mid price: ${lighterOrderbook.midPrice}`);
|
|
25
33
|
|
|
26
34
|
// Get historical order book snapshots
|
|
27
|
-
const history = await client.orderbook.history('ETH', {
|
|
35
|
+
const history = await client.hyperliquid.orderbook.history('ETH', {
|
|
28
36
|
start: Date.now() - 86400000, // 24 hours ago
|
|
29
37
|
end: Date.now(),
|
|
30
38
|
limit: 100
|
|
@@ -44,20 +52,25 @@ const client = new OxArchive({
|
|
|
44
52
|
|
|
45
53
|
## REST API Reference
|
|
46
54
|
|
|
55
|
+
All examples use `client.hyperliquid.*` but the same methods are available on `client.lighter.*` for Lighter.xyz data.
|
|
56
|
+
|
|
47
57
|
### Order Book
|
|
48
58
|
|
|
49
59
|
```typescript
|
|
50
|
-
// Get current order book
|
|
51
|
-
const orderbook = await client.orderbook.get('BTC');
|
|
60
|
+
// Get current order book (Hyperliquid)
|
|
61
|
+
const orderbook = await client.hyperliquid.orderbook.get('BTC');
|
|
62
|
+
|
|
63
|
+
// Get current order book (Lighter.xyz)
|
|
64
|
+
const lighterOb = await client.lighter.orderbook.get('BTC');
|
|
52
65
|
|
|
53
66
|
// Get order book at specific timestamp with custom depth
|
|
54
|
-
const historical = await client.orderbook.get('BTC', {
|
|
67
|
+
const historical = await client.hyperliquid.orderbook.get('BTC', {
|
|
55
68
|
timestamp: 1704067200000,
|
|
56
69
|
depth: 20 // Number of levels per side
|
|
57
70
|
});
|
|
58
71
|
|
|
59
72
|
// Get historical snapshots (start is required)
|
|
60
|
-
const history = await client.orderbook.history('BTC', {
|
|
73
|
+
const history = await client.hyperliquid.orderbook.history('BTC', {
|
|
61
74
|
start: Date.now() - 86400000,
|
|
62
75
|
end: Date.now(),
|
|
63
76
|
limit: 1000
|
|
@@ -70,10 +83,10 @@ The trades API uses cursor-based pagination for efficient retrieval of large dat
|
|
|
70
83
|
|
|
71
84
|
```typescript
|
|
72
85
|
// Get recent trades
|
|
73
|
-
const recent = await client.trades.recent('BTC', 100);
|
|
86
|
+
const recent = await client.hyperliquid.trades.recent('BTC', 100);
|
|
74
87
|
|
|
75
88
|
// Get trade history with cursor-based pagination
|
|
76
|
-
let result = await client.trades.list('BTC', {
|
|
89
|
+
let result = await client.hyperliquid.trades.list('BTC', {
|
|
77
90
|
start: Date.now() - 86400000,
|
|
78
91
|
end: Date.now(),
|
|
79
92
|
limit: 1000
|
|
@@ -82,7 +95,7 @@ let result = await client.trades.list('BTC', {
|
|
|
82
95
|
// Paginate through all results
|
|
83
96
|
const allTrades = [...result.data];
|
|
84
97
|
while (result.nextCursor) {
|
|
85
|
-
result = await client.trades.list('BTC', {
|
|
98
|
+
result = await client.hyperliquid.trades.list('BTC', {
|
|
86
99
|
start: Date.now() - 86400000,
|
|
87
100
|
end: Date.now(),
|
|
88
101
|
cursor: result.nextCursor,
|
|
@@ -96,20 +109,20 @@ while (result.nextCursor) {
|
|
|
96
109
|
|
|
97
110
|
```typescript
|
|
98
111
|
// List all trading instruments
|
|
99
|
-
const instruments = await client.instruments.list();
|
|
112
|
+
const instruments = await client.hyperliquid.instruments.list();
|
|
100
113
|
|
|
101
114
|
// Get specific instrument details
|
|
102
|
-
const btc = await client.instruments.get('BTC');
|
|
115
|
+
const btc = await client.hyperliquid.instruments.get('BTC');
|
|
103
116
|
```
|
|
104
117
|
|
|
105
118
|
### Funding Rates
|
|
106
119
|
|
|
107
120
|
```typescript
|
|
108
121
|
// Get current funding rate
|
|
109
|
-
const current = await client.funding.current('BTC');
|
|
122
|
+
const current = await client.hyperliquid.funding.current('BTC');
|
|
110
123
|
|
|
111
124
|
// Get funding rate history (start is required)
|
|
112
|
-
const history = await client.funding.history('ETH', {
|
|
125
|
+
const history = await client.hyperliquid.funding.history('ETH', {
|
|
113
126
|
start: Date.now() - 86400000 * 7,
|
|
114
127
|
end: Date.now()
|
|
115
128
|
});
|
|
@@ -119,16 +132,28 @@ const history = await client.funding.history('ETH', {
|
|
|
119
132
|
|
|
120
133
|
```typescript
|
|
121
134
|
// Get current open interest
|
|
122
|
-
const current = await client.openInterest.current('BTC');
|
|
135
|
+
const current = await client.hyperliquid.openInterest.current('BTC');
|
|
123
136
|
|
|
124
137
|
// Get open interest history (start is required)
|
|
125
|
-
const history = await client.openInterest.history('ETH', {
|
|
138
|
+
const history = await client.hyperliquid.openInterest.history('ETH', {
|
|
126
139
|
start: Date.now() - 86400000,
|
|
127
140
|
end: Date.now(),
|
|
128
141
|
limit: 100
|
|
129
142
|
});
|
|
130
143
|
```
|
|
131
144
|
|
|
145
|
+
### Legacy API (Deprecated)
|
|
146
|
+
|
|
147
|
+
The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// Deprecated - use client.hyperliquid.orderbook.get() instead
|
|
151
|
+
const orderbook = await client.orderbook.get('BTC');
|
|
152
|
+
|
|
153
|
+
// Deprecated - use client.hyperliquid.trades.list() instead
|
|
154
|
+
const trades = await client.trades.list('BTC', { start, end });
|
|
155
|
+
```
|
|
156
|
+
|
|
132
157
|
## WebSocket Client
|
|
133
158
|
|
|
134
159
|
The WebSocket client supports three modes: real-time streaming, historical replay, and bulk streaming.
|
package/dist/index.d.mts
CHANGED
|
@@ -32,26 +32,6 @@ interface ApiResponse<T> {
|
|
|
32
32
|
data: T;
|
|
33
33
|
meta: ApiMeta;
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Pagination parameters for list endpoints
|
|
37
|
-
* @deprecated Use cursor-based pagination instead (CursorPaginationParams)
|
|
38
|
-
*/
|
|
39
|
-
interface PaginationParams {
|
|
40
|
-
/** Maximum number of results to return */
|
|
41
|
-
limit?: number;
|
|
42
|
-
/** @deprecated Use cursor instead. Number of results to skip */
|
|
43
|
-
offset?: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Time range parameters for historical queries
|
|
47
|
-
* @deprecated Use CursorPaginationParams for better performance with large datasets
|
|
48
|
-
*/
|
|
49
|
-
interface TimeRangeParams extends PaginationParams {
|
|
50
|
-
/** Start timestamp (Unix ms or ISO string) - REQUIRED for history endpoints */
|
|
51
|
-
start: number | string;
|
|
52
|
-
/** End timestamp (Unix ms or ISO string) - REQUIRED for history endpoints */
|
|
53
|
-
end: number | string;
|
|
54
|
-
}
|
|
55
35
|
/**
|
|
56
36
|
* A price level in the order book
|
|
57
37
|
*/
|
|
@@ -88,7 +68,7 @@ interface GetOrderBookParams {
|
|
|
88
68
|
/** Number of price levels to return per side */
|
|
89
69
|
depth?: number;
|
|
90
70
|
}
|
|
91
|
-
interface OrderBookHistoryParams extends
|
|
71
|
+
interface OrderBookHistoryParams extends CursorPaginationParams {
|
|
92
72
|
/** Number of price levels to return per side */
|
|
93
73
|
depth?: number;
|
|
94
74
|
}
|
|
@@ -136,14 +116,7 @@ interface Trade {
|
|
|
136
116
|
takerAddress?: string;
|
|
137
117
|
}
|
|
138
118
|
/**
|
|
139
|
-
*
|
|
140
|
-
*/
|
|
141
|
-
interface GetTradesParams extends TimeRangeParams {
|
|
142
|
-
/** Filter by side */
|
|
143
|
-
side?: TradeSide;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Cursor-based pagination parameters for trades (recommended)
|
|
119
|
+
* Cursor-based pagination parameters (recommended)
|
|
147
120
|
* More efficient than offset-based pagination for large datasets.
|
|
148
121
|
* The cursor is a timestamp - use the `nextCursor` from the response to get the next page.
|
|
149
122
|
*/
|
|
@@ -204,6 +177,11 @@ interface FundingRate {
|
|
|
204
177
|
/** Premium component of funding rate */
|
|
205
178
|
premium?: string;
|
|
206
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* Parameters for getting funding rate history
|
|
182
|
+
*/
|
|
183
|
+
interface FundingHistoryParams extends CursorPaginationParams {
|
|
184
|
+
}
|
|
207
185
|
/**
|
|
208
186
|
* Open interest snapshot with market context
|
|
209
187
|
*/
|
|
@@ -229,6 +207,11 @@ interface OpenInterest {
|
|
|
229
207
|
/** Impact ask price for liquidations */
|
|
230
208
|
impactAskPrice?: string;
|
|
231
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Parameters for getting open interest history
|
|
212
|
+
*/
|
|
213
|
+
interface OpenInterestHistoryParams extends CursorPaginationParams {
|
|
214
|
+
}
|
|
232
215
|
/** WebSocket channel types. Note: ticker/all_tickers are real-time only. */
|
|
233
216
|
type WsChannel = 'orderbook' | 'trades' | 'ticker' | 'all_tickers';
|
|
234
217
|
/** Subscribe message from client */
|
|
@@ -502,7 +485,8 @@ declare class HttpClient {
|
|
|
502
485
|
*/
|
|
503
486
|
declare class OrderBookResource {
|
|
504
487
|
private http;
|
|
505
|
-
|
|
488
|
+
private basePath;
|
|
489
|
+
constructor(http: HttpClient, basePath?: string);
|
|
506
490
|
/**
|
|
507
491
|
* Get order book snapshot for a coin
|
|
508
492
|
*
|
|
@@ -512,13 +496,33 @@ declare class OrderBookResource {
|
|
|
512
496
|
*/
|
|
513
497
|
get(coin: string, params?: GetOrderBookParams): Promise<OrderBook>;
|
|
514
498
|
/**
|
|
515
|
-
* Get historical order book snapshots
|
|
499
|
+
* Get historical order book snapshots with cursor-based pagination
|
|
516
500
|
*
|
|
517
501
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
518
|
-
* @param params - Time range and pagination parameters (start
|
|
519
|
-
* @returns
|
|
502
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
503
|
+
* @returns CursorResponse with order book snapshots and nextCursor for pagination
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
* ```typescript
|
|
507
|
+
* // First page
|
|
508
|
+
* let result = await client.orderbook.history('BTC', {
|
|
509
|
+
* start: Date.now() - 86400000,
|
|
510
|
+
* end: Date.now(),
|
|
511
|
+
* limit: 1000
|
|
512
|
+
* });
|
|
513
|
+
*
|
|
514
|
+
* // Subsequent pages
|
|
515
|
+
* while (result.nextCursor) {
|
|
516
|
+
* result = await client.orderbook.history('BTC', {
|
|
517
|
+
* start: Date.now() - 86400000,
|
|
518
|
+
* end: Date.now(),
|
|
519
|
+
* cursor: result.nextCursor,
|
|
520
|
+
* limit: 1000
|
|
521
|
+
* });
|
|
522
|
+
* }
|
|
523
|
+
* ```
|
|
520
524
|
*/
|
|
521
|
-
history(coin: string, params: OrderBookHistoryParams): Promise<OrderBook[]
|
|
525
|
+
history(coin: string, params: OrderBookHistoryParams): Promise<CursorResponse<OrderBook[]>>;
|
|
522
526
|
}
|
|
523
527
|
|
|
524
528
|
/**
|
|
@@ -551,7 +555,8 @@ declare class OrderBookResource {
|
|
|
551
555
|
*/
|
|
552
556
|
declare class TradesResource {
|
|
553
557
|
private http;
|
|
554
|
-
|
|
558
|
+
private basePath;
|
|
559
|
+
constructor(http: HttpClient, basePath?: string);
|
|
555
560
|
/**
|
|
556
561
|
* Get trade history for a coin using cursor-based pagination
|
|
557
562
|
*
|
|
@@ -591,26 +596,6 @@ declare class TradesResource {
|
|
|
591
596
|
* @returns Array of recent trades
|
|
592
597
|
*/
|
|
593
598
|
recent(coin: string, limit?: number): Promise<Trade[]>;
|
|
594
|
-
/**
|
|
595
|
-
* Get trade history using cursor-based pagination (explicit endpoint)
|
|
596
|
-
*
|
|
597
|
-
* @deprecated Use `list()` instead - it now uses cursor-based pagination by default.
|
|
598
|
-
*
|
|
599
|
-
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
600
|
-
* @param params - Cursor pagination parameters (start and end are required)
|
|
601
|
-
* @returns Object with trades array and nextCursor for pagination
|
|
602
|
-
*/
|
|
603
|
-
listWithCursor(coin: string, params: GetTradesCursorParams): Promise<CursorResponse<Trade[]>>;
|
|
604
|
-
/**
|
|
605
|
-
* Get trade history using offset-based pagination
|
|
606
|
-
*
|
|
607
|
-
* @deprecated Use `list()` with cursor-based pagination instead for better performance.
|
|
608
|
-
*
|
|
609
|
-
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
610
|
-
* @param params - Time range and offset pagination parameters
|
|
611
|
-
* @returns Array of trades (without cursor response wrapper)
|
|
612
|
-
*/
|
|
613
|
-
listWithOffset(coin: string, params: GetTradesParams): Promise<Trade[]>;
|
|
614
599
|
}
|
|
615
600
|
|
|
616
601
|
/**
|
|
@@ -627,7 +612,8 @@ declare class TradesResource {
|
|
|
627
612
|
*/
|
|
628
613
|
declare class InstrumentsResource {
|
|
629
614
|
private http;
|
|
630
|
-
|
|
615
|
+
private basePath;
|
|
616
|
+
constructor(http: HttpClient, basePath?: string);
|
|
631
617
|
/**
|
|
632
618
|
* List all available trading instruments
|
|
633
619
|
*
|
|
@@ -651,24 +637,38 @@ declare class InstrumentsResource {
|
|
|
651
637
|
* // Get current funding rate
|
|
652
638
|
* const current = await client.funding.current('BTC');
|
|
653
639
|
*
|
|
654
|
-
* // Get funding rate history
|
|
655
|
-
*
|
|
640
|
+
* // Get funding rate history with cursor-based pagination
|
|
641
|
+
* let result = await client.funding.history('ETH', {
|
|
656
642
|
* start: Date.now() - 86400000 * 7,
|
|
657
|
-
* end: Date.now()
|
|
643
|
+
* end: Date.now(),
|
|
644
|
+
* limit: 1000
|
|
658
645
|
* });
|
|
646
|
+
*
|
|
647
|
+
* // Get all pages
|
|
648
|
+
* const allRates = [...result.data];
|
|
649
|
+
* while (result.nextCursor) {
|
|
650
|
+
* result = await client.funding.history('ETH', {
|
|
651
|
+
* start: Date.now() - 86400000 * 7,
|
|
652
|
+
* end: Date.now(),
|
|
653
|
+
* cursor: result.nextCursor,
|
|
654
|
+
* limit: 1000
|
|
655
|
+
* });
|
|
656
|
+
* allRates.push(...result.data);
|
|
657
|
+
* }
|
|
659
658
|
* ```
|
|
660
659
|
*/
|
|
661
660
|
declare class FundingResource {
|
|
662
661
|
private http;
|
|
663
|
-
|
|
662
|
+
private basePath;
|
|
663
|
+
constructor(http: HttpClient, basePath?: string);
|
|
664
664
|
/**
|
|
665
|
-
* Get funding rate history for a coin
|
|
665
|
+
* Get funding rate history for a coin with cursor-based pagination
|
|
666
666
|
*
|
|
667
667
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
668
|
-
* @param params - Time range and pagination parameters (start
|
|
669
|
-
* @returns
|
|
668
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
669
|
+
* @returns CursorResponse with funding rate records and nextCursor for pagination
|
|
670
670
|
*/
|
|
671
|
-
history(coin: string, params:
|
|
671
|
+
history(coin: string, params: FundingHistoryParams): Promise<CursorResponse<FundingRate[]>>;
|
|
672
672
|
/**
|
|
673
673
|
* Get current funding rate for a coin
|
|
674
674
|
*
|
|
@@ -686,25 +686,38 @@ declare class FundingResource {
|
|
|
686
686
|
* // Get current open interest
|
|
687
687
|
* const current = await client.openInterest.current('BTC');
|
|
688
688
|
*
|
|
689
|
-
* // Get open interest history
|
|
690
|
-
*
|
|
689
|
+
* // Get open interest history with cursor-based pagination
|
|
690
|
+
* let result = await client.openInterest.history('ETH', {
|
|
691
691
|
* start: Date.now() - 86400000,
|
|
692
692
|
* end: Date.now(),
|
|
693
|
-
* limit:
|
|
693
|
+
* limit: 1000
|
|
694
694
|
* });
|
|
695
|
+
*
|
|
696
|
+
* // Get all pages
|
|
697
|
+
* const allRecords = [...result.data];
|
|
698
|
+
* while (result.nextCursor) {
|
|
699
|
+
* result = await client.openInterest.history('ETH', {
|
|
700
|
+
* start: Date.now() - 86400000,
|
|
701
|
+
* end: Date.now(),
|
|
702
|
+
* cursor: result.nextCursor,
|
|
703
|
+
* limit: 1000
|
|
704
|
+
* });
|
|
705
|
+
* allRecords.push(...result.data);
|
|
706
|
+
* }
|
|
695
707
|
* ```
|
|
696
708
|
*/
|
|
697
709
|
declare class OpenInterestResource {
|
|
698
710
|
private http;
|
|
699
|
-
|
|
711
|
+
private basePath;
|
|
712
|
+
constructor(http: HttpClient, basePath?: string);
|
|
700
713
|
/**
|
|
701
|
-
* Get open interest history for a coin
|
|
714
|
+
* Get open interest history for a coin with cursor-based pagination
|
|
702
715
|
*
|
|
703
716
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
704
|
-
* @param params - Time range and pagination parameters (start
|
|
705
|
-
* @returns
|
|
717
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
718
|
+
* @returns CursorResponse with open interest records and nextCursor for pagination
|
|
706
719
|
*/
|
|
707
|
-
history(coin: string, params:
|
|
720
|
+
history(coin: string, params: OpenInterestHistoryParams): Promise<CursorResponse<OpenInterest[]>>;
|
|
708
721
|
/**
|
|
709
722
|
* Get current open interest for a coin
|
|
710
723
|
*
|
|
@@ -714,50 +727,143 @@ declare class OpenInterestResource {
|
|
|
714
727
|
current(coin: string): Promise<OpenInterest>;
|
|
715
728
|
}
|
|
716
729
|
|
|
730
|
+
/**
|
|
731
|
+
* Hyperliquid exchange client
|
|
732
|
+
*
|
|
733
|
+
* Access Hyperliquid market data through the 0xarchive API.
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```typescript
|
|
737
|
+
* const client = new OxArchive({ apiKey: '...' });
|
|
738
|
+
* const orderbook = await client.hyperliquid.orderbook.get('BTC');
|
|
739
|
+
* const trades = await client.hyperliquid.trades.list('ETH', { start, end });
|
|
740
|
+
* ```
|
|
741
|
+
*/
|
|
742
|
+
declare class HyperliquidClient {
|
|
743
|
+
/**
|
|
744
|
+
* Order book data (L2 snapshots from April 2023)
|
|
745
|
+
*/
|
|
746
|
+
readonly orderbook: OrderBookResource;
|
|
747
|
+
/**
|
|
748
|
+
* Trade/fill history
|
|
749
|
+
*/
|
|
750
|
+
readonly trades: TradesResource;
|
|
751
|
+
/**
|
|
752
|
+
* Trading instruments metadata
|
|
753
|
+
*/
|
|
754
|
+
readonly instruments: InstrumentsResource;
|
|
755
|
+
/**
|
|
756
|
+
* Funding rates
|
|
757
|
+
*/
|
|
758
|
+
readonly funding: FundingResource;
|
|
759
|
+
/**
|
|
760
|
+
* Open interest
|
|
761
|
+
*/
|
|
762
|
+
readonly openInterest: OpenInterestResource;
|
|
763
|
+
constructor(http: HttpClient);
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Lighter.xyz exchange client
|
|
767
|
+
*
|
|
768
|
+
* Access Lighter.xyz market data through the 0xarchive API.
|
|
769
|
+
* Lighter orderbooks are reconstructed from checkpoint + delta data.
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* ```typescript
|
|
773
|
+
* const client = new OxArchive({ apiKey: '...' });
|
|
774
|
+
* const orderbook = await client.lighter.orderbook.get('BTC');
|
|
775
|
+
* const trades = await client.lighter.trades.list('ETH', { start, end });
|
|
776
|
+
* ```
|
|
777
|
+
*/
|
|
778
|
+
declare class LighterClient {
|
|
779
|
+
/**
|
|
780
|
+
* Order book data (reconstructed from checkpoints + deltas)
|
|
781
|
+
*/
|
|
782
|
+
readonly orderbook: OrderBookResource;
|
|
783
|
+
/**
|
|
784
|
+
* Trade/fill history
|
|
785
|
+
*/
|
|
786
|
+
readonly trades: TradesResource;
|
|
787
|
+
/**
|
|
788
|
+
* Trading instruments metadata
|
|
789
|
+
*/
|
|
790
|
+
readonly instruments: InstrumentsResource;
|
|
791
|
+
/**
|
|
792
|
+
* Funding rates
|
|
793
|
+
*/
|
|
794
|
+
readonly funding: FundingResource;
|
|
795
|
+
/**
|
|
796
|
+
* Open interest
|
|
797
|
+
*/
|
|
798
|
+
readonly openInterest: OpenInterestResource;
|
|
799
|
+
constructor(http: HttpClient);
|
|
800
|
+
}
|
|
801
|
+
|
|
717
802
|
/**
|
|
718
803
|
* 0xarchive API client
|
|
719
804
|
*
|
|
805
|
+
* Supports multiple exchanges:
|
|
806
|
+
* - `client.hyperliquid` - Hyperliquid perpetuals (April 2023+)
|
|
807
|
+
* - `client.lighter` - Lighter.xyz perpetuals
|
|
808
|
+
*
|
|
720
809
|
* @example
|
|
721
810
|
* ```typescript
|
|
722
811
|
* import { OxArchive } from '@0xarchive/sdk';
|
|
723
812
|
*
|
|
724
813
|
* const client = new OxArchive({ apiKey: 'ox_your_api_key' });
|
|
725
814
|
*
|
|
726
|
-
* //
|
|
727
|
-
* const
|
|
728
|
-
* console.log(`BTC mid price: ${
|
|
815
|
+
* // Hyperliquid data
|
|
816
|
+
* const hlOrderbook = await client.hyperliquid.orderbook.get('BTC');
|
|
817
|
+
* console.log(`BTC mid price: ${hlOrderbook.mid_price}`);
|
|
818
|
+
*
|
|
819
|
+
* // Lighter.xyz data
|
|
820
|
+
* const lighterOrderbook = await client.lighter.orderbook.get('BTC');
|
|
729
821
|
*
|
|
730
822
|
* // Get historical data
|
|
731
|
-
* const history = await client.orderbook.history('ETH', {
|
|
823
|
+
* const history = await client.hyperliquid.orderbook.history('ETH', {
|
|
732
824
|
* start: Date.now() - 86400000,
|
|
733
825
|
* end: Date.now(),
|
|
734
826
|
* limit: 100
|
|
735
827
|
* });
|
|
736
828
|
*
|
|
737
829
|
* // List all instruments
|
|
738
|
-
* const instruments = await client.instruments.list();
|
|
830
|
+
* const instruments = await client.hyperliquid.instruments.list();
|
|
831
|
+
* ```
|
|
832
|
+
*
|
|
833
|
+
* Legacy usage (deprecated, will be removed in v2.0):
|
|
834
|
+
* ```typescript
|
|
835
|
+
* // These still work but use client.hyperliquid.* instead
|
|
836
|
+
* const orderbook = await client.orderbook.get('BTC'); // deprecated
|
|
739
837
|
* ```
|
|
740
838
|
*/
|
|
741
839
|
declare class OxArchive {
|
|
742
840
|
private http;
|
|
743
841
|
/**
|
|
744
|
-
*
|
|
842
|
+
* Hyperliquid exchange data (orderbook, trades, funding, OI from April 2023)
|
|
843
|
+
*/
|
|
844
|
+
readonly hyperliquid: HyperliquidClient;
|
|
845
|
+
/**
|
|
846
|
+
* Lighter.xyz exchange data (orderbook reconstructed from checkpoints + deltas)
|
|
847
|
+
*/
|
|
848
|
+
readonly lighter: LighterClient;
|
|
849
|
+
/**
|
|
850
|
+
* @deprecated Use client.hyperliquid.orderbook instead
|
|
745
851
|
*/
|
|
746
852
|
readonly orderbook: OrderBookResource;
|
|
747
853
|
/**
|
|
748
|
-
*
|
|
854
|
+
* @deprecated Use client.hyperliquid.trades instead
|
|
749
855
|
*/
|
|
750
856
|
readonly trades: TradesResource;
|
|
751
857
|
/**
|
|
752
|
-
*
|
|
858
|
+
* @deprecated Use client.hyperliquid.instruments instead
|
|
753
859
|
*/
|
|
754
860
|
readonly instruments: InstrumentsResource;
|
|
755
861
|
/**
|
|
756
|
-
*
|
|
862
|
+
* @deprecated Use client.hyperliquid.funding instead
|
|
757
863
|
*/
|
|
758
864
|
readonly funding: FundingResource;
|
|
759
865
|
/**
|
|
760
|
-
*
|
|
866
|
+
* @deprecated Use client.hyperliquid.openInterest instead
|
|
761
867
|
*/
|
|
762
868
|
readonly openInterest: OpenInterestResource;
|
|
763
869
|
/**
|
|
@@ -1374,18 +1480,18 @@ declare const WsReplayStartedSchema: z.ZodObject<{
|
|
|
1374
1480
|
end: z.ZodNumber;
|
|
1375
1481
|
speed: z.ZodNumber;
|
|
1376
1482
|
}, "strip", z.ZodTypeAny, {
|
|
1377
|
-
start: number;
|
|
1378
|
-
end: number;
|
|
1379
1483
|
type: "replay_started";
|
|
1380
1484
|
coin: string;
|
|
1381
1485
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1382
|
-
speed: number;
|
|
1383
|
-
}, {
|
|
1384
1486
|
start: number;
|
|
1385
1487
|
end: number;
|
|
1488
|
+
speed: number;
|
|
1489
|
+
}, {
|
|
1386
1490
|
type: "replay_started";
|
|
1387
1491
|
coin: string;
|
|
1388
1492
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1493
|
+
start: number;
|
|
1494
|
+
end: number;
|
|
1389
1495
|
speed: number;
|
|
1390
1496
|
}>;
|
|
1391
1497
|
declare const WsReplayPausedSchema: z.ZodObject<{
|
|
@@ -1457,17 +1563,17 @@ declare const WsStreamStartedSchema: z.ZodObject<{
|
|
|
1457
1563
|
start: z.ZodNumber;
|
|
1458
1564
|
end: z.ZodNumber;
|
|
1459
1565
|
}, "strip", z.ZodTypeAny, {
|
|
1460
|
-
start: number;
|
|
1461
|
-
end: number;
|
|
1462
1566
|
type: "stream_started";
|
|
1463
1567
|
coin: string;
|
|
1464
1568
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1465
|
-
}, {
|
|
1466
1569
|
start: number;
|
|
1467
1570
|
end: number;
|
|
1571
|
+
}, {
|
|
1468
1572
|
type: "stream_started";
|
|
1469
1573
|
coin: string;
|
|
1470
1574
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1575
|
+
start: number;
|
|
1576
|
+
end: number;
|
|
1471
1577
|
}>;
|
|
1472
1578
|
declare const WsStreamProgressSchema: z.ZodObject<{
|
|
1473
1579
|
type: z.ZodLiteral<"stream_progress">;
|
|
@@ -1608,18 +1714,18 @@ declare const WsServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
|
1608
1714
|
end: z.ZodNumber;
|
|
1609
1715
|
speed: z.ZodNumber;
|
|
1610
1716
|
}, "strip", z.ZodTypeAny, {
|
|
1611
|
-
start: number;
|
|
1612
|
-
end: number;
|
|
1613
1717
|
type: "replay_started";
|
|
1614
1718
|
coin: string;
|
|
1615
1719
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1616
|
-
speed: number;
|
|
1617
|
-
}, {
|
|
1618
1720
|
start: number;
|
|
1619
1721
|
end: number;
|
|
1722
|
+
speed: number;
|
|
1723
|
+
}, {
|
|
1620
1724
|
type: "replay_started";
|
|
1621
1725
|
coin: string;
|
|
1622
1726
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1727
|
+
start: number;
|
|
1728
|
+
end: number;
|
|
1623
1729
|
speed: number;
|
|
1624
1730
|
}>, z.ZodObject<{
|
|
1625
1731
|
type: z.ZodLiteral<"replay_paused">;
|
|
@@ -1685,17 +1791,17 @@ declare const WsServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
|
1685
1791
|
start: z.ZodNumber;
|
|
1686
1792
|
end: z.ZodNumber;
|
|
1687
1793
|
}, "strip", z.ZodTypeAny, {
|
|
1688
|
-
start: number;
|
|
1689
|
-
end: number;
|
|
1690
1794
|
type: "stream_started";
|
|
1691
1795
|
coin: string;
|
|
1692
1796
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1693
|
-
}, {
|
|
1694
1797
|
start: number;
|
|
1695
1798
|
end: number;
|
|
1799
|
+
}, {
|
|
1696
1800
|
type: "stream_started";
|
|
1697
1801
|
coin: string;
|
|
1698
1802
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1803
|
+
start: number;
|
|
1804
|
+
end: number;
|
|
1699
1805
|
}>, z.ZodObject<{
|
|
1700
1806
|
type: z.ZodLiteral<"stream_progress">;
|
|
1701
1807
|
snapshotsSent: z.ZodNumber;
|
|
@@ -2578,4 +2684,4 @@ type ValidatedFundingRate = z.infer<typeof FundingRateSchema>;
|
|
|
2578
2684
|
type ValidatedOpenInterest = z.infer<typeof OpenInterestSchema>;
|
|
2579
2685
|
type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
|
|
2580
2686
|
|
|
2581
|
-
export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type ClientOptions, type CursorResponse, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams,
|
|
2687
|
+
export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type ClientOptions, type CursorResponse, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, HyperliquidClient, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, LighterClient, type OpenInterest, OpenInterestArrayResponseSchema, OpenInterestResponseSchema, OpenInterestSchema, type OrderBook, OrderBookArrayResponseSchema, type OrderBookHistoryParams, OrderBookResponseSchema, OrderBookSchema, OxArchive, OxArchiveError, OxArchiveWs, type PriceLevel, PriceLevelSchema, type Timestamp, type TimestampedRecord, TimestampedRecordSchema, type Trade, TradeArrayResponseSchema, type TradeDirection, TradeDirectionSchema, TradeSchema, type TradeSide, TradeSideSchema, type ValidatedApiMeta, type ValidatedFundingRate, type ValidatedInstrument, type ValidatedOpenInterest, type ValidatedOrderBook, type ValidatedPriceLevel, type ValidatedTrade, type ValidatedWsServerMessage, type WsChannel, WsChannelSchema, type WsClientMessage, type WsConnectionState, WsConnectionStateSchema, type WsData, WsDataSchema, type WsError, WsErrorSchema, type WsEventHandlers, type WsHistoricalBatch, WsHistoricalBatchSchema, type WsHistoricalData, WsHistoricalDataSchema, type WsOptions, type WsPing, type WsPong, WsPongSchema, type WsReplay, type WsReplayCompleted, WsReplayCompletedSchema, type WsReplayPause, type WsReplayPaused, WsReplayPausedSchema, type WsReplayResume, type WsReplayResumed, WsReplayResumedSchema, type WsReplaySeek, type WsReplayStarted, WsReplayStartedSchema, type WsReplayStop, type WsReplayStopped, WsReplayStoppedSchema, type WsServerMessage, WsServerMessageSchema, type WsStream, type WsStreamCompleted, WsStreamCompletedSchema, type WsStreamProgress, WsStreamProgressSchema, type WsStreamStarted, WsStreamStartedSchema, type WsStreamStop, type WsStreamStopped, WsStreamStoppedSchema, type WsSubscribe, type WsSubscribed, WsSubscribedSchema, type WsUnsubscribe, type WsUnsubscribed, WsUnsubscribedSchema, OxArchive as default };
|