@0xarchive/sdk 0.3.3 → 0.3.4

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
@@ -35,13 +35,14 @@ const history = await client.orderbook.history('ETH', {
35
35
 
36
36
  ```typescript
37
37
  const client = new OxArchive({
38
- apiKey: 'ox_your_api_key', // Required
39
- baseUrl: 'https://api.0xarchive.io', // Optional, defaults to production
40
- timeout: 30000, // Optional, request timeout in ms
38
+ apiKey: 'ox_your_api_key', // Required
39
+ baseUrl: 'https://api.0xarchive.io', // Optional
40
+ timeout: 30000, // Optional, request timeout in ms (default: 30000)
41
+ validate: false, // Optional, enable Zod schema validation
41
42
  });
42
43
  ```
43
44
 
44
- ## API Reference
45
+ ## REST API Reference
45
46
 
46
47
  ### Order Book
47
48
 
@@ -49,41 +50,55 @@ const client = new OxArchive({
49
50
  // Get current order book
50
51
  const orderbook = await client.orderbook.get('BTC');
51
52
 
52
- // Get order book at specific timestamp
53
+ // Get order book at specific timestamp with custom depth
53
54
  const historical = await client.orderbook.get('BTC', {
54
55
  timestamp: 1704067200000,
55
56
  depth: 20 // Number of levels per side
56
57
  });
57
58
 
58
- // Get historical snapshots
59
+ // Get historical snapshots (start is required)
59
60
  const history = await client.orderbook.history('BTC', {
60
- start: '2024-01-01',
61
- end: '2024-01-02',
61
+ start: Date.now() - 86400000,
62
+ end: Date.now(),
62
63
  limit: 1000
63
64
  });
64
65
  ```
65
66
 
66
67
  ### Trades
67
68
 
69
+ The trades API uses cursor-based pagination for efficient retrieval of large datasets.
70
+
68
71
  ```typescript
69
72
  // Get recent trades
70
73
  const recent = await client.trades.recent('BTC', 100);
71
74
 
72
- // Get trade history
73
- const trades = await client.trades.list('ETH', {
74
- start: Date.now() - 3600000,
75
+ // Get trade history with cursor-based pagination
76
+ let result = await client.trades.list('BTC', {
77
+ start: Date.now() - 86400000,
75
78
  end: Date.now(),
76
- side: 'buy' // Optional: filter by side
79
+ limit: 1000
77
80
  });
81
+
82
+ // Paginate through all results
83
+ const allTrades = [...result.data];
84
+ while (result.nextCursor) {
85
+ result = await client.trades.list('BTC', {
86
+ start: Date.now() - 86400000,
87
+ end: Date.now(),
88
+ cursor: result.nextCursor,
89
+ limit: 1000
90
+ });
91
+ allTrades.push(...result.data);
92
+ }
78
93
  ```
79
94
 
80
95
  ### Instruments
81
96
 
82
97
  ```typescript
83
- // List all instruments
98
+ // List all trading instruments
84
99
  const instruments = await client.instruments.list();
85
100
 
86
- // Get specific instrument
101
+ // Get specific instrument details
87
102
  const btc = await client.instruments.get('BTC');
88
103
  ```
89
104
 
@@ -93,7 +108,7 @@ const btc = await client.instruments.get('BTC');
93
108
  // Get current funding rate
94
109
  const current = await client.funding.current('BTC');
95
110
 
96
- // Get funding rate history
111
+ // Get funding rate history (start is required)
97
112
  const history = await client.funding.history('ETH', {
98
113
  start: Date.now() - 86400000 * 7,
99
114
  end: Date.now()
@@ -106,72 +121,76 @@ const history = await client.funding.history('ETH', {
106
121
  // Get current open interest
107
122
  const current = await client.openInterest.current('BTC');
108
123
 
109
- // Get open interest history
124
+ // Get open interest history (start is required)
110
125
  const history = await client.openInterest.history('ETH', {
111
126
  start: Date.now() - 86400000,
112
- end: Date.now()
127
+ end: Date.now(),
128
+ limit: 100
113
129
  });
114
130
  ```
115
131
 
116
- ## WebSocket Streaming
132
+ ## WebSocket Client
117
133
 
118
- For real-time data, use the WebSocket client:
134
+ The WebSocket client supports three modes: real-time streaming, historical replay, and bulk streaming.
119
135
 
120
136
  ```typescript
121
137
  import { OxArchiveWs } from '@0xarchive/sdk';
122
138
 
123
139
  const ws = new OxArchiveWs({ apiKey: 'ox_your_api_key' });
140
+ ```
141
+
142
+ ### Real-time Streaming
124
143
 
125
- // Connect and set up handlers
144
+ Subscribe to live market data from Hyperliquid.
145
+
146
+ ```typescript
126
147
  ws.connect({
127
148
  onOpen: () => console.log('Connected'),
128
149
  onClose: (code, reason) => console.log(`Disconnected: ${code}`),
129
150
  onError: (error) => console.error('Error:', error),
130
- onMessage: (message) => console.log('Message:', message),
131
- onStateChange: (state) => console.log('State:', state),
132
151
  });
133
152
 
134
- // Subscribe to order book updates
153
+ // Subscribe to channels
135
154
  ws.subscribeOrderbook('BTC');
136
- ws.subscribeOrderbook('ETH');
137
-
138
- // Subscribe to trades
139
- ws.subscribeTrades('BTC');
140
-
141
- // Subscribe to all tickers
155
+ ws.subscribeTrades('ETH');
156
+ ws.subscribeTicker('SOL');
142
157
  ws.subscribeAllTickers();
143
158
 
144
- // Typed handlers for specific data
159
+ // Handle real-time data with typed callbacks
145
160
  ws.onOrderbook((coin, data) => {
146
- console.log(`${coin} orderbook: ${data.mid_price}`);
161
+ console.log(`${coin} mid price: ${data.mid_price}`);
147
162
  });
148
163
 
149
164
  ws.onTrades((coin, trades) => {
150
165
  console.log(`${coin} new trades: ${trades.length}`);
151
166
  });
152
167
 
153
- // Unsubscribe
154
- ws.unsubscribeOrderbook('ETH');
168
+ // Unsubscribe when done
169
+ ws.unsubscribeOrderbook('BTC');
155
170
 
156
- // Disconnect when done
171
+ // Disconnect
157
172
  ws.disconnect();
158
173
  ```
159
174
 
160
- ### Historical Replay (like Tardis.dev)
175
+ ### Historical Replay
176
+
177
+ Replay historical data with original timing preserved. Perfect for backtesting.
161
178
 
162
- Replay historical data with timing preserved:
179
+ > **Important:** Replay data is delivered via `onHistoricalData()`, NOT `onTrades()` or `onOrderbook()`.
180
+ > The real-time callbacks only receive live market data from subscriptions.
163
181
 
164
182
  ```typescript
165
183
  const ws = new OxArchiveWs({ apiKey: 'ox_...' });
166
184
  ws.connect();
167
185
 
168
- // Handle replay data
186
+ // Handle replay data - this is where historical records arrive
169
187
  ws.onHistoricalData((coin, timestamp, data) => {
170
- console.log(`${new Date(timestamp)}: ${data.mid_price}`);
188
+ console.log(`${new Date(timestamp).toISOString()}: ${data.mid_price}`);
171
189
  });
172
190
 
191
+ // Replay lifecycle events
173
192
  ws.onReplayStart((channel, coin, start, end, speed) => {
174
- console.log(`Starting replay from ${start} to ${end} at ${speed}x`);
193
+ console.log(`Starting replay: ${channel}/${coin} at ${speed}x`);
175
194
  });
176
195
 
177
196
  ws.onReplayComplete((channel, coin, recordsSent) => {
@@ -180,20 +199,21 @@ ws.onReplayComplete((channel, coin, recordsSent) => {
180
199
 
181
200
  // Start replay at 10x speed
182
201
  ws.replay('orderbook', 'BTC', {
183
- start: Date.now() - 86400000, // 24 hours ago
184
- speed: 10
202
+ start: Date.now() - 86400000, // 24 hours ago
203
+ end: Date.now(), // Optional, defaults to now
204
+ speed: 10 // Optional, defaults to 1x
185
205
  });
186
206
 
187
207
  // Control playback
188
208
  ws.replayPause();
189
209
  ws.replayResume();
190
- ws.replaySeek(1704067200000); // Jump to timestamp
210
+ ws.replaySeek(1704067200000); // Jump to timestamp
191
211
  ws.replayStop();
192
212
  ```
193
213
 
194
- ### Bulk Streaming (like Databento)
214
+ ### Bulk Streaming
195
215
 
196
- Fast bulk download for data pipelines:
216
+ Fast bulk download for data pipelines. Data arrives in batches without timing delays.
197
217
 
198
218
  ```typescript
199
219
  const ws = new OxArchiveWs({ apiKey: 'ox_...' });
@@ -207,7 +227,7 @@ ws.onBatch((coin, records) => {
207
227
  });
208
228
 
209
229
  ws.onStreamProgress((snapshotsSent) => {
210
- console.log(`Sent: ${snapshotsSent} snapshots`);
230
+ console.log(`Progress: ${snapshotsSent} snapshots`);
211
231
  });
212
232
 
213
233
  ws.onStreamComplete((channel, coin, recordsSent) => {
@@ -216,12 +236,12 @@ ws.onStreamComplete((channel, coin, recordsSent) => {
216
236
 
217
237
  // Start bulk stream
218
238
  ws.stream('orderbook', 'ETH', {
219
- start: Date.now() - 3600000, // 1 hour ago
239
+ start: Date.now() - 3600000, // 1 hour ago
220
240
  end: Date.now(),
221
- batchSize: 1000
241
+ batchSize: 1000 // Optional, defaults to 1000
222
242
  });
223
243
 
224
- // Stop stream if needed
244
+ // Stop if needed
225
245
  ws.streamStop();
226
246
  ```
227
247
 
@@ -229,12 +249,12 @@ ws.streamStop();
229
249
 
230
250
  ```typescript
231
251
  const ws = new OxArchiveWs({
232
- apiKey: 'ox_your_api_key',
233
- wsUrl: 'wss://api.0xarchive.io/ws', // Optional
234
- autoReconnect: true, // Auto-reconnect on disconnect
235
- reconnectDelay: 1000, // Initial reconnect delay (ms)
236
- maxReconnectAttempts: 10, // Max reconnect attempts
237
- pingInterval: 30000, // Keep-alive ping interval (ms)
252
+ apiKey: 'ox_your_api_key', // Required
253
+ wsUrl: 'wss://api.0xarchive.io/ws', // Optional
254
+ autoReconnect: true, // Auto-reconnect on disconnect (default: true)
255
+ reconnectDelay: 1000, // Initial reconnect delay in ms (default: 1000)
256
+ maxReconnectAttempts: 10, // Max reconnect attempts (default: 10)
257
+ pingInterval: 30000, // Keep-alive ping interval in ms (default: 30000)
238
258
  });
239
259
  ```
240
260
 
@@ -247,6 +267,38 @@ const ws = new OxArchiveWs({
247
267
  | `ticker` | Price and 24h volume | Yes |
248
268
  | `all_tickers` | All market tickers | No |
249
269
 
270
+ ### WebSocket Connection States
271
+
272
+ ```typescript
273
+ ws.getState(); // 'disconnected' | 'connecting' | 'connected' | 'reconnecting'
274
+ ws.isConnected(); // boolean
275
+ ```
276
+
277
+ ## Timestamp Formats
278
+
279
+ The SDK accepts timestamps as Unix milliseconds or Date objects:
280
+
281
+ ```typescript
282
+ // Unix milliseconds (recommended)
283
+ client.orderbook.history('BTC', {
284
+ start: Date.now() - 86400000,
285
+ end: Date.now()
286
+ });
287
+
288
+ // Date objects (converted automatically)
289
+ client.orderbook.history('BTC', {
290
+ start: new Date('2024-01-01'),
291
+ end: new Date('2024-01-02')
292
+ });
293
+
294
+ // WebSocket replay/stream also accepts both
295
+ ws.replay('orderbook', 'BTC', {
296
+ start: Date.now() - 3600000,
297
+ end: Date.now(),
298
+ speed: 10
299
+ });
300
+ ```
301
+
250
302
  ## Error Handling
251
303
 
252
304
  ```typescript
@@ -270,17 +322,34 @@ Full TypeScript support with exported types:
270
322
  ```typescript
271
323
  import type {
272
324
  OrderBook,
325
+ PriceLevel,
273
326
  Trade,
274
327
  Instrument,
275
328
  FundingRate,
276
- OpenInterest
329
+ OpenInterest,
330
+ CursorResponse,
331
+ WsOptions,
332
+ WsChannel,
333
+ WsConnectionState,
277
334
  } from '@0xarchive/sdk';
278
335
  ```
279
336
 
337
+ ## Runtime Validation
338
+
339
+ Enable Zod schema validation for API responses:
340
+
341
+ ```typescript
342
+ const client = new OxArchive({
343
+ apiKey: 'ox_your_api_key',
344
+ validate: true // Enable runtime validation
345
+ });
346
+ ```
347
+
348
+ When enabled, responses are validated against Zod schemas and throw `OxArchiveError` with status 422 if validation fails.
349
+
280
350
  ## Requirements
281
351
 
282
- - Node.js 18+
283
- - Modern browsers with `fetch` support
352
+ - Node.js 18+ or modern browsers with `fetch` and `WebSocket` support
284
353
 
285
354
  ## License
286
355
 
package/dist/index.d.mts CHANGED
@@ -94,8 +94,8 @@ interface OrderBookHistoryParams extends TimeRangeParams {
94
94
  }
95
95
  /** Trade side: 'A' (ask/sell) or 'B' (bid/buy) */
96
96
  type TradeSide = 'A' | 'B';
97
- /** Position direction */
98
- type TradeDirection = 'Open Long' | 'Open Short' | 'Close Long' | 'Close Short';
97
+ /** Position direction (can include 'Open Long', 'Close Short', 'Long > Short', etc.) */
98
+ type TradeDirection = string;
99
99
  /** Data source: 's3' (historical), 'api' (REST backfill), 'ws' (websocket), 'live' (real-time ingestion) */
100
100
  type DataSource = 's3' | 'ws' | 'api' | 'live';
101
101
  /**
@@ -1174,7 +1174,7 @@ declare const OrderBookSchema: z.ZodObject<{
1174
1174
  spread_bps?: string | undefined;
1175
1175
  }>;
1176
1176
  declare const TradeSideSchema: z.ZodEnum<["A", "B"]>;
1177
- declare const TradeDirectionSchema: z.ZodEnum<["Open Long", "Open Short", "Close Long", "Close Short"]>;
1177
+ declare const TradeDirectionSchema: z.ZodString;
1178
1178
  declare const DataSourceSchema: z.ZodEnum<["s3", "ws", "api", "live"]>;
1179
1179
  declare const TradeSchema: z.ZodObject<{
1180
1180
  coin: z.ZodString;
@@ -1189,7 +1189,7 @@ declare const TradeSchema: z.ZodObject<{
1189
1189
  fee: z.ZodOptional<z.ZodString>;
1190
1190
  fee_token: z.ZodOptional<z.ZodString>;
1191
1191
  closed_pnl: z.ZodOptional<z.ZodString>;
1192
- direction: z.ZodOptional<z.ZodEnum<["Open Long", "Open Short", "Close Long", "Close Short"]>>;
1192
+ direction: z.ZodOptional<z.ZodString>;
1193
1193
  start_position: z.ZodOptional<z.ZodString>;
1194
1194
  source: z.ZodOptional<z.ZodEnum<["s3", "ws", "api", "live"]>>;
1195
1195
  user_address: z.ZodOptional<z.ZodString>;
@@ -1208,7 +1208,7 @@ declare const TradeSchema: z.ZodObject<{
1208
1208
  fee?: string | undefined;
1209
1209
  fee_token?: string | undefined;
1210
1210
  closed_pnl?: string | undefined;
1211
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
1211
+ direction?: string | undefined;
1212
1212
  start_position?: string | undefined;
1213
1213
  source?: "s3" | "ws" | "api" | "live" | undefined;
1214
1214
  user_address?: string | undefined;
@@ -1227,7 +1227,7 @@ declare const TradeSchema: z.ZodObject<{
1227
1227
  fee?: string | undefined;
1228
1228
  fee_token?: string | undefined;
1229
1229
  closed_pnl?: string | undefined;
1230
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
1230
+ direction?: string | undefined;
1231
1231
  start_position?: string | undefined;
1232
1232
  source?: "s3" | "ws" | "api" | "live" | undefined;
1233
1233
  user_address?: string | undefined;
@@ -2035,7 +2035,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2035
2035
  fee: z.ZodOptional<z.ZodString>;
2036
2036
  fee_token: z.ZodOptional<z.ZodString>;
2037
2037
  closed_pnl: z.ZodOptional<z.ZodString>;
2038
- direction: z.ZodOptional<z.ZodEnum<["Open Long", "Open Short", "Close Long", "Close Short"]>>;
2038
+ direction: z.ZodOptional<z.ZodString>;
2039
2039
  start_position: z.ZodOptional<z.ZodString>;
2040
2040
  source: z.ZodOptional<z.ZodEnum<["s3", "ws", "api", "live"]>>;
2041
2041
  user_address: z.ZodOptional<z.ZodString>;
@@ -2054,7 +2054,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2054
2054
  fee?: string | undefined;
2055
2055
  fee_token?: string | undefined;
2056
2056
  closed_pnl?: string | undefined;
2057
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
2057
+ direction?: string | undefined;
2058
2058
  start_position?: string | undefined;
2059
2059
  source?: "s3" | "ws" | "api" | "live" | undefined;
2060
2060
  user_address?: string | undefined;
@@ -2073,7 +2073,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2073
2073
  fee?: string | undefined;
2074
2074
  fee_token?: string | undefined;
2075
2075
  closed_pnl?: string | undefined;
2076
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
2076
+ direction?: string | undefined;
2077
2077
  start_position?: string | undefined;
2078
2078
  source?: "s3" | "ws" | "api" | "live" | undefined;
2079
2079
  user_address?: string | undefined;
@@ -2107,7 +2107,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2107
2107
  fee?: string | undefined;
2108
2108
  fee_token?: string | undefined;
2109
2109
  closed_pnl?: string | undefined;
2110
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
2110
+ direction?: string | undefined;
2111
2111
  start_position?: string | undefined;
2112
2112
  source?: "s3" | "ws" | "api" | "live" | undefined;
2113
2113
  user_address?: string | undefined;
@@ -2134,7 +2134,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2134
2134
  fee?: string | undefined;
2135
2135
  fee_token?: string | undefined;
2136
2136
  closed_pnl?: string | undefined;
2137
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
2137
+ direction?: string | undefined;
2138
2138
  start_position?: string | undefined;
2139
2139
  source?: "s3" | "ws" | "api" | "live" | undefined;
2140
2140
  user_address?: string | undefined;
package/dist/index.d.ts CHANGED
@@ -94,8 +94,8 @@ interface OrderBookHistoryParams extends TimeRangeParams {
94
94
  }
95
95
  /** Trade side: 'A' (ask/sell) or 'B' (bid/buy) */
96
96
  type TradeSide = 'A' | 'B';
97
- /** Position direction */
98
- type TradeDirection = 'Open Long' | 'Open Short' | 'Close Long' | 'Close Short';
97
+ /** Position direction (can include 'Open Long', 'Close Short', 'Long > Short', etc.) */
98
+ type TradeDirection = string;
99
99
  /** Data source: 's3' (historical), 'api' (REST backfill), 'ws' (websocket), 'live' (real-time ingestion) */
100
100
  type DataSource = 's3' | 'ws' | 'api' | 'live';
101
101
  /**
@@ -1174,7 +1174,7 @@ declare const OrderBookSchema: z.ZodObject<{
1174
1174
  spread_bps?: string | undefined;
1175
1175
  }>;
1176
1176
  declare const TradeSideSchema: z.ZodEnum<["A", "B"]>;
1177
- declare const TradeDirectionSchema: z.ZodEnum<["Open Long", "Open Short", "Close Long", "Close Short"]>;
1177
+ declare const TradeDirectionSchema: z.ZodString;
1178
1178
  declare const DataSourceSchema: z.ZodEnum<["s3", "ws", "api", "live"]>;
1179
1179
  declare const TradeSchema: z.ZodObject<{
1180
1180
  coin: z.ZodString;
@@ -1189,7 +1189,7 @@ declare const TradeSchema: z.ZodObject<{
1189
1189
  fee: z.ZodOptional<z.ZodString>;
1190
1190
  fee_token: z.ZodOptional<z.ZodString>;
1191
1191
  closed_pnl: z.ZodOptional<z.ZodString>;
1192
- direction: z.ZodOptional<z.ZodEnum<["Open Long", "Open Short", "Close Long", "Close Short"]>>;
1192
+ direction: z.ZodOptional<z.ZodString>;
1193
1193
  start_position: z.ZodOptional<z.ZodString>;
1194
1194
  source: z.ZodOptional<z.ZodEnum<["s3", "ws", "api", "live"]>>;
1195
1195
  user_address: z.ZodOptional<z.ZodString>;
@@ -1208,7 +1208,7 @@ declare const TradeSchema: z.ZodObject<{
1208
1208
  fee?: string | undefined;
1209
1209
  fee_token?: string | undefined;
1210
1210
  closed_pnl?: string | undefined;
1211
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
1211
+ direction?: string | undefined;
1212
1212
  start_position?: string | undefined;
1213
1213
  source?: "s3" | "ws" | "api" | "live" | undefined;
1214
1214
  user_address?: string | undefined;
@@ -1227,7 +1227,7 @@ declare const TradeSchema: z.ZodObject<{
1227
1227
  fee?: string | undefined;
1228
1228
  fee_token?: string | undefined;
1229
1229
  closed_pnl?: string | undefined;
1230
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
1230
+ direction?: string | undefined;
1231
1231
  start_position?: string | undefined;
1232
1232
  source?: "s3" | "ws" | "api" | "live" | undefined;
1233
1233
  user_address?: string | undefined;
@@ -2035,7 +2035,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2035
2035
  fee: z.ZodOptional<z.ZodString>;
2036
2036
  fee_token: z.ZodOptional<z.ZodString>;
2037
2037
  closed_pnl: z.ZodOptional<z.ZodString>;
2038
- direction: z.ZodOptional<z.ZodEnum<["Open Long", "Open Short", "Close Long", "Close Short"]>>;
2038
+ direction: z.ZodOptional<z.ZodString>;
2039
2039
  start_position: z.ZodOptional<z.ZodString>;
2040
2040
  source: z.ZodOptional<z.ZodEnum<["s3", "ws", "api", "live"]>>;
2041
2041
  user_address: z.ZodOptional<z.ZodString>;
@@ -2054,7 +2054,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2054
2054
  fee?: string | undefined;
2055
2055
  fee_token?: string | undefined;
2056
2056
  closed_pnl?: string | undefined;
2057
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
2057
+ direction?: string | undefined;
2058
2058
  start_position?: string | undefined;
2059
2059
  source?: "s3" | "ws" | "api" | "live" | undefined;
2060
2060
  user_address?: string | undefined;
@@ -2073,7 +2073,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2073
2073
  fee?: string | undefined;
2074
2074
  fee_token?: string | undefined;
2075
2075
  closed_pnl?: string | undefined;
2076
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
2076
+ direction?: string | undefined;
2077
2077
  start_position?: string | undefined;
2078
2078
  source?: "s3" | "ws" | "api" | "live" | undefined;
2079
2079
  user_address?: string | undefined;
@@ -2107,7 +2107,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2107
2107
  fee?: string | undefined;
2108
2108
  fee_token?: string | undefined;
2109
2109
  closed_pnl?: string | undefined;
2110
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
2110
+ direction?: string | undefined;
2111
2111
  start_position?: string | undefined;
2112
2112
  source?: "s3" | "ws" | "api" | "live" | undefined;
2113
2113
  user_address?: string | undefined;
@@ -2134,7 +2134,7 @@ declare const TradeArrayResponseSchema: z.ZodObject<{
2134
2134
  fee?: string | undefined;
2135
2135
  fee_token?: string | undefined;
2136
2136
  closed_pnl?: string | undefined;
2137
- direction?: "Open Long" | "Open Short" | "Close Long" | "Close Short" | undefined;
2137
+ direction?: string | undefined;
2138
2138
  start_position?: string | undefined;
2139
2139
  source?: "s3" | "ws" | "api" | "live" | undefined;
2140
2140
  user_address?: string | undefined;
package/dist/index.js CHANGED
@@ -108,7 +108,11 @@ var HttpClient = class {
108
108
  if (params) {
109
109
  for (const [key, value] of Object.entries(params)) {
110
110
  if (value !== void 0 && value !== null) {
111
- url.searchParams.set(key, String(value));
111
+ if (value instanceof Date) {
112
+ url.searchParams.set(key, String(value.getTime()));
113
+ } else {
114
+ url.searchParams.set(key, String(value));
115
+ }
112
116
  }
113
117
  }
114
118
  }
@@ -188,12 +192,7 @@ var OrderBookSchema = import_zod.z.object({
188
192
  spread_bps: import_zod.z.string().optional()
189
193
  });
190
194
  var TradeSideSchema = import_zod.z.enum(["A", "B"]);
191
- var TradeDirectionSchema = import_zod.z.enum([
192
- "Open Long",
193
- "Open Short",
194
- "Close Long",
195
- "Close Short"
196
- ]);
195
+ var TradeDirectionSchema = import_zod.z.string();
197
196
  var DataSourceSchema = import_zod.z.enum(["s3", "ws", "api", "live"]);
198
197
  var TradeSchema = import_zod.z.object({
199
198
  coin: import_zod.z.string(),