@0xarchive/sdk 0.3.9 → 0.3.11
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/dist/index.d.mts +90 -82
- package/dist/index.d.ts +90 -82
- package/dist/index.js +41 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -41
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 */
|
|
@@ -512,13 +495,33 @@ declare class OrderBookResource {
|
|
|
512
495
|
*/
|
|
513
496
|
get(coin: string, params?: GetOrderBookParams): Promise<OrderBook>;
|
|
514
497
|
/**
|
|
515
|
-
* Get historical order book snapshots
|
|
498
|
+
* Get historical order book snapshots with cursor-based pagination
|
|
516
499
|
*
|
|
517
500
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
518
|
-
* @param params - Time range and pagination parameters (start
|
|
519
|
-
* @returns
|
|
501
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
502
|
+
* @returns CursorResponse with order book snapshots and nextCursor for pagination
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* // First page
|
|
507
|
+
* let result = await client.orderbook.history('BTC', {
|
|
508
|
+
* start: Date.now() - 86400000,
|
|
509
|
+
* end: Date.now(),
|
|
510
|
+
* limit: 1000
|
|
511
|
+
* });
|
|
512
|
+
*
|
|
513
|
+
* // Subsequent pages
|
|
514
|
+
* while (result.nextCursor) {
|
|
515
|
+
* result = await client.orderbook.history('BTC', {
|
|
516
|
+
* start: Date.now() - 86400000,
|
|
517
|
+
* end: Date.now(),
|
|
518
|
+
* cursor: result.nextCursor,
|
|
519
|
+
* limit: 1000
|
|
520
|
+
* });
|
|
521
|
+
* }
|
|
522
|
+
* ```
|
|
520
523
|
*/
|
|
521
|
-
history(coin: string, params: OrderBookHistoryParams): Promise<OrderBook[]
|
|
524
|
+
history(coin: string, params: OrderBookHistoryParams): Promise<CursorResponse<OrderBook[]>>;
|
|
522
525
|
}
|
|
523
526
|
|
|
524
527
|
/**
|
|
@@ -591,26 +594,6 @@ declare class TradesResource {
|
|
|
591
594
|
* @returns Array of recent trades
|
|
592
595
|
*/
|
|
593
596
|
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
597
|
}
|
|
615
598
|
|
|
616
599
|
/**
|
|
@@ -651,24 +634,37 @@ declare class InstrumentsResource {
|
|
|
651
634
|
* // Get current funding rate
|
|
652
635
|
* const current = await client.funding.current('BTC');
|
|
653
636
|
*
|
|
654
|
-
* // Get funding rate history
|
|
655
|
-
*
|
|
637
|
+
* // Get funding rate history with cursor-based pagination
|
|
638
|
+
* let result = await client.funding.history('ETH', {
|
|
656
639
|
* start: Date.now() - 86400000 * 7,
|
|
657
|
-
* end: Date.now()
|
|
640
|
+
* end: Date.now(),
|
|
641
|
+
* limit: 1000
|
|
658
642
|
* });
|
|
643
|
+
*
|
|
644
|
+
* // Get all pages
|
|
645
|
+
* const allRates = [...result.data];
|
|
646
|
+
* while (result.nextCursor) {
|
|
647
|
+
* result = await client.funding.history('ETH', {
|
|
648
|
+
* start: Date.now() - 86400000 * 7,
|
|
649
|
+
* end: Date.now(),
|
|
650
|
+
* cursor: result.nextCursor,
|
|
651
|
+
* limit: 1000
|
|
652
|
+
* });
|
|
653
|
+
* allRates.push(...result.data);
|
|
654
|
+
* }
|
|
659
655
|
* ```
|
|
660
656
|
*/
|
|
661
657
|
declare class FundingResource {
|
|
662
658
|
private http;
|
|
663
659
|
constructor(http: HttpClient);
|
|
664
660
|
/**
|
|
665
|
-
* Get funding rate history for a coin
|
|
661
|
+
* Get funding rate history for a coin with cursor-based pagination
|
|
666
662
|
*
|
|
667
663
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
668
|
-
* @param params - Time range and pagination parameters (start
|
|
669
|
-
* @returns
|
|
664
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
665
|
+
* @returns CursorResponse with funding rate records and nextCursor for pagination
|
|
670
666
|
*/
|
|
671
|
-
history(coin: string, params:
|
|
667
|
+
history(coin: string, params: FundingHistoryParams): Promise<CursorResponse<FundingRate[]>>;
|
|
672
668
|
/**
|
|
673
669
|
* Get current funding rate for a coin
|
|
674
670
|
*
|
|
@@ -686,25 +682,37 @@ declare class FundingResource {
|
|
|
686
682
|
* // Get current open interest
|
|
687
683
|
* const current = await client.openInterest.current('BTC');
|
|
688
684
|
*
|
|
689
|
-
* // Get open interest history
|
|
690
|
-
*
|
|
685
|
+
* // Get open interest history with cursor-based pagination
|
|
686
|
+
* let result = await client.openInterest.history('ETH', {
|
|
691
687
|
* start: Date.now() - 86400000,
|
|
692
688
|
* end: Date.now(),
|
|
693
|
-
* limit:
|
|
689
|
+
* limit: 1000
|
|
694
690
|
* });
|
|
691
|
+
*
|
|
692
|
+
* // Get all pages
|
|
693
|
+
* const allRecords = [...result.data];
|
|
694
|
+
* while (result.nextCursor) {
|
|
695
|
+
* result = await client.openInterest.history('ETH', {
|
|
696
|
+
* start: Date.now() - 86400000,
|
|
697
|
+
* end: Date.now(),
|
|
698
|
+
* cursor: result.nextCursor,
|
|
699
|
+
* limit: 1000
|
|
700
|
+
* });
|
|
701
|
+
* allRecords.push(...result.data);
|
|
702
|
+
* }
|
|
695
703
|
* ```
|
|
696
704
|
*/
|
|
697
705
|
declare class OpenInterestResource {
|
|
698
706
|
private http;
|
|
699
707
|
constructor(http: HttpClient);
|
|
700
708
|
/**
|
|
701
|
-
* Get open interest history for a coin
|
|
709
|
+
* Get open interest history for a coin with cursor-based pagination
|
|
702
710
|
*
|
|
703
711
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
704
|
-
* @param params - Time range and pagination parameters (start
|
|
705
|
-
* @returns
|
|
712
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
713
|
+
* @returns CursorResponse with open interest records and nextCursor for pagination
|
|
706
714
|
*/
|
|
707
|
-
history(coin: string, params:
|
|
715
|
+
history(coin: string, params: OpenInterestHistoryParams): Promise<CursorResponse<OpenInterest[]>>;
|
|
708
716
|
/**
|
|
709
717
|
* Get current open interest for a coin
|
|
710
718
|
*
|
|
@@ -1374,18 +1382,18 @@ declare const WsReplayStartedSchema: z.ZodObject<{
|
|
|
1374
1382
|
end: z.ZodNumber;
|
|
1375
1383
|
speed: z.ZodNumber;
|
|
1376
1384
|
}, "strip", z.ZodTypeAny, {
|
|
1377
|
-
start: number;
|
|
1378
|
-
end: number;
|
|
1379
1385
|
type: "replay_started";
|
|
1380
1386
|
coin: string;
|
|
1381
1387
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1382
|
-
speed: number;
|
|
1383
|
-
}, {
|
|
1384
1388
|
start: number;
|
|
1385
1389
|
end: number;
|
|
1390
|
+
speed: number;
|
|
1391
|
+
}, {
|
|
1386
1392
|
type: "replay_started";
|
|
1387
1393
|
coin: string;
|
|
1388
1394
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1395
|
+
start: number;
|
|
1396
|
+
end: number;
|
|
1389
1397
|
speed: number;
|
|
1390
1398
|
}>;
|
|
1391
1399
|
declare const WsReplayPausedSchema: z.ZodObject<{
|
|
@@ -1457,17 +1465,17 @@ declare const WsStreamStartedSchema: z.ZodObject<{
|
|
|
1457
1465
|
start: z.ZodNumber;
|
|
1458
1466
|
end: z.ZodNumber;
|
|
1459
1467
|
}, "strip", z.ZodTypeAny, {
|
|
1460
|
-
start: number;
|
|
1461
|
-
end: number;
|
|
1462
1468
|
type: "stream_started";
|
|
1463
1469
|
coin: string;
|
|
1464
1470
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1465
|
-
}, {
|
|
1466
1471
|
start: number;
|
|
1467
1472
|
end: number;
|
|
1473
|
+
}, {
|
|
1468
1474
|
type: "stream_started";
|
|
1469
1475
|
coin: string;
|
|
1470
1476
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1477
|
+
start: number;
|
|
1478
|
+
end: number;
|
|
1471
1479
|
}>;
|
|
1472
1480
|
declare const WsStreamProgressSchema: z.ZodObject<{
|
|
1473
1481
|
type: z.ZodLiteral<"stream_progress">;
|
|
@@ -1608,18 +1616,18 @@ declare const WsServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
|
1608
1616
|
end: z.ZodNumber;
|
|
1609
1617
|
speed: z.ZodNumber;
|
|
1610
1618
|
}, "strip", z.ZodTypeAny, {
|
|
1611
|
-
start: number;
|
|
1612
|
-
end: number;
|
|
1613
1619
|
type: "replay_started";
|
|
1614
1620
|
coin: string;
|
|
1615
1621
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1616
|
-
speed: number;
|
|
1617
|
-
}, {
|
|
1618
1622
|
start: number;
|
|
1619
1623
|
end: number;
|
|
1624
|
+
speed: number;
|
|
1625
|
+
}, {
|
|
1620
1626
|
type: "replay_started";
|
|
1621
1627
|
coin: string;
|
|
1622
1628
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1629
|
+
start: number;
|
|
1630
|
+
end: number;
|
|
1623
1631
|
speed: number;
|
|
1624
1632
|
}>, z.ZodObject<{
|
|
1625
1633
|
type: z.ZodLiteral<"replay_paused">;
|
|
@@ -1685,17 +1693,17 @@ declare const WsServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
|
1685
1693
|
start: z.ZodNumber;
|
|
1686
1694
|
end: z.ZodNumber;
|
|
1687
1695
|
}, "strip", z.ZodTypeAny, {
|
|
1688
|
-
start: number;
|
|
1689
|
-
end: number;
|
|
1690
1696
|
type: "stream_started";
|
|
1691
1697
|
coin: string;
|
|
1692
1698
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1693
|
-
}, {
|
|
1694
1699
|
start: number;
|
|
1695
1700
|
end: number;
|
|
1701
|
+
}, {
|
|
1696
1702
|
type: "stream_started";
|
|
1697
1703
|
coin: string;
|
|
1698
1704
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1705
|
+
start: number;
|
|
1706
|
+
end: number;
|
|
1699
1707
|
}>, z.ZodObject<{
|
|
1700
1708
|
type: z.ZodLiteral<"stream_progress">;
|
|
1701
1709
|
snapshotsSent: z.ZodNumber;
|
|
@@ -2578,4 +2586,4 @@ type ValidatedFundingRate = z.infer<typeof FundingRateSchema>;
|
|
|
2578
2586
|
type ValidatedOpenInterest = z.infer<typeof OpenInterestSchema>;
|
|
2579
2587
|
type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
|
|
2580
2588
|
|
|
2581
|
-
export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type ClientOptions, type CursorResponse, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, type
|
|
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 };
|
package/dist/index.d.ts
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 */
|
|
@@ -512,13 +495,33 @@ declare class OrderBookResource {
|
|
|
512
495
|
*/
|
|
513
496
|
get(coin: string, params?: GetOrderBookParams): Promise<OrderBook>;
|
|
514
497
|
/**
|
|
515
|
-
* Get historical order book snapshots
|
|
498
|
+
* Get historical order book snapshots with cursor-based pagination
|
|
516
499
|
*
|
|
517
500
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
518
|
-
* @param params - Time range and pagination parameters (start
|
|
519
|
-
* @returns
|
|
501
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
502
|
+
* @returns CursorResponse with order book snapshots and nextCursor for pagination
|
|
503
|
+
*
|
|
504
|
+
* @example
|
|
505
|
+
* ```typescript
|
|
506
|
+
* // First page
|
|
507
|
+
* let result = await client.orderbook.history('BTC', {
|
|
508
|
+
* start: Date.now() - 86400000,
|
|
509
|
+
* end: Date.now(),
|
|
510
|
+
* limit: 1000
|
|
511
|
+
* });
|
|
512
|
+
*
|
|
513
|
+
* // Subsequent pages
|
|
514
|
+
* while (result.nextCursor) {
|
|
515
|
+
* result = await client.orderbook.history('BTC', {
|
|
516
|
+
* start: Date.now() - 86400000,
|
|
517
|
+
* end: Date.now(),
|
|
518
|
+
* cursor: result.nextCursor,
|
|
519
|
+
* limit: 1000
|
|
520
|
+
* });
|
|
521
|
+
* }
|
|
522
|
+
* ```
|
|
520
523
|
*/
|
|
521
|
-
history(coin: string, params: OrderBookHistoryParams): Promise<OrderBook[]
|
|
524
|
+
history(coin: string, params: OrderBookHistoryParams): Promise<CursorResponse<OrderBook[]>>;
|
|
522
525
|
}
|
|
523
526
|
|
|
524
527
|
/**
|
|
@@ -591,26 +594,6 @@ declare class TradesResource {
|
|
|
591
594
|
* @returns Array of recent trades
|
|
592
595
|
*/
|
|
593
596
|
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
597
|
}
|
|
615
598
|
|
|
616
599
|
/**
|
|
@@ -651,24 +634,37 @@ declare class InstrumentsResource {
|
|
|
651
634
|
* // Get current funding rate
|
|
652
635
|
* const current = await client.funding.current('BTC');
|
|
653
636
|
*
|
|
654
|
-
* // Get funding rate history
|
|
655
|
-
*
|
|
637
|
+
* // Get funding rate history with cursor-based pagination
|
|
638
|
+
* let result = await client.funding.history('ETH', {
|
|
656
639
|
* start: Date.now() - 86400000 * 7,
|
|
657
|
-
* end: Date.now()
|
|
640
|
+
* end: Date.now(),
|
|
641
|
+
* limit: 1000
|
|
658
642
|
* });
|
|
643
|
+
*
|
|
644
|
+
* // Get all pages
|
|
645
|
+
* const allRates = [...result.data];
|
|
646
|
+
* while (result.nextCursor) {
|
|
647
|
+
* result = await client.funding.history('ETH', {
|
|
648
|
+
* start: Date.now() - 86400000 * 7,
|
|
649
|
+
* end: Date.now(),
|
|
650
|
+
* cursor: result.nextCursor,
|
|
651
|
+
* limit: 1000
|
|
652
|
+
* });
|
|
653
|
+
* allRates.push(...result.data);
|
|
654
|
+
* }
|
|
659
655
|
* ```
|
|
660
656
|
*/
|
|
661
657
|
declare class FundingResource {
|
|
662
658
|
private http;
|
|
663
659
|
constructor(http: HttpClient);
|
|
664
660
|
/**
|
|
665
|
-
* Get funding rate history for a coin
|
|
661
|
+
* Get funding rate history for a coin with cursor-based pagination
|
|
666
662
|
*
|
|
667
663
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
668
|
-
* @param params - Time range and pagination parameters (start
|
|
669
|
-
* @returns
|
|
664
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
665
|
+
* @returns CursorResponse with funding rate records and nextCursor for pagination
|
|
670
666
|
*/
|
|
671
|
-
history(coin: string, params:
|
|
667
|
+
history(coin: string, params: FundingHistoryParams): Promise<CursorResponse<FundingRate[]>>;
|
|
672
668
|
/**
|
|
673
669
|
* Get current funding rate for a coin
|
|
674
670
|
*
|
|
@@ -686,25 +682,37 @@ declare class FundingResource {
|
|
|
686
682
|
* // Get current open interest
|
|
687
683
|
* const current = await client.openInterest.current('BTC');
|
|
688
684
|
*
|
|
689
|
-
* // Get open interest history
|
|
690
|
-
*
|
|
685
|
+
* // Get open interest history with cursor-based pagination
|
|
686
|
+
* let result = await client.openInterest.history('ETH', {
|
|
691
687
|
* start: Date.now() - 86400000,
|
|
692
688
|
* end: Date.now(),
|
|
693
|
-
* limit:
|
|
689
|
+
* limit: 1000
|
|
694
690
|
* });
|
|
691
|
+
*
|
|
692
|
+
* // Get all pages
|
|
693
|
+
* const allRecords = [...result.data];
|
|
694
|
+
* while (result.nextCursor) {
|
|
695
|
+
* result = await client.openInterest.history('ETH', {
|
|
696
|
+
* start: Date.now() - 86400000,
|
|
697
|
+
* end: Date.now(),
|
|
698
|
+
* cursor: result.nextCursor,
|
|
699
|
+
* limit: 1000
|
|
700
|
+
* });
|
|
701
|
+
* allRecords.push(...result.data);
|
|
702
|
+
* }
|
|
695
703
|
* ```
|
|
696
704
|
*/
|
|
697
705
|
declare class OpenInterestResource {
|
|
698
706
|
private http;
|
|
699
707
|
constructor(http: HttpClient);
|
|
700
708
|
/**
|
|
701
|
-
* Get open interest history for a coin
|
|
709
|
+
* Get open interest history for a coin with cursor-based pagination
|
|
702
710
|
*
|
|
703
711
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
704
|
-
* @param params - Time range and pagination parameters (start
|
|
705
|
-
* @returns
|
|
712
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
713
|
+
* @returns CursorResponse with open interest records and nextCursor for pagination
|
|
706
714
|
*/
|
|
707
|
-
history(coin: string, params:
|
|
715
|
+
history(coin: string, params: OpenInterestHistoryParams): Promise<CursorResponse<OpenInterest[]>>;
|
|
708
716
|
/**
|
|
709
717
|
* Get current open interest for a coin
|
|
710
718
|
*
|
|
@@ -1374,18 +1382,18 @@ declare const WsReplayStartedSchema: z.ZodObject<{
|
|
|
1374
1382
|
end: z.ZodNumber;
|
|
1375
1383
|
speed: z.ZodNumber;
|
|
1376
1384
|
}, "strip", z.ZodTypeAny, {
|
|
1377
|
-
start: number;
|
|
1378
|
-
end: number;
|
|
1379
1385
|
type: "replay_started";
|
|
1380
1386
|
coin: string;
|
|
1381
1387
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1382
|
-
speed: number;
|
|
1383
|
-
}, {
|
|
1384
1388
|
start: number;
|
|
1385
1389
|
end: number;
|
|
1390
|
+
speed: number;
|
|
1391
|
+
}, {
|
|
1386
1392
|
type: "replay_started";
|
|
1387
1393
|
coin: string;
|
|
1388
1394
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1395
|
+
start: number;
|
|
1396
|
+
end: number;
|
|
1389
1397
|
speed: number;
|
|
1390
1398
|
}>;
|
|
1391
1399
|
declare const WsReplayPausedSchema: z.ZodObject<{
|
|
@@ -1457,17 +1465,17 @@ declare const WsStreamStartedSchema: z.ZodObject<{
|
|
|
1457
1465
|
start: z.ZodNumber;
|
|
1458
1466
|
end: z.ZodNumber;
|
|
1459
1467
|
}, "strip", z.ZodTypeAny, {
|
|
1460
|
-
start: number;
|
|
1461
|
-
end: number;
|
|
1462
1468
|
type: "stream_started";
|
|
1463
1469
|
coin: string;
|
|
1464
1470
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1465
|
-
}, {
|
|
1466
1471
|
start: number;
|
|
1467
1472
|
end: number;
|
|
1473
|
+
}, {
|
|
1468
1474
|
type: "stream_started";
|
|
1469
1475
|
coin: string;
|
|
1470
1476
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1477
|
+
start: number;
|
|
1478
|
+
end: number;
|
|
1471
1479
|
}>;
|
|
1472
1480
|
declare const WsStreamProgressSchema: z.ZodObject<{
|
|
1473
1481
|
type: z.ZodLiteral<"stream_progress">;
|
|
@@ -1608,18 +1616,18 @@ declare const WsServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
|
1608
1616
|
end: z.ZodNumber;
|
|
1609
1617
|
speed: z.ZodNumber;
|
|
1610
1618
|
}, "strip", z.ZodTypeAny, {
|
|
1611
|
-
start: number;
|
|
1612
|
-
end: number;
|
|
1613
1619
|
type: "replay_started";
|
|
1614
1620
|
coin: string;
|
|
1615
1621
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1616
|
-
speed: number;
|
|
1617
|
-
}, {
|
|
1618
1622
|
start: number;
|
|
1619
1623
|
end: number;
|
|
1624
|
+
speed: number;
|
|
1625
|
+
}, {
|
|
1620
1626
|
type: "replay_started";
|
|
1621
1627
|
coin: string;
|
|
1622
1628
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1629
|
+
start: number;
|
|
1630
|
+
end: number;
|
|
1623
1631
|
speed: number;
|
|
1624
1632
|
}>, z.ZodObject<{
|
|
1625
1633
|
type: z.ZodLiteral<"replay_paused">;
|
|
@@ -1685,17 +1693,17 @@ declare const WsServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObjec
|
|
|
1685
1693
|
start: z.ZodNumber;
|
|
1686
1694
|
end: z.ZodNumber;
|
|
1687
1695
|
}, "strip", z.ZodTypeAny, {
|
|
1688
|
-
start: number;
|
|
1689
|
-
end: number;
|
|
1690
1696
|
type: "stream_started";
|
|
1691
1697
|
coin: string;
|
|
1692
1698
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1693
|
-
}, {
|
|
1694
1699
|
start: number;
|
|
1695
1700
|
end: number;
|
|
1701
|
+
}, {
|
|
1696
1702
|
type: "stream_started";
|
|
1697
1703
|
coin: string;
|
|
1698
1704
|
channel: "orderbook" | "trades" | "ticker" | "all_tickers";
|
|
1705
|
+
start: number;
|
|
1706
|
+
end: number;
|
|
1699
1707
|
}>, z.ZodObject<{
|
|
1700
1708
|
type: z.ZodLiteral<"stream_progress">;
|
|
1701
1709
|
snapshotsSent: z.ZodNumber;
|
|
@@ -2578,4 +2586,4 @@ type ValidatedFundingRate = z.infer<typeof FundingRateSchema>;
|
|
|
2578
2586
|
type ValidatedOpenInterest = z.infer<typeof OpenInterestSchema>;
|
|
2579
2587
|
type ValidatedWsServerMessage = z.infer<typeof WsServerMessageSchema>;
|
|
2580
2588
|
|
|
2581
|
-
export { type ApiError, type ApiMeta, ApiMetaSchema, type ApiResponse, ApiResponseSchema, type ClientOptions, type CursorResponse, type FundingRate, FundingRateArrayResponseSchema, FundingRateResponseSchema, FundingRateSchema, type GetOrderBookParams, type GetTradesCursorParams, type
|
|
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 };
|