@0xarchive/sdk 0.4.6 → 0.5.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 CHANGED
@@ -218,6 +218,64 @@ const history = await client.hyperliquid.openInterest.history('ETH', {
218
218
  });
219
219
  ```
220
220
 
221
+ ### Candles (OHLCV)
222
+
223
+ Get historical OHLCV candle data aggregated from trades.
224
+
225
+ ```typescript
226
+ // Get candle history (start is required)
227
+ const candles = await client.hyperliquid.candles.history('BTC', {
228
+ start: Date.now() - 86400000,
229
+ end: Date.now(),
230
+ interval: '1h', // 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w
231
+ limit: 100
232
+ });
233
+
234
+ // Iterate through candles
235
+ for (const candle of candles.data) {
236
+ console.log(`${candle.timestamp}: O=${candle.open} H=${candle.high} L=${candle.low} C=${candle.close} V=${candle.volume}`);
237
+ }
238
+
239
+ // Cursor-based pagination for large datasets
240
+ let result = await client.hyperliquid.candles.history('BTC', {
241
+ start: Date.now() - 86400000,
242
+ end: Date.now(),
243
+ interval: '1m',
244
+ limit: 1000
245
+ });
246
+ const allCandles = [...result.data];
247
+ while (result.nextCursor) {
248
+ result = await client.hyperliquid.candles.history('BTC', {
249
+ start: Date.now() - 86400000,
250
+ end: Date.now(),
251
+ interval: '1m',
252
+ cursor: result.nextCursor,
253
+ limit: 1000
254
+ });
255
+ allCandles.push(...result.data);
256
+ }
257
+
258
+ // Lighter.xyz candles
259
+ const lighterCandles = await client.lighter.candles.history('BTC', {
260
+ start: Date.now() - 86400000,
261
+ end: Date.now(),
262
+ interval: '15m'
263
+ });
264
+ ```
265
+
266
+ #### Available Intervals
267
+
268
+ | Interval | Description |
269
+ |----------|-------------|
270
+ | `1m` | 1 minute |
271
+ | `5m` | 5 minutes |
272
+ | `15m` | 15 minutes |
273
+ | `30m` | 30 minutes |
274
+ | `1h` | 1 hour (default) |
275
+ | `4h` | 4 hours |
276
+ | `1d` | 1 day |
277
+ | `1w` | 1 week |
278
+
221
279
  ### Legacy API (Deprecated)
222
280
 
223
281
  The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
@@ -382,12 +440,40 @@ const ws = new OxArchiveWs({
382
440
 
383
441
  ### Available Channels
384
442
 
385
- | Channel | Description | Requires Coin |
386
- |---------|-------------|---------------|
387
- | `orderbook` | L2 order book updates | Yes |
388
- | `trades` | Trade/fill updates | Yes |
389
- | `ticker` | Price and 24h volume | Yes |
390
- | `all_tickers` | All market tickers | No |
443
+ | Channel | Description | Requires Coin | Historical Support |
444
+ |---------|-------------|---------------|-------------------|
445
+ | `orderbook` | L2 order book updates | Yes | Yes |
446
+ | `trades` | Trade/fill updates | Yes | Yes |
447
+ | `candles` | OHLCV candle data | Yes | Yes (replay/stream only) |
448
+ | `ticker` | Price and 24h volume | Yes | Real-time only |
449
+ | `all_tickers` | All market tickers | No | Real-time only |
450
+
451
+ #### Candle Replay/Stream
452
+
453
+ ```typescript
454
+ // Replay candles at 10x speed
455
+ ws.replay('candles', 'BTC', {
456
+ start: Date.now() - 86400000,
457
+ end: Date.now(),
458
+ speed: 10,
459
+ interval: '15m' // 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w
460
+ });
461
+
462
+ // Bulk stream candles
463
+ ws.stream('candles', 'ETH', {
464
+ start: Date.now() - 3600000,
465
+ end: Date.now(),
466
+ batchSize: 1000,
467
+ interval: '1h'
468
+ });
469
+
470
+ // Lighter.xyz candles
471
+ ws.replay('lighter_candles', 'BTC', {
472
+ start: Date.now() - 86400000,
473
+ speed: 10,
474
+ interval: '5m'
475
+ });
476
+ ```
391
477
 
392
478
  ### WebSocket Connection States
393
479