oxarchive 0.3.6__py3-none-any.whl → 0.4.5__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oxarchive
3
- Version: 0.3.6
3
+ Version: 0.4.5
4
4
  Summary: Official Python SDK for 0xarchive - Hyperliquid Historical Data API
5
5
  Project-URL: Homepage, https://0xarchive.io
6
6
  Project-URL: Documentation, https://0xarchive.io/docs/sdks
@@ -24,7 +24,7 @@ Requires-Python: >=3.9
24
24
  Requires-Dist: httpx>=0.25.0
25
25
  Requires-Dist: pydantic>=2.0.0
26
26
  Provides-Extra: all
27
- Requires-Dist: websockets>=12.0; extra == 'all'
27
+ Requires-Dist: websockets>=14.0; extra == 'all'
28
28
  Provides-Extra: dev
29
29
  Requires-Dist: mypy>=1.9.0; extra == 'dev'
30
30
  Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
@@ -32,12 +32,16 @@ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
32
32
  Requires-Dist: pytest>=8.0.0; extra == 'dev'
33
33
  Requires-Dist: ruff>=0.4.0; extra == 'dev'
34
34
  Provides-Extra: websocket
35
- Requires-Dist: websockets>=12.0; extra == 'websocket'
35
+ Requires-Dist: websockets>=14.0; extra == 'websocket'
36
36
  Description-Content-Type: text/markdown
37
37
 
38
38
  # oxarchive
39
39
 
40
- Official Python SDK for [0xarchive](https://0xarchive.io) - Hyperliquid Historical Data API.
40
+ Official Python SDK for [0xarchive](https://0xarchive.io) - Historical Market Data API.
41
+
42
+ Supports multiple exchanges:
43
+ - **Hyperliquid** - Perpetuals data from April 2023
44
+ - **Lighter.xyz** - Perpetuals data (August 2025+ for fills, Jan 2026+ for OB, OI, Funding Rate)
41
45
 
42
46
  ## Installation
43
47
 
@@ -58,12 +62,16 @@ from oxarchive import Client
58
62
 
59
63
  client = Client(api_key="ox_your_api_key")
60
64
 
61
- # Get current order book
62
- orderbook = client.orderbook.get("BTC")
63
- print(f"BTC mid price: {orderbook.mid_price}")
65
+ # Hyperliquid data
66
+ hl_orderbook = client.hyperliquid.orderbook.get("BTC")
67
+ print(f"Hyperliquid BTC mid price: {hl_orderbook.mid_price}")
68
+
69
+ # Lighter.xyz data
70
+ lighter_orderbook = client.lighter.orderbook.get("BTC")
71
+ print(f"Lighter BTC mid price: {lighter_orderbook.mid_price}")
64
72
 
65
73
  # Get historical order book snapshots
66
- history = client.orderbook.history(
74
+ history = client.hyperliquid.orderbook.history(
67
75
  "ETH",
68
76
  start="2024-01-01",
69
77
  end="2024-01-02",
@@ -82,10 +90,13 @@ from oxarchive import Client
82
90
  async def main():
83
91
  client = Client(api_key="ox_your_api_key")
84
92
 
85
- # Async get
86
- orderbook = await client.orderbook.aget("BTC")
93
+ # Async get (Hyperliquid)
94
+ orderbook = await client.hyperliquid.orderbook.aget("BTC")
87
95
  print(f"BTC mid price: {orderbook.mid_price}")
88
96
 
97
+ # Async get (Lighter.xyz)
98
+ lighter_ob = await client.lighter.orderbook.aget("BTC")
99
+
89
100
  # Don't forget to close the client
90
101
  await client.aclose()
91
102
 
@@ -96,7 +107,7 @@ Or use as async context manager:
96
107
 
97
108
  ```python
98
109
  async with Client(api_key="ox_your_api_key") as client:
99
- orderbook = await client.orderbook.aget("BTC")
110
+ orderbook = await client.hyperliquid.orderbook.aget("BTC")
100
111
  ```
101
112
 
102
113
  ## Configuration
@@ -111,20 +122,25 @@ client = Client(
111
122
 
112
123
  ## REST API Reference
113
124
 
125
+ All examples use `client.hyperliquid.*` but the same methods are available on `client.lighter.*` for Lighter.xyz data.
126
+
114
127
  ### Order Book
115
128
 
116
129
  ```python
117
- # Get current order book
118
- orderbook = client.orderbook.get("BTC")
130
+ # Get current order book (Hyperliquid)
131
+ orderbook = client.hyperliquid.orderbook.get("BTC")
132
+
133
+ # Get current order book (Lighter.xyz)
134
+ orderbook = client.lighter.orderbook.get("BTC")
119
135
 
120
136
  # Get order book at specific timestamp
121
- historical = client.orderbook.get("BTC", timestamp=1704067200000)
137
+ historical = client.hyperliquid.orderbook.get("BTC", timestamp=1704067200000)
122
138
 
123
139
  # Get with limited depth
124
- shallow = client.orderbook.get("BTC", depth=10)
140
+ shallow = client.hyperliquid.orderbook.get("BTC", depth=10)
125
141
 
126
142
  # Get historical snapshots (start and end are required)
127
- history = client.orderbook.history(
143
+ history = client.hyperliquid.orderbook.history(
128
144
  "BTC",
129
145
  start="2024-01-01",
130
146
  end="2024-01-02",
@@ -133,25 +149,78 @@ history = client.orderbook.history(
133
149
  )
134
150
 
135
151
  # Async versions
136
- orderbook = await client.orderbook.aget("BTC")
137
- history = await client.orderbook.ahistory("BTC", start=..., end=...)
152
+ orderbook = await client.hyperliquid.orderbook.aget("BTC")
153
+ history = await client.hyperliquid.orderbook.ahistory("BTC", start=..., end=...)
154
+ ```
155
+
156
+ #### Orderbook Depth Limits
157
+
158
+ The `depth` parameter controls how many price levels are returned per side. Tier-based limits apply:
159
+
160
+ | Tier | Max Depth |
161
+ |------|-----------|
162
+ | Free | 20 |
163
+ | Build | 50 |
164
+ | Pro | 100 |
165
+ | Enterprise | Full Depth |
166
+
167
+ **Note:** Hyperliquid source data only contains 20 levels. Higher limits apply to Lighter.xyz data.
168
+
169
+ #### Lighter Orderbook Granularity
170
+
171
+ Lighter.xyz orderbook history supports a `granularity` parameter for different data resolutions. Tier restrictions apply.
172
+
173
+ | Granularity | Interval | Tier Required | Credit Multiplier |
174
+ |-------------|----------|---------------|-------------------|
175
+ | `checkpoint` | ~60s | Free+ | 1x |
176
+ | `30s` | 30s | Build+ | 2x |
177
+ | `10s` | 10s | Build+ | 3x |
178
+ | `1s` | 1s | Pro+ | 10x |
179
+ | `tick` | tick-level | Enterprise | 20x |
180
+
181
+ ```python
182
+ # Get Lighter orderbook history with 10s resolution (Build+ tier)
183
+ history = client.lighter.orderbook.history(
184
+ "BTC",
185
+ start="2024-01-01",
186
+ end="2024-01-02",
187
+ granularity="10s"
188
+ )
189
+
190
+ # Get 1-second resolution (Pro+ tier)
191
+ history = client.lighter.orderbook.history(
192
+ "BTC",
193
+ start="2024-01-01",
194
+ end="2024-01-02",
195
+ granularity="1s"
196
+ )
197
+
198
+ # Tick-level data (Enterprise tier) - returns checkpoint + raw deltas
199
+ history = client.lighter.orderbook.history(
200
+ "BTC",
201
+ start="2024-01-01",
202
+ end="2024-01-02",
203
+ granularity="tick"
204
+ )
138
205
  ```
139
206
 
207
+ **Note:** The `granularity` parameter is ignored for Hyperliquid orderbook history.
208
+
140
209
  ### Trades
141
210
 
142
211
  The trades API uses cursor-based pagination for efficient retrieval of large datasets.
143
212
 
144
213
  ```python
145
214
  # Get recent trades
146
- recent = client.trades.recent("BTC", limit=100)
215
+ recent = client.hyperliquid.trades.recent("BTC", limit=100)
147
216
 
148
217
  # Get trade history with cursor-based pagination
149
- result = client.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
218
+ result = client.hyperliquid.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
150
219
  trades = result.data
151
220
 
152
221
  # Paginate through all results
153
222
  while result.next_cursor:
154
- result = client.trades.list(
223
+ result = client.hyperliquid.trades.list(
155
224
  "ETH",
156
225
  start="2024-01-01",
157
226
  end="2024-01-02",
@@ -161,61 +230,103 @@ while result.next_cursor:
161
230
  trades.extend(result.data)
162
231
 
163
232
  # Filter by side
164
- buys = client.trades.list("BTC", start=..., end=..., side="buy")
233
+ buys = client.hyperliquid.trades.list("BTC", start=..., end=..., side="buy")
165
234
 
166
235
  # Async versions
167
- recent = await client.trades.arecent("BTC")
168
- result = await client.trades.alist("ETH", start=..., end=...)
236
+ recent = await client.hyperliquid.trades.arecent("BTC")
237
+ result = await client.hyperliquid.trades.alist("ETH", start=..., end=...)
169
238
  ```
170
239
 
171
240
  ### Instruments
172
241
 
173
242
  ```python
174
- # List all trading instruments
175
- instruments = client.instruments.list()
243
+ # List all trading instruments (Hyperliquid)
244
+ instruments = client.hyperliquid.instruments.list()
176
245
 
177
246
  # Get specific instrument details
178
- btc = client.instruments.get("BTC")
247
+ btc = client.hyperliquid.instruments.get("BTC")
248
+ print(f"BTC size decimals: {btc.sz_decimals}")
179
249
 
180
250
  # Async versions
181
- instruments = await client.instruments.alist()
182
- btc = await client.instruments.aget("BTC")
251
+ instruments = await client.hyperliquid.instruments.alist()
252
+ btc = await client.hyperliquid.instruments.aget("BTC")
183
253
  ```
184
254
 
255
+ #### Lighter.xyz Instruments
256
+
257
+ Lighter instruments have a different schema with additional fields for fees, market IDs, and minimum order amounts:
258
+
259
+ ```python
260
+ # List Lighter instruments (returns LighterInstrument, not Instrument)
261
+ lighter_instruments = client.lighter.instruments.list()
262
+
263
+ # Get specific Lighter instrument
264
+ eth = client.lighter.instruments.get("ETH")
265
+ print(f"ETH taker fee: {eth.taker_fee}")
266
+ print(f"ETH maker fee: {eth.maker_fee}")
267
+ print(f"ETH market ID: {eth.market_id}")
268
+ print(f"ETH min base amount: {eth.min_base_amount}")
269
+
270
+ # Async versions
271
+ lighter_instruments = await client.lighter.instruments.alist()
272
+ eth = await client.lighter.instruments.aget("ETH")
273
+ ```
274
+
275
+ **Key differences:**
276
+ | Field | Hyperliquid (`Instrument`) | Lighter (`LighterInstrument`) |
277
+ |-------|---------------------------|------------------------------|
278
+ | Symbol | `name` | `symbol` |
279
+ | Size decimals | `sz_decimals` | `size_decimals` |
280
+ | Fee info | Not available | `taker_fee`, `maker_fee`, `liquidation_fee` |
281
+ | Market ID | Not available | `market_id` |
282
+ | Min amounts | Not available | `min_base_amount`, `min_quote_amount` |
283
+
185
284
  ### Funding Rates
186
285
 
187
286
  ```python
188
287
  # Get current funding rate
189
- current = client.funding.current("BTC")
288
+ current = client.hyperliquid.funding.current("BTC")
190
289
 
191
290
  # Get funding rate history (start is required)
192
- history = client.funding.history(
291
+ history = client.hyperliquid.funding.history(
193
292
  "ETH",
194
293
  start="2024-01-01",
195
294
  end="2024-01-07"
196
295
  )
197
296
 
198
297
  # Async versions
199
- current = await client.funding.acurrent("BTC")
200
- history = await client.funding.ahistory("ETH", start=..., end=...)
298
+ current = await client.hyperliquid.funding.acurrent("BTC")
299
+ history = await client.hyperliquid.funding.ahistory("ETH", start=..., end=...)
201
300
  ```
202
301
 
203
302
  ### Open Interest
204
303
 
205
304
  ```python
206
305
  # Get current open interest
207
- current = client.open_interest.current("BTC")
306
+ current = client.hyperliquid.open_interest.current("BTC")
208
307
 
209
308
  # Get open interest history (start is required)
210
- history = client.open_interest.history(
309
+ history = client.hyperliquid.open_interest.history(
211
310
  "ETH",
212
311
  start="2024-01-01",
213
312
  end="2024-01-07"
214
313
  )
215
314
 
216
315
  # Async versions
217
- current = await client.open_interest.acurrent("BTC")
218
- history = await client.open_interest.ahistory("ETH", start=..., end=...)
316
+ current = await client.hyperliquid.open_interest.acurrent("BTC")
317
+ history = await client.hyperliquid.open_interest.ahistory("ETH", start=..., end=...)
318
+ ```
319
+
320
+ ### Legacy API (Deprecated)
321
+
322
+ The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
323
+
324
+ ```python
325
+ # Deprecated - use client.hyperliquid.orderbook.get() instead
326
+ orderbook = client.orderbook.get("BTC")
327
+
328
+ # Deprecated - use client.hyperliquid.trades.list() instead
329
+ trades = client.trades.list("BTC", start=..., end=...)
219
330
  ```
220
331
 
221
332
  ## WebSocket Client
@@ -307,6 +418,19 @@ async def main():
307
418
  speed=10 # Optional, defaults to 1x
308
419
  )
309
420
 
421
+ # Lighter.xyz replay with granularity (tier restrictions apply)
422
+ await ws.replay(
423
+ "orderbook", "BTC",
424
+ start=int(time.time() * 1000) - 86400000,
425
+ speed=10,
426
+ granularity="10s" # Options: 'checkpoint', '30s', '10s', '1s', 'tick'
427
+ )
428
+
429
+ # Handle tick-level data (granularity='tick', Enterprise tier)
430
+ ws.on_historical_tick_data(lambda coin, checkpoint, deltas:
431
+ print(f"Checkpoint: {len(checkpoint['bids'])} bids, Deltas: {len(deltas)}")
432
+ )
433
+
310
434
  # Control playback
311
435
  await ws.replay_pause()
312
436
  await ws.replay_resume()
@@ -352,6 +476,14 @@ async def main():
352
476
  batch_size=1000 # Optional, defaults to 1000
353
477
  )
354
478
 
479
+ # Lighter.xyz stream with granularity (tier restrictions apply)
480
+ await ws.stream(
481
+ "orderbook", "BTC",
482
+ start=int(time.time() * 1000) - 3600000,
483
+ end=int(time.time() * 1000),
484
+ granularity="10s" # Options: 'checkpoint', '30s', '10s', '1s', 'tick'
485
+ )
486
+
355
487
  # Stop if needed
356
488
  await ws.stream_stop()
357
489
 
@@ -421,8 +553,8 @@ except OxArchiveError as e:
421
553
  Full type hint support with Pydantic models:
422
554
 
423
555
  ```python
424
- from oxarchive import Client
425
- from oxarchive.types import OrderBook, Trade, Instrument, FundingRate, OpenInterest
556
+ from oxarchive import Client, LighterGranularity
557
+ from oxarchive.types import OrderBook, Trade, Instrument, LighterInstrument, FundingRate, OpenInterest
426
558
  from oxarchive.resources.trades import CursorResponse
427
559
 
428
560
  client = Client(api_key="ox_your_api_key")
@@ -430,6 +562,9 @@ client = Client(api_key="ox_your_api_key")
430
562
  orderbook: OrderBook = client.orderbook.get("BTC")
431
563
  trades: list[Trade] = client.trades.recent("BTC")
432
564
  result: CursorResponse = client.trades.list("BTC", start=..., end=...)
565
+
566
+ # Lighter granularity type hint
567
+ granularity: LighterGranularity = "10s"
433
568
  ```
434
569
 
435
570
  ## Requirements
@@ -0,0 +1,15 @@
1
+ oxarchive/__init__.py,sha256=sqzliCe2bC5ecOGaijBeOyLwj1K6d8mjwrCUSVl6r2Q,2666
2
+ oxarchive/client.py,sha256=XWQ_VEBQy3UIAnmZQ-Z_FyzXnvMA3FITwtinBOf3o-Y,4453
3
+ oxarchive/exchanges.py,sha256=kk--Uh4g1U_tPfhJhYtZD_1zR6tJS5D-iaPnOGwWa9c,2425
4
+ oxarchive/http.py,sha256=SY_o9Ag8ADo1HI3i3uAKW1xwkYjPE75gRAjnMsddAGs,4211
5
+ oxarchive/types.py,sha256=YHy04TYtuEmJSHDMRh_9D9MVnhnXVc2rGagc45LwPiQ,13380
6
+ oxarchive/websocket.py,sha256=kfpi_-Bifa5l78et-QbwV9XZ6wCVDyDmK0v90H0mFfU,29888
7
+ oxarchive/resources/__init__.py,sha256=ZGS3rLOfQFD665oJYMia_MxfTWlal7MXtx874DLG5EE,448
8
+ oxarchive/resources/funding.py,sha256=ybMWkpoccrkdwnd6W3oHgsaor7cBcA2nkYy4CbjmHUg,4485
9
+ oxarchive/resources/instruments.py,sha256=6q7rMdIaixXgFVXgwQsVd-YuO7RIXr1oGPT5jBsqI9A,3733
10
+ oxarchive/resources/openinterest.py,sha256=whwo60KFNLGwvVrDmDYYc-rMZr35Fcizb5Iil-DSvD8,4553
11
+ oxarchive/resources/orderbook.py,sha256=NzgKH45MBb2oAHyPmy6BSikaYyq0nM-8GFjur9LIRN8,6661
12
+ oxarchive/resources/trades.py,sha256=t4iicyi1waaHzC7Q_cC-c7O4yVx1vqS4eMH8F8_5hxk,5503
13
+ oxarchive-0.4.5.dist-info/METADATA,sha256=i0CBOXJAlThCcc_-2PQwV-Or1-SxMHNovKVPMujsmLc,15945
14
+ oxarchive-0.4.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
15
+ oxarchive-0.4.5.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- oxarchive/__init__.py,sha256=Q6hk0SMNM5HLYIuyFXrCPYrT261n90iPKoGakQL11vk,2181
2
- oxarchive/client.py,sha256=3P0fvOcyM5BWppkVV4054NduDHKvRg-cWeluoGymmRk,3163
3
- oxarchive/http.py,sha256=SY_o9Ag8ADo1HI3i3uAKW1xwkYjPE75gRAjnMsddAGs,4211
4
- oxarchive/types.py,sha256=pQJt1ZilZaV6h4anPYHloVrB97Q9Y2v9B9iYTkMXFo0,11025
5
- oxarchive/websocket.py,sha256=f5MeqwWL0WRn1X4uRXaSir7izUPPpkG1R75JuvA_fqE,28383
6
- oxarchive/resources/__init__.py,sha256=WQ4GYQ8p3L0D2Isk4IV4h1DRpvyZlt6tOF1t_CJr6ls,385
7
- oxarchive/resources/funding.py,sha256=TXkZxodVQTVcVbzNG6SpMQAzf8AkLm2NYZJxnP4MNXw,3500
8
- oxarchive/resources/instruments.py,sha256=flD1sH6x3P3CTqV1ZwkfwbranVacmhsHn5Dhr7lGQhM,1606
9
- oxarchive/resources/openinterest.py,sha256=h13yLA72LpfryUf8IqF6W7uE4ObYY2Qbc-auv4LtPqc,3552
10
- oxarchive/resources/orderbook.py,sha256=o_DTdpzKrZvHL9YXm8cGGUugPM8uUa6r9O_72r1ByV0,4557
11
- oxarchive/resources/trades.py,sha256=XCi2rXA2hxaTt0KNlWw8f7W0hzAvNWyT7DaivMz_rHw,10012
12
- oxarchive-0.3.6.dist-info/METADATA,sha256=mAi4P9emfIG3_rlaFXyocwpRjxLEw9xo5sAwnMBUE5U,11070
13
- oxarchive-0.3.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
14
- oxarchive-0.3.6.dist-info/RECORD,,