oxarchive 0.3.5__tar.gz → 0.4.1__tar.gz

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.5
3
+ Version: 0.4.1
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,8 +149,8 @@ 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=...)
138
154
  ```
139
155
 
140
156
  ### Trades
@@ -143,15 +159,15 @@ The trades API uses cursor-based pagination for efficient retrieval of large dat
143
159
 
144
160
  ```python
145
161
  # Get recent trades
146
- recent = client.trades.recent("BTC", limit=100)
162
+ recent = client.hyperliquid.trades.recent("BTC", limit=100)
147
163
 
148
164
  # Get trade history with cursor-based pagination
149
- result = client.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
165
+ result = client.hyperliquid.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
150
166
  trades = result.data
151
167
 
152
168
  # Paginate through all results
153
169
  while result.next_cursor:
154
- result = client.trades.list(
170
+ result = client.hyperliquid.trades.list(
155
171
  "ETH",
156
172
  start="2024-01-01",
157
173
  end="2024-01-02",
@@ -161,61 +177,73 @@ while result.next_cursor:
161
177
  trades.extend(result.data)
162
178
 
163
179
  # Filter by side
164
- buys = client.trades.list("BTC", start=..., end=..., side="buy")
180
+ buys = client.hyperliquid.trades.list("BTC", start=..., end=..., side="buy")
165
181
 
166
182
  # Async versions
167
- recent = await client.trades.arecent("BTC")
168
- result = await client.trades.alist("ETH", start=..., end=...)
183
+ recent = await client.hyperliquid.trades.arecent("BTC")
184
+ result = await client.hyperliquid.trades.alist("ETH", start=..., end=...)
169
185
  ```
170
186
 
171
187
  ### Instruments
172
188
 
173
189
  ```python
174
190
  # List all trading instruments
175
- instruments = client.instruments.list()
191
+ instruments = client.hyperliquid.instruments.list()
176
192
 
177
193
  # Get specific instrument details
178
- btc = client.instruments.get("BTC")
194
+ btc = client.hyperliquid.instruments.get("BTC")
179
195
 
180
196
  # Async versions
181
- instruments = await client.instruments.alist()
182
- btc = await client.instruments.aget("BTC")
197
+ instruments = await client.hyperliquid.instruments.alist()
198
+ btc = await client.hyperliquid.instruments.aget("BTC")
183
199
  ```
184
200
 
185
201
  ### Funding Rates
186
202
 
187
203
  ```python
188
204
  # Get current funding rate
189
- current = client.funding.current("BTC")
205
+ current = client.hyperliquid.funding.current("BTC")
190
206
 
191
207
  # Get funding rate history (start is required)
192
- history = client.funding.history(
208
+ history = client.hyperliquid.funding.history(
193
209
  "ETH",
194
210
  start="2024-01-01",
195
211
  end="2024-01-07"
196
212
  )
197
213
 
198
214
  # Async versions
199
- current = await client.funding.acurrent("BTC")
200
- history = await client.funding.ahistory("ETH", start=..., end=...)
215
+ current = await client.hyperliquid.funding.acurrent("BTC")
216
+ history = await client.hyperliquid.funding.ahistory("ETH", start=..., end=...)
201
217
  ```
202
218
 
203
219
  ### Open Interest
204
220
 
205
221
  ```python
206
222
  # Get current open interest
207
- current = client.open_interest.current("BTC")
223
+ current = client.hyperliquid.open_interest.current("BTC")
208
224
 
209
225
  # Get open interest history (start is required)
210
- history = client.open_interest.history(
226
+ history = client.hyperliquid.open_interest.history(
211
227
  "ETH",
212
228
  start="2024-01-01",
213
229
  end="2024-01-07"
214
230
  )
215
231
 
216
232
  # Async versions
217
- current = await client.open_interest.acurrent("BTC")
218
- history = await client.open_interest.ahistory("ETH", start=..., end=...)
233
+ current = await client.hyperliquid.open_interest.acurrent("BTC")
234
+ history = await client.hyperliquid.open_interest.ahistory("ETH", start=..., end=...)
235
+ ```
236
+
237
+ ### Legacy API (Deprecated)
238
+
239
+ The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
240
+
241
+ ```python
242
+ # Deprecated - use client.hyperliquid.orderbook.get() instead
243
+ orderbook = client.orderbook.get("BTC")
244
+
245
+ # Deprecated - use client.hyperliquid.trades.list() instead
246
+ trades = client.trades.list("BTC", start=..., end=...)
219
247
  ```
220
248
 
221
249
  ## WebSocket Client
@@ -1,6 +1,10 @@
1
1
  # oxarchive
2
2
 
3
- Official Python SDK for [0xarchive](https://0xarchive.io) - Hyperliquid Historical Data API.
3
+ Official Python SDK for [0xarchive](https://0xarchive.io) - Historical Market Data API.
4
+
5
+ Supports multiple exchanges:
6
+ - **Hyperliquid** - Perpetuals data from April 2023
7
+ - **Lighter.xyz** - Perpetuals data (August 2025+ for fills, Jan 2026+ for OB, OI, Funding Rate)
4
8
 
5
9
  ## Installation
6
10
 
@@ -21,12 +25,16 @@ from oxarchive import Client
21
25
 
22
26
  client = Client(api_key="ox_your_api_key")
23
27
 
24
- # Get current order book
25
- orderbook = client.orderbook.get("BTC")
26
- print(f"BTC mid price: {orderbook.mid_price}")
28
+ # Hyperliquid data
29
+ hl_orderbook = client.hyperliquid.orderbook.get("BTC")
30
+ print(f"Hyperliquid BTC mid price: {hl_orderbook.mid_price}")
31
+
32
+ # Lighter.xyz data
33
+ lighter_orderbook = client.lighter.orderbook.get("BTC")
34
+ print(f"Lighter BTC mid price: {lighter_orderbook.mid_price}")
27
35
 
28
36
  # Get historical order book snapshots
29
- history = client.orderbook.history(
37
+ history = client.hyperliquid.orderbook.history(
30
38
  "ETH",
31
39
  start="2024-01-01",
32
40
  end="2024-01-02",
@@ -45,10 +53,13 @@ from oxarchive import Client
45
53
  async def main():
46
54
  client = Client(api_key="ox_your_api_key")
47
55
 
48
- # Async get
49
- orderbook = await client.orderbook.aget("BTC")
56
+ # Async get (Hyperliquid)
57
+ orderbook = await client.hyperliquid.orderbook.aget("BTC")
50
58
  print(f"BTC mid price: {orderbook.mid_price}")
51
59
 
60
+ # Async get (Lighter.xyz)
61
+ lighter_ob = await client.lighter.orderbook.aget("BTC")
62
+
52
63
  # Don't forget to close the client
53
64
  await client.aclose()
54
65
 
@@ -59,7 +70,7 @@ Or use as async context manager:
59
70
 
60
71
  ```python
61
72
  async with Client(api_key="ox_your_api_key") as client:
62
- orderbook = await client.orderbook.aget("BTC")
73
+ orderbook = await client.hyperliquid.orderbook.aget("BTC")
63
74
  ```
64
75
 
65
76
  ## Configuration
@@ -74,20 +85,25 @@ client = Client(
74
85
 
75
86
  ## REST API Reference
76
87
 
88
+ All examples use `client.hyperliquid.*` but the same methods are available on `client.lighter.*` for Lighter.xyz data.
89
+
77
90
  ### Order Book
78
91
 
79
92
  ```python
80
- # Get current order book
81
- orderbook = client.orderbook.get("BTC")
93
+ # Get current order book (Hyperliquid)
94
+ orderbook = client.hyperliquid.orderbook.get("BTC")
95
+
96
+ # Get current order book (Lighter.xyz)
97
+ orderbook = client.lighter.orderbook.get("BTC")
82
98
 
83
99
  # Get order book at specific timestamp
84
- historical = client.orderbook.get("BTC", timestamp=1704067200000)
100
+ historical = client.hyperliquid.orderbook.get("BTC", timestamp=1704067200000)
85
101
 
86
102
  # Get with limited depth
87
- shallow = client.orderbook.get("BTC", depth=10)
103
+ shallow = client.hyperliquid.orderbook.get("BTC", depth=10)
88
104
 
89
105
  # Get historical snapshots (start and end are required)
90
- history = client.orderbook.history(
106
+ history = client.hyperliquid.orderbook.history(
91
107
  "BTC",
92
108
  start="2024-01-01",
93
109
  end="2024-01-02",
@@ -96,8 +112,8 @@ history = client.orderbook.history(
96
112
  )
97
113
 
98
114
  # Async versions
99
- orderbook = await client.orderbook.aget("BTC")
100
- history = await client.orderbook.ahistory("BTC", start=..., end=...)
115
+ orderbook = await client.hyperliquid.orderbook.aget("BTC")
116
+ history = await client.hyperliquid.orderbook.ahistory("BTC", start=..., end=...)
101
117
  ```
102
118
 
103
119
  ### Trades
@@ -106,15 +122,15 @@ The trades API uses cursor-based pagination for efficient retrieval of large dat
106
122
 
107
123
  ```python
108
124
  # Get recent trades
109
- recent = client.trades.recent("BTC", limit=100)
125
+ recent = client.hyperliquid.trades.recent("BTC", limit=100)
110
126
 
111
127
  # Get trade history with cursor-based pagination
112
- result = client.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
128
+ result = client.hyperliquid.trades.list("ETH", start="2024-01-01", end="2024-01-02", limit=1000)
113
129
  trades = result.data
114
130
 
115
131
  # Paginate through all results
116
132
  while result.next_cursor:
117
- result = client.trades.list(
133
+ result = client.hyperliquid.trades.list(
118
134
  "ETH",
119
135
  start="2024-01-01",
120
136
  end="2024-01-02",
@@ -124,61 +140,73 @@ while result.next_cursor:
124
140
  trades.extend(result.data)
125
141
 
126
142
  # Filter by side
127
- buys = client.trades.list("BTC", start=..., end=..., side="buy")
143
+ buys = client.hyperliquid.trades.list("BTC", start=..., end=..., side="buy")
128
144
 
129
145
  # Async versions
130
- recent = await client.trades.arecent("BTC")
131
- result = await client.trades.alist("ETH", start=..., end=...)
146
+ recent = await client.hyperliquid.trades.arecent("BTC")
147
+ result = await client.hyperliquid.trades.alist("ETH", start=..., end=...)
132
148
  ```
133
149
 
134
150
  ### Instruments
135
151
 
136
152
  ```python
137
153
  # List all trading instruments
138
- instruments = client.instruments.list()
154
+ instruments = client.hyperliquid.instruments.list()
139
155
 
140
156
  # Get specific instrument details
141
- btc = client.instruments.get("BTC")
157
+ btc = client.hyperliquid.instruments.get("BTC")
142
158
 
143
159
  # Async versions
144
- instruments = await client.instruments.alist()
145
- btc = await client.instruments.aget("BTC")
160
+ instruments = await client.hyperliquid.instruments.alist()
161
+ btc = await client.hyperliquid.instruments.aget("BTC")
146
162
  ```
147
163
 
148
164
  ### Funding Rates
149
165
 
150
166
  ```python
151
167
  # Get current funding rate
152
- current = client.funding.current("BTC")
168
+ current = client.hyperliquid.funding.current("BTC")
153
169
 
154
170
  # Get funding rate history (start is required)
155
- history = client.funding.history(
171
+ history = client.hyperliquid.funding.history(
156
172
  "ETH",
157
173
  start="2024-01-01",
158
174
  end="2024-01-07"
159
175
  )
160
176
 
161
177
  # Async versions
162
- current = await client.funding.acurrent("BTC")
163
- history = await client.funding.ahistory("ETH", start=..., end=...)
178
+ current = await client.hyperliquid.funding.acurrent("BTC")
179
+ history = await client.hyperliquid.funding.ahistory("ETH", start=..., end=...)
164
180
  ```
165
181
 
166
182
  ### Open Interest
167
183
 
168
184
  ```python
169
185
  # Get current open interest
170
- current = client.open_interest.current("BTC")
186
+ current = client.hyperliquid.open_interest.current("BTC")
171
187
 
172
188
  # Get open interest history (start is required)
173
- history = client.open_interest.history(
189
+ history = client.hyperliquid.open_interest.history(
174
190
  "ETH",
175
191
  start="2024-01-01",
176
192
  end="2024-01-07"
177
193
  )
178
194
 
179
195
  # Async versions
180
- current = await client.open_interest.acurrent("BTC")
181
- history = await client.open_interest.ahistory("ETH", start=..., end=...)
196
+ current = await client.hyperliquid.open_interest.acurrent("BTC")
197
+ history = await client.hyperliquid.open_interest.ahistory("ETH", start=..., end=...)
198
+ ```
199
+
200
+ ### Legacy API (Deprecated)
201
+
202
+ The following legacy methods are deprecated and will be removed in v2.0. They default to Hyperliquid data:
203
+
204
+ ```python
205
+ # Deprecated - use client.hyperliquid.orderbook.get() instead
206
+ orderbook = client.orderbook.get("BTC")
207
+
208
+ # Deprecated - use client.hyperliquid.trades.list() instead
209
+ trades = client.trades.list("BTC", start=..., end=...)
182
210
  ```
183
211
 
184
212
  ## WebSocket Client
@@ -1,22 +1,28 @@
1
1
  """
2
2
  oxarchive - Official Python SDK for 0xarchive
3
3
 
4
- Hyperliquid Historical Data API.
4
+ Historical Market Data API for multiple exchanges:
5
+ - Hyperliquid (perpetuals data from April 2023)
6
+ - Lighter.xyz (perpetuals data)
5
7
 
6
8
  Example:
7
9
  >>> from oxarchive import Client
8
10
  >>>
9
11
  >>> client = Client(api_key="ox_your_api_key")
10
12
  >>>
11
- >>> # Get current order book
12
- >>> orderbook = client.orderbook.get("BTC")
13
- >>> print(f"BTC mid price: {orderbook.mid_price}")
13
+ >>> # Hyperliquid data
14
+ >>> hl_orderbook = client.hyperliquid.orderbook.get("BTC")
15
+ >>> print(f"BTC mid price: {hl_orderbook.mid_price}")
16
+ >>>
17
+ >>> # Lighter.xyz data
18
+ >>> lighter_orderbook = client.lighter.orderbook.get("BTC")
14
19
  >>>
15
20
  >>> # Get historical snapshots
16
- >>> history = client.orderbook.history("ETH", start="2024-01-01", end="2024-01-02")
21
+ >>> history = client.hyperliquid.orderbook.history("ETH", start="2024-01-01", end="2024-01-02")
17
22
  """
18
23
 
19
24
  from .client import Client
25
+ from .exchanges import HyperliquidClient, LighterClient
20
26
  from .types import (
21
27
  OrderBook,
22
28
  Trade,
@@ -57,11 +63,14 @@ except ImportError:
57
63
  OxArchiveWs = None # type: ignore
58
64
  WsOptions = None # type: ignore
59
65
 
60
- __version__ = "0.3.5"
66
+ __version__ = "0.4.1"
61
67
 
62
68
  __all__ = [
63
69
  # Client
64
70
  "Client",
71
+ # Exchange Clients
72
+ "HyperliquidClient",
73
+ "LighterClient",
65
74
  # WebSocket Client
66
75
  "OxArchiveWs",
67
76
  "WsOptions",
@@ -0,0 +1,132 @@
1
+ """0xarchive API client."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ from .http import HttpClient
8
+ from .exchanges import HyperliquidClient, LighterClient
9
+ from .resources import (
10
+ OrderBookResource,
11
+ TradesResource,
12
+ InstrumentsResource,
13
+ FundingResource,
14
+ OpenInterestResource,
15
+ )
16
+
17
+ DEFAULT_BASE_URL = "https://api.0xarchive.io"
18
+ DEFAULT_TIMEOUT = 30.0
19
+
20
+
21
+ class Client:
22
+ """
23
+ 0xarchive API client.
24
+
25
+ Supports multiple exchanges:
26
+ - `client.hyperliquid` - Hyperliquid perpetuals (April 2023+)
27
+ - `client.lighter` - Lighter.xyz perpetuals
28
+
29
+ Example:
30
+ >>> from oxarchive import Client
31
+ >>>
32
+ >>> client = Client(api_key="ox_your_api_key")
33
+ >>>
34
+ >>> # Hyperliquid data
35
+ >>> hl_orderbook = client.hyperliquid.orderbook.get("BTC")
36
+ >>> print(f"BTC mid price: {hl_orderbook.mid_price}")
37
+ >>>
38
+ >>> # Lighter.xyz data
39
+ >>> lighter_orderbook = client.lighter.orderbook.get("BTC")
40
+ >>>
41
+ >>> # Get historical snapshots
42
+ >>> history = client.hyperliquid.orderbook.history("ETH", start="2024-01-01", end="2024-01-02")
43
+ >>>
44
+ >>> # List all instruments
45
+ >>> instruments = client.hyperliquid.instruments.list()
46
+
47
+ Async example:
48
+ >>> import asyncio
49
+ >>> from oxarchive import Client
50
+ >>>
51
+ >>> async def main():
52
+ ... client = Client(api_key="ox_your_api_key")
53
+ ... orderbook = await client.hyperliquid.orderbook.aget("BTC")
54
+ ... print(f"BTC mid price: {orderbook.mid_price}")
55
+ ... await client.aclose()
56
+ >>>
57
+ >>> asyncio.run(main())
58
+
59
+ Legacy usage (deprecated, will be removed in v2.0):
60
+ >>> # These still work but use client.hyperliquid.* instead
61
+ >>> orderbook = client.orderbook.get("BTC") # deprecated
62
+ """
63
+
64
+ def __init__(
65
+ self,
66
+ api_key: str,
67
+ *,
68
+ base_url: Optional[str] = None,
69
+ timeout: Optional[float] = None,
70
+ ):
71
+ """
72
+ Create a new 0xarchive client.
73
+
74
+ Args:
75
+ api_key: Your 0xarchive API key
76
+ base_url: Base URL for the API (defaults to https://api.0xarchive.io)
77
+ timeout: Request timeout in seconds (defaults to 30.0)
78
+ """
79
+ if not api_key:
80
+ raise ValueError("API key is required. Get one at https://0xarchive.io/signup")
81
+
82
+ self._http = HttpClient(
83
+ base_url=base_url or DEFAULT_BASE_URL,
84
+ api_key=api_key,
85
+ timeout=timeout or DEFAULT_TIMEOUT,
86
+ )
87
+
88
+ # Exchange-specific clients (recommended)
89
+ self.hyperliquid = HyperliquidClient(self._http)
90
+ """Hyperliquid exchange data (orderbook, trades, funding, OI from April 2023)"""
91
+
92
+ self.lighter = LighterClient(self._http)
93
+ """Lighter.xyz exchange data (August 2025+)"""
94
+
95
+ # Legacy resource namespaces (deprecated - use client.hyperliquid.* instead)
96
+ # These will be removed in v2.0
97
+ # Note: Using /v1/hyperliquid base path for backward compatibility
98
+ legacy_base = "/v1/hyperliquid"
99
+ self.orderbook = OrderBookResource(self._http, legacy_base)
100
+ """[DEPRECATED] Use client.hyperliquid.orderbook instead"""
101
+
102
+ self.trades = TradesResource(self._http, legacy_base)
103
+ """[DEPRECATED] Use client.hyperliquid.trades instead"""
104
+
105
+ self.instruments = InstrumentsResource(self._http, legacy_base)
106
+ """[DEPRECATED] Use client.hyperliquid.instruments instead"""
107
+
108
+ self.funding = FundingResource(self._http, legacy_base)
109
+ """[DEPRECATED] Use client.hyperliquid.funding instead"""
110
+
111
+ self.open_interest = OpenInterestResource(self._http, legacy_base)
112
+ """[DEPRECATED] Use client.hyperliquid.open_interest instead"""
113
+
114
+ def close(self) -> None:
115
+ """Close the HTTP client and release resources."""
116
+ self._http.close()
117
+
118
+ async def aclose(self) -> None:
119
+ """Close the async HTTP client and release resources."""
120
+ await self._http.aclose()
121
+
122
+ def __enter__(self) -> "Client":
123
+ return self
124
+
125
+ def __exit__(self, *args) -> None:
126
+ self.close()
127
+
128
+ async def __aenter__(self) -> "Client":
129
+ return self
130
+
131
+ async def __aexit__(self, *args) -> None:
132
+ await self.aclose()
@@ -0,0 +1,76 @@
1
+ """Exchange-specific client classes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .http import HttpClient
6
+ from .resources import (
7
+ OrderBookResource,
8
+ TradesResource,
9
+ InstrumentsResource,
10
+ FundingResource,
11
+ OpenInterestResource,
12
+ )
13
+
14
+
15
+ class HyperliquidClient:
16
+ """
17
+ Hyperliquid exchange client.
18
+
19
+ Access Hyperliquid market data through the 0xarchive API.
20
+
21
+ Example:
22
+ >>> client = oxarchive.Client(api_key="...")
23
+ >>> orderbook = client.hyperliquid.orderbook.get("BTC")
24
+ >>> trades = client.hyperliquid.trades.list("ETH", start=..., end=...)
25
+ """
26
+
27
+ def __init__(self, http: HttpClient):
28
+ self._http = http
29
+ base_path = "/v1/hyperliquid"
30
+
31
+ self.orderbook = OrderBookResource(http, base_path)
32
+ """Order book data (L2 snapshots from April 2023)"""
33
+
34
+ self.trades = TradesResource(http, base_path)
35
+ """Trade/fill history"""
36
+
37
+ self.instruments = InstrumentsResource(http, base_path)
38
+ """Trading instruments metadata"""
39
+
40
+ self.funding = FundingResource(http, base_path)
41
+ """Funding rates"""
42
+
43
+ self.open_interest = OpenInterestResource(http, base_path)
44
+ """Open interest"""
45
+
46
+
47
+ class LighterClient:
48
+ """
49
+ Lighter.xyz exchange client.
50
+
51
+ Access Lighter.xyz market data through the 0xarchive API.
52
+
53
+ Example:
54
+ >>> client = oxarchive.Client(api_key="...")
55
+ >>> orderbook = client.lighter.orderbook.get("BTC")
56
+ >>> trades = client.lighter.trades.list("ETH", start=..., end=...)
57
+ """
58
+
59
+ def __init__(self, http: HttpClient):
60
+ self._http = http
61
+ base_path = "/v1/lighter"
62
+
63
+ self.orderbook = OrderBookResource(http, base_path)
64
+ """Order book data (L2 snapshots)"""
65
+
66
+ self.trades = TradesResource(http, base_path)
67
+ """Trade/fill history"""
68
+
69
+ self.instruments = InstrumentsResource(http, base_path)
70
+ """Trading instruments metadata"""
71
+
72
+ self.funding = FundingResource(http, base_path)
73
+ """Funding rates"""
74
+
75
+ self.open_interest = OpenInterestResource(http, base_path)
76
+ """Open interest"""