@0xarchive/sdk 0.4.6 → 0.5.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/dist/index.js CHANGED
@@ -22,6 +22,9 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  ApiMetaSchema: () => ApiMetaSchema,
24
24
  ApiResponseSchema: () => ApiResponseSchema,
25
+ CandleArrayResponseSchema: () => CandleArrayResponseSchema,
26
+ CandleIntervalSchema: () => CandleIntervalSchema,
27
+ CandleSchema: () => CandleSchema,
25
28
  FundingRateArrayResponseSchema: () => FundingRateArrayResponseSchema,
26
29
  FundingRateResponseSchema: () => FundingRateResponseSchema,
27
30
  FundingRateSchema: () => FundingRateSchema,
@@ -262,7 +265,18 @@ var OpenInterestSchema = import_zod.z.object({
262
265
  impactBidPrice: import_zod.z.string().optional(),
263
266
  impactAskPrice: import_zod.z.string().optional()
264
267
  });
265
- var WsChannelSchema = import_zod.z.enum(["orderbook", "trades", "ticker", "all_tickers"]);
268
+ var CandleIntervalSchema = import_zod.z.enum(["1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w"]);
269
+ var CandleSchema = import_zod.z.object({
270
+ timestamp: import_zod.z.string(),
271
+ open: import_zod.z.number(),
272
+ high: import_zod.z.number(),
273
+ low: import_zod.z.number(),
274
+ close: import_zod.z.number(),
275
+ volume: import_zod.z.number(),
276
+ quoteVolume: import_zod.z.number().optional(),
277
+ tradeCount: import_zod.z.number().optional()
278
+ });
279
+ var WsChannelSchema = import_zod.z.enum(["orderbook", "trades", "candles", "ticker", "all_tickers"]);
266
280
  var WsConnectionStateSchema = import_zod.z.enum(["connecting", "connected", "disconnected", "reconnecting"]);
267
281
  var WsSubscribedSchema = import_zod.z.object({
268
282
  type: import_zod.z.literal("subscribed"),
@@ -377,6 +391,7 @@ var FundingRateResponseSchema = ApiResponseSchema(FundingRateSchema);
377
391
  var FundingRateArrayResponseSchema = ApiResponseSchema(import_zod.z.array(FundingRateSchema));
378
392
  var OpenInterestResponseSchema = ApiResponseSchema(OpenInterestSchema);
379
393
  var OpenInterestArrayResponseSchema = ApiResponseSchema(import_zod.z.array(OpenInterestSchema));
394
+ var CandleArrayResponseSchema = ApiResponseSchema(import_zod.z.array(CandleSchema));
380
395
 
381
396
  // src/resources/orderbook.ts
382
397
  var OrderBookResource = class {
@@ -647,6 +662,32 @@ var OpenInterestResource = class {
647
662
  }
648
663
  };
649
664
 
665
+ // src/resources/candles.ts
666
+ var CandlesResource = class {
667
+ constructor(http, basePath = "/v1") {
668
+ this.http = http;
669
+ this.basePath = basePath;
670
+ }
671
+ /**
672
+ * Get historical OHLCV candle data with cursor-based pagination
673
+ *
674
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
675
+ * @param params - Time range, interval, and cursor pagination parameters (start and end are required)
676
+ * @returns CursorResponse with candle records and nextCursor for pagination
677
+ */
678
+ async history(coin, params) {
679
+ const response = await this.http.get(
680
+ `${this.basePath}/candles/${coin.toUpperCase()}`,
681
+ params,
682
+ this.http.validationEnabled ? CandleArrayResponseSchema : void 0
683
+ );
684
+ return {
685
+ data: response.data,
686
+ nextCursor: response.meta.nextCursor
687
+ };
688
+ }
689
+ };
690
+
650
691
  // src/exchanges.ts
651
692
  var HyperliquidClient = class {
652
693
  /**
@@ -669,6 +710,10 @@ var HyperliquidClient = class {
669
710
  * Open interest
670
711
  */
671
712
  openInterest;
713
+ /**
714
+ * OHLCV candle data
715
+ */
716
+ candles;
672
717
  constructor(http) {
673
718
  const basePath = "/v1/hyperliquid";
674
719
  this.orderbook = new OrderBookResource(http, basePath);
@@ -676,6 +721,7 @@ var HyperliquidClient = class {
676
721
  this.instruments = new InstrumentsResource(http, basePath);
677
722
  this.funding = new FundingResource(http, basePath);
678
723
  this.openInterest = new OpenInterestResource(http, basePath);
724
+ this.candles = new CandlesResource(http, basePath);
679
725
  }
680
726
  };
681
727
  var LighterClient = class {
@@ -699,6 +745,10 @@ var LighterClient = class {
699
745
  * Open interest
700
746
  */
701
747
  openInterest;
748
+ /**
749
+ * OHLCV candle data
750
+ */
751
+ candles;
702
752
  constructor(http) {
703
753
  const basePath = "/v1/lighter";
704
754
  this.orderbook = new OrderBookResource(http, basePath);
@@ -706,6 +756,7 @@ var LighterClient = class {
706
756
  this.instruments = new LighterInstrumentsResource(http, basePath);
707
757
  this.funding = new FundingResource(http, basePath);
708
758
  this.openInterest = new OpenInterestResource(http, basePath);
759
+ this.candles = new CandlesResource(http, basePath);
709
760
  }
710
761
  };
711
762
 
@@ -1033,7 +1084,8 @@ var OxArchiveWs = class {
1033
1084
  start: options.start,
1034
1085
  end: options.end,
1035
1086
  speed: options.speed ?? 1,
1036
- granularity: options.granularity
1087
+ granularity: options.granularity,
1088
+ interval: options.interval
1037
1089
  });
1038
1090
  }
1039
1091
  /**
@@ -1088,7 +1140,8 @@ var OxArchiveWs = class {
1088
1140
  start: options.start,
1089
1141
  end: options.end,
1090
1142
  batch_size: options.batchSize ?? 1e3,
1091
- granularity: options.granularity
1143
+ granularity: options.granularity,
1144
+ interval: options.interval
1092
1145
  });
1093
1146
  }
1094
1147
  /**
@@ -1313,6 +1366,9 @@ var OxArchiveWs = class {
1313
1366
  0 && (module.exports = {
1314
1367
  ApiMetaSchema,
1315
1368
  ApiResponseSchema,
1369
+ CandleArrayResponseSchema,
1370
+ CandleIntervalSchema,
1371
+ CandleSchema,
1316
1372
  FundingRateArrayResponseSchema,
1317
1373
  FundingRateResponseSchema,
1318
1374
  FundingRateSchema,