@0xarchive/sdk 0.3.11 → 0.4.1
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 +113 -16
- package/dist/index.d.ts +113 -16
- package/dist/index.js +103 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -21
- 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 (August 2025+ for fills, Jan 2026+ for OB, OI, Funding Rate)
|
|
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
|
@@ -485,7 +485,8 @@ declare class HttpClient {
|
|
|
485
485
|
*/
|
|
486
486
|
declare class OrderBookResource {
|
|
487
487
|
private http;
|
|
488
|
-
|
|
488
|
+
private basePath;
|
|
489
|
+
constructor(http: HttpClient, basePath?: string);
|
|
489
490
|
/**
|
|
490
491
|
* Get order book snapshot for a coin
|
|
491
492
|
*
|
|
@@ -554,7 +555,8 @@ declare class OrderBookResource {
|
|
|
554
555
|
*/
|
|
555
556
|
declare class TradesResource {
|
|
556
557
|
private http;
|
|
557
|
-
|
|
558
|
+
private basePath;
|
|
559
|
+
constructor(http: HttpClient, basePath?: string);
|
|
558
560
|
/**
|
|
559
561
|
* Get trade history for a coin using cursor-based pagination
|
|
560
562
|
*
|
|
@@ -610,7 +612,8 @@ declare class TradesResource {
|
|
|
610
612
|
*/
|
|
611
613
|
declare class InstrumentsResource {
|
|
612
614
|
private http;
|
|
613
|
-
|
|
615
|
+
private basePath;
|
|
616
|
+
constructor(http: HttpClient, basePath?: string);
|
|
614
617
|
/**
|
|
615
618
|
* List all available trading instruments
|
|
616
619
|
*
|
|
@@ -656,7 +659,8 @@ declare class InstrumentsResource {
|
|
|
656
659
|
*/
|
|
657
660
|
declare class FundingResource {
|
|
658
661
|
private http;
|
|
659
|
-
|
|
662
|
+
private basePath;
|
|
663
|
+
constructor(http: HttpClient, basePath?: string);
|
|
660
664
|
/**
|
|
661
665
|
* Get funding rate history for a coin with cursor-based pagination
|
|
662
666
|
*
|
|
@@ -704,7 +708,8 @@ declare class FundingResource {
|
|
|
704
708
|
*/
|
|
705
709
|
declare class OpenInterestResource {
|
|
706
710
|
private http;
|
|
707
|
-
|
|
711
|
+
private basePath;
|
|
712
|
+
constructor(http: HttpClient, basePath?: string);
|
|
708
713
|
/**
|
|
709
714
|
* Get open interest history for a coin with cursor-based pagination
|
|
710
715
|
*
|
|
@@ -722,50 +727,142 @@ declare class OpenInterestResource {
|
|
|
722
727
|
current(coin: string): Promise<OpenInterest>;
|
|
723
728
|
}
|
|
724
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
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```typescript
|
|
772
|
+
* const client = new OxArchive({ apiKey: '...' });
|
|
773
|
+
* const orderbook = await client.lighter.orderbook.get('BTC');
|
|
774
|
+
* const trades = await client.lighter.trades.list('ETH', { start, end });
|
|
775
|
+
* ```
|
|
776
|
+
*/
|
|
777
|
+
declare class LighterClient {
|
|
778
|
+
/**
|
|
779
|
+
* Order book data (L2 snapshots)
|
|
780
|
+
*/
|
|
781
|
+
readonly orderbook: OrderBookResource;
|
|
782
|
+
/**
|
|
783
|
+
* Trade/fill history
|
|
784
|
+
*/
|
|
785
|
+
readonly trades: TradesResource;
|
|
786
|
+
/**
|
|
787
|
+
* Trading instruments metadata
|
|
788
|
+
*/
|
|
789
|
+
readonly instruments: InstrumentsResource;
|
|
790
|
+
/**
|
|
791
|
+
* Funding rates
|
|
792
|
+
*/
|
|
793
|
+
readonly funding: FundingResource;
|
|
794
|
+
/**
|
|
795
|
+
* Open interest
|
|
796
|
+
*/
|
|
797
|
+
readonly openInterest: OpenInterestResource;
|
|
798
|
+
constructor(http: HttpClient);
|
|
799
|
+
}
|
|
800
|
+
|
|
725
801
|
/**
|
|
726
802
|
* 0xarchive API client
|
|
727
803
|
*
|
|
804
|
+
* Supports multiple exchanges:
|
|
805
|
+
* - `client.hyperliquid` - Hyperliquid perpetuals (April 2023+)
|
|
806
|
+
* - `client.lighter` - Lighter.xyz perpetuals
|
|
807
|
+
*
|
|
728
808
|
* @example
|
|
729
809
|
* ```typescript
|
|
730
810
|
* import { OxArchive } from '@0xarchive/sdk';
|
|
731
811
|
*
|
|
732
812
|
* const client = new OxArchive({ apiKey: 'ox_your_api_key' });
|
|
733
813
|
*
|
|
734
|
-
* //
|
|
735
|
-
* const
|
|
736
|
-
* console.log(`BTC mid price: ${
|
|
814
|
+
* // Hyperliquid data
|
|
815
|
+
* const hlOrderbook = await client.hyperliquid.orderbook.get('BTC');
|
|
816
|
+
* console.log(`BTC mid price: ${hlOrderbook.mid_price}`);
|
|
817
|
+
*
|
|
818
|
+
* // Lighter.xyz data
|
|
819
|
+
* const lighterOrderbook = await client.lighter.orderbook.get('BTC');
|
|
737
820
|
*
|
|
738
821
|
* // Get historical data
|
|
739
|
-
* const history = await client.orderbook.history('ETH', {
|
|
822
|
+
* const history = await client.hyperliquid.orderbook.history('ETH', {
|
|
740
823
|
* start: Date.now() - 86400000,
|
|
741
824
|
* end: Date.now(),
|
|
742
825
|
* limit: 100
|
|
743
826
|
* });
|
|
744
827
|
*
|
|
745
828
|
* // List all instruments
|
|
746
|
-
* const instruments = await client.instruments.list();
|
|
829
|
+
* const instruments = await client.hyperliquid.instruments.list();
|
|
830
|
+
* ```
|
|
831
|
+
*
|
|
832
|
+
* Legacy usage (deprecated, will be removed in v2.0):
|
|
833
|
+
* ```typescript
|
|
834
|
+
* // These still work but use client.hyperliquid.* instead
|
|
835
|
+
* const orderbook = await client.orderbook.get('BTC'); // deprecated
|
|
747
836
|
* ```
|
|
748
837
|
*/
|
|
749
838
|
declare class OxArchive {
|
|
750
839
|
private http;
|
|
751
840
|
/**
|
|
752
|
-
*
|
|
841
|
+
* Hyperliquid exchange data (orderbook, trades, funding, OI from April 2023)
|
|
842
|
+
*/
|
|
843
|
+
readonly hyperliquid: HyperliquidClient;
|
|
844
|
+
/**
|
|
845
|
+
* Lighter.xyz exchange data (August 2025+)
|
|
846
|
+
*/
|
|
847
|
+
readonly lighter: LighterClient;
|
|
848
|
+
/**
|
|
849
|
+
* @deprecated Use client.hyperliquid.orderbook instead
|
|
753
850
|
*/
|
|
754
851
|
readonly orderbook: OrderBookResource;
|
|
755
852
|
/**
|
|
756
|
-
*
|
|
853
|
+
* @deprecated Use client.hyperliquid.trades instead
|
|
757
854
|
*/
|
|
758
855
|
readonly trades: TradesResource;
|
|
759
856
|
/**
|
|
760
|
-
*
|
|
857
|
+
* @deprecated Use client.hyperliquid.instruments instead
|
|
761
858
|
*/
|
|
762
859
|
readonly instruments: InstrumentsResource;
|
|
763
860
|
/**
|
|
764
|
-
*
|
|
861
|
+
* @deprecated Use client.hyperliquid.funding instead
|
|
765
862
|
*/
|
|
766
863
|
readonly funding: FundingResource;
|
|
767
864
|
/**
|
|
768
|
-
*
|
|
865
|
+
* @deprecated Use client.hyperliquid.openInterest instead
|
|
769
866
|
*/
|
|
770
867
|
readonly openInterest: OpenInterestResource;
|
|
771
868
|
/**
|
|
@@ -2586,4 +2683,4 @@ type ValidatedFundingRate = z.infer<typeof FundingRateSchema>;
|
|
|
2586
2683
|
type ValidatedOpenInterest = z.infer<typeof OpenInterestSchema>;
|
|
2587
2684
|
type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
|
|
2588
2685
|
|
|
2589
|
-
export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type ClientOptions, type CursorResponse, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, 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 };
|
|
2686
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -485,7 +485,8 @@ declare class HttpClient {
|
|
|
485
485
|
*/
|
|
486
486
|
declare class OrderBookResource {
|
|
487
487
|
private http;
|
|
488
|
-
|
|
488
|
+
private basePath;
|
|
489
|
+
constructor(http: HttpClient, basePath?: string);
|
|
489
490
|
/**
|
|
490
491
|
* Get order book snapshot for a coin
|
|
491
492
|
*
|
|
@@ -554,7 +555,8 @@ declare class OrderBookResource {
|
|
|
554
555
|
*/
|
|
555
556
|
declare class TradesResource {
|
|
556
557
|
private http;
|
|
557
|
-
|
|
558
|
+
private basePath;
|
|
559
|
+
constructor(http: HttpClient, basePath?: string);
|
|
558
560
|
/**
|
|
559
561
|
* Get trade history for a coin using cursor-based pagination
|
|
560
562
|
*
|
|
@@ -610,7 +612,8 @@ declare class TradesResource {
|
|
|
610
612
|
*/
|
|
611
613
|
declare class InstrumentsResource {
|
|
612
614
|
private http;
|
|
613
|
-
|
|
615
|
+
private basePath;
|
|
616
|
+
constructor(http: HttpClient, basePath?: string);
|
|
614
617
|
/**
|
|
615
618
|
* List all available trading instruments
|
|
616
619
|
*
|
|
@@ -656,7 +659,8 @@ declare class InstrumentsResource {
|
|
|
656
659
|
*/
|
|
657
660
|
declare class FundingResource {
|
|
658
661
|
private http;
|
|
659
|
-
|
|
662
|
+
private basePath;
|
|
663
|
+
constructor(http: HttpClient, basePath?: string);
|
|
660
664
|
/**
|
|
661
665
|
* Get funding rate history for a coin with cursor-based pagination
|
|
662
666
|
*
|
|
@@ -704,7 +708,8 @@ declare class FundingResource {
|
|
|
704
708
|
*/
|
|
705
709
|
declare class OpenInterestResource {
|
|
706
710
|
private http;
|
|
707
|
-
|
|
711
|
+
private basePath;
|
|
712
|
+
constructor(http: HttpClient, basePath?: string);
|
|
708
713
|
/**
|
|
709
714
|
* Get open interest history for a coin with cursor-based pagination
|
|
710
715
|
*
|
|
@@ -722,50 +727,142 @@ declare class OpenInterestResource {
|
|
|
722
727
|
current(coin: string): Promise<OpenInterest>;
|
|
723
728
|
}
|
|
724
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
|
+
*
|
|
770
|
+
* @example
|
|
771
|
+
* ```typescript
|
|
772
|
+
* const client = new OxArchive({ apiKey: '...' });
|
|
773
|
+
* const orderbook = await client.lighter.orderbook.get('BTC');
|
|
774
|
+
* const trades = await client.lighter.trades.list('ETH', { start, end });
|
|
775
|
+
* ```
|
|
776
|
+
*/
|
|
777
|
+
declare class LighterClient {
|
|
778
|
+
/**
|
|
779
|
+
* Order book data (L2 snapshots)
|
|
780
|
+
*/
|
|
781
|
+
readonly orderbook: OrderBookResource;
|
|
782
|
+
/**
|
|
783
|
+
* Trade/fill history
|
|
784
|
+
*/
|
|
785
|
+
readonly trades: TradesResource;
|
|
786
|
+
/**
|
|
787
|
+
* Trading instruments metadata
|
|
788
|
+
*/
|
|
789
|
+
readonly instruments: InstrumentsResource;
|
|
790
|
+
/**
|
|
791
|
+
* Funding rates
|
|
792
|
+
*/
|
|
793
|
+
readonly funding: FundingResource;
|
|
794
|
+
/**
|
|
795
|
+
* Open interest
|
|
796
|
+
*/
|
|
797
|
+
readonly openInterest: OpenInterestResource;
|
|
798
|
+
constructor(http: HttpClient);
|
|
799
|
+
}
|
|
800
|
+
|
|
725
801
|
/**
|
|
726
802
|
* 0xarchive API client
|
|
727
803
|
*
|
|
804
|
+
* Supports multiple exchanges:
|
|
805
|
+
* - `client.hyperliquid` - Hyperliquid perpetuals (April 2023+)
|
|
806
|
+
* - `client.lighter` - Lighter.xyz perpetuals
|
|
807
|
+
*
|
|
728
808
|
* @example
|
|
729
809
|
* ```typescript
|
|
730
810
|
* import { OxArchive } from '@0xarchive/sdk';
|
|
731
811
|
*
|
|
732
812
|
* const client = new OxArchive({ apiKey: 'ox_your_api_key' });
|
|
733
813
|
*
|
|
734
|
-
* //
|
|
735
|
-
* const
|
|
736
|
-
* console.log(`BTC mid price: ${
|
|
814
|
+
* // Hyperliquid data
|
|
815
|
+
* const hlOrderbook = await client.hyperliquid.orderbook.get('BTC');
|
|
816
|
+
* console.log(`BTC mid price: ${hlOrderbook.mid_price}`);
|
|
817
|
+
*
|
|
818
|
+
* // Lighter.xyz data
|
|
819
|
+
* const lighterOrderbook = await client.lighter.orderbook.get('BTC');
|
|
737
820
|
*
|
|
738
821
|
* // Get historical data
|
|
739
|
-
* const history = await client.orderbook.history('ETH', {
|
|
822
|
+
* const history = await client.hyperliquid.orderbook.history('ETH', {
|
|
740
823
|
* start: Date.now() - 86400000,
|
|
741
824
|
* end: Date.now(),
|
|
742
825
|
* limit: 100
|
|
743
826
|
* });
|
|
744
827
|
*
|
|
745
828
|
* // List all instruments
|
|
746
|
-
* const instruments = await client.instruments.list();
|
|
829
|
+
* const instruments = await client.hyperliquid.instruments.list();
|
|
830
|
+
* ```
|
|
831
|
+
*
|
|
832
|
+
* Legacy usage (deprecated, will be removed in v2.0):
|
|
833
|
+
* ```typescript
|
|
834
|
+
* // These still work but use client.hyperliquid.* instead
|
|
835
|
+
* const orderbook = await client.orderbook.get('BTC'); // deprecated
|
|
747
836
|
* ```
|
|
748
837
|
*/
|
|
749
838
|
declare class OxArchive {
|
|
750
839
|
private http;
|
|
751
840
|
/**
|
|
752
|
-
*
|
|
841
|
+
* Hyperliquid exchange data (orderbook, trades, funding, OI from April 2023)
|
|
842
|
+
*/
|
|
843
|
+
readonly hyperliquid: HyperliquidClient;
|
|
844
|
+
/**
|
|
845
|
+
* Lighter.xyz exchange data (August 2025+)
|
|
846
|
+
*/
|
|
847
|
+
readonly lighter: LighterClient;
|
|
848
|
+
/**
|
|
849
|
+
* @deprecated Use client.hyperliquid.orderbook instead
|
|
753
850
|
*/
|
|
754
851
|
readonly orderbook: OrderBookResource;
|
|
755
852
|
/**
|
|
756
|
-
*
|
|
853
|
+
* @deprecated Use client.hyperliquid.trades instead
|
|
757
854
|
*/
|
|
758
855
|
readonly trades: TradesResource;
|
|
759
856
|
/**
|
|
760
|
-
*
|
|
857
|
+
* @deprecated Use client.hyperliquid.instruments instead
|
|
761
858
|
*/
|
|
762
859
|
readonly instruments: InstrumentsResource;
|
|
763
860
|
/**
|
|
764
|
-
*
|
|
861
|
+
* @deprecated Use client.hyperliquid.funding instead
|
|
765
862
|
*/
|
|
766
863
|
readonly funding: FundingResource;
|
|
767
864
|
/**
|
|
768
|
-
*
|
|
865
|
+
* @deprecated Use client.hyperliquid.openInterest instead
|
|
769
866
|
*/
|
|
770
867
|
readonly openInterest: OpenInterestResource;
|
|
771
868
|
/**
|
|
@@ -2586,4 +2683,4 @@ type ValidatedFundingRate = z.infer<typeof FundingRateSchema>;
|
|
|
2586
2683
|
type ValidatedOpenInterest = z.infer<typeof OpenInterestSchema>;
|
|
2587
2684
|
type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
|
|
2588
2685
|
|
|
2589
|
-
export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type ClientOptions, type CursorResponse, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, type Instrument, InstrumentArrayResponseSchema, InstrumentResponseSchema, InstrumentSchema, type InstrumentType, InstrumentTypeSchema, 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 };
|
|
2686
|
+
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 };
|