@0xarchive/sdk 0.3.11 → 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 +114 -16
- package/dist/index.d.ts +114 -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 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
|
@@ -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,143 @@ 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
|
+
* 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
|
+
|
|
725
802
|
/**
|
|
726
803
|
* 0xarchive API client
|
|
727
804
|
*
|
|
805
|
+
* Supports multiple exchanges:
|
|
806
|
+
* - `client.hyperliquid` - Hyperliquid perpetuals (April 2023+)
|
|
807
|
+
* - `client.lighter` - Lighter.xyz perpetuals
|
|
808
|
+
*
|
|
728
809
|
* @example
|
|
729
810
|
* ```typescript
|
|
730
811
|
* import { OxArchive } from '@0xarchive/sdk';
|
|
731
812
|
*
|
|
732
813
|
* const client = new OxArchive({ apiKey: 'ox_your_api_key' });
|
|
733
814
|
*
|
|
734
|
-
* //
|
|
735
|
-
* const
|
|
736
|
-
* 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');
|
|
737
821
|
*
|
|
738
822
|
* // Get historical data
|
|
739
|
-
* const history = await client.orderbook.history('ETH', {
|
|
823
|
+
* const history = await client.hyperliquid.orderbook.history('ETH', {
|
|
740
824
|
* start: Date.now() - 86400000,
|
|
741
825
|
* end: Date.now(),
|
|
742
826
|
* limit: 100
|
|
743
827
|
* });
|
|
744
828
|
*
|
|
745
829
|
* // List all instruments
|
|
746
|
-
* 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
|
|
747
837
|
* ```
|
|
748
838
|
*/
|
|
749
839
|
declare class OxArchive {
|
|
750
840
|
private http;
|
|
751
841
|
/**
|
|
752
|
-
*
|
|
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
|
|
753
851
|
*/
|
|
754
852
|
readonly orderbook: OrderBookResource;
|
|
755
853
|
/**
|
|
756
|
-
*
|
|
854
|
+
* @deprecated Use client.hyperliquid.trades instead
|
|
757
855
|
*/
|
|
758
856
|
readonly trades: TradesResource;
|
|
759
857
|
/**
|
|
760
|
-
*
|
|
858
|
+
* @deprecated Use client.hyperliquid.instruments instead
|
|
761
859
|
*/
|
|
762
860
|
readonly instruments: InstrumentsResource;
|
|
763
861
|
/**
|
|
764
|
-
*
|
|
862
|
+
* @deprecated Use client.hyperliquid.funding instead
|
|
765
863
|
*/
|
|
766
864
|
readonly funding: FundingResource;
|
|
767
865
|
/**
|
|
768
|
-
*
|
|
866
|
+
* @deprecated Use client.hyperliquid.openInterest instead
|
|
769
867
|
*/
|
|
770
868
|
readonly openInterest: OpenInterestResource;
|
|
771
869
|
/**
|
|
@@ -2586,4 +2684,4 @@ type ValidatedFundingRate = z.infer<typeof FundingRateSchema>;
|
|
|
2586
2684
|
type ValidatedOpenInterest = z.infer<typeof OpenInterestSchema>;
|
|
2587
2685
|
type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
|
|
2588
2686
|
|
|
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 };
|
|
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 };
|
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,143 @@ 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
|
+
* 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
|
+
|
|
725
802
|
/**
|
|
726
803
|
* 0xarchive API client
|
|
727
804
|
*
|
|
805
|
+
* Supports multiple exchanges:
|
|
806
|
+
* - `client.hyperliquid` - Hyperliquid perpetuals (April 2023+)
|
|
807
|
+
* - `client.lighter` - Lighter.xyz perpetuals
|
|
808
|
+
*
|
|
728
809
|
* @example
|
|
729
810
|
* ```typescript
|
|
730
811
|
* import { OxArchive } from '@0xarchive/sdk';
|
|
731
812
|
*
|
|
732
813
|
* const client = new OxArchive({ apiKey: 'ox_your_api_key' });
|
|
733
814
|
*
|
|
734
|
-
* //
|
|
735
|
-
* const
|
|
736
|
-
* 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');
|
|
737
821
|
*
|
|
738
822
|
* // Get historical data
|
|
739
|
-
* const history = await client.orderbook.history('ETH', {
|
|
823
|
+
* const history = await client.hyperliquid.orderbook.history('ETH', {
|
|
740
824
|
* start: Date.now() - 86400000,
|
|
741
825
|
* end: Date.now(),
|
|
742
826
|
* limit: 100
|
|
743
827
|
* });
|
|
744
828
|
*
|
|
745
829
|
* // List all instruments
|
|
746
|
-
* 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
|
|
747
837
|
* ```
|
|
748
838
|
*/
|
|
749
839
|
declare class OxArchive {
|
|
750
840
|
private http;
|
|
751
841
|
/**
|
|
752
|
-
*
|
|
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
|
|
753
851
|
*/
|
|
754
852
|
readonly orderbook: OrderBookResource;
|
|
755
853
|
/**
|
|
756
|
-
*
|
|
854
|
+
* @deprecated Use client.hyperliquid.trades instead
|
|
757
855
|
*/
|
|
758
856
|
readonly trades: TradesResource;
|
|
759
857
|
/**
|
|
760
|
-
*
|
|
858
|
+
* @deprecated Use client.hyperliquid.instruments instead
|
|
761
859
|
*/
|
|
762
860
|
readonly instruments: InstrumentsResource;
|
|
763
861
|
/**
|
|
764
|
-
*
|
|
862
|
+
* @deprecated Use client.hyperliquid.funding instead
|
|
765
863
|
*/
|
|
766
864
|
readonly funding: FundingResource;
|
|
767
865
|
/**
|
|
768
|
-
*
|
|
866
|
+
* @deprecated Use client.hyperliquid.openInterest instead
|
|
769
867
|
*/
|
|
770
868
|
readonly openInterest: OpenInterestResource;
|
|
771
869
|
/**
|
|
@@ -2586,4 +2684,4 @@ type ValidatedFundingRate = z.infer<typeof FundingRateSchema>;
|
|
|
2586
2684
|
type ValidatedOpenInterest = z.infer<typeof OpenInterestSchema>;
|
|
2587
2685
|
type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
|
|
2588
2686
|
|
|
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 };
|
|
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 };
|