ironflow-sdk 0.1.0__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.
@@ -0,0 +1,4 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ *.egg-info/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ironflow
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,254 @@
1
+ Metadata-Version: 2.4
2
+ Name: ironflow-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for Ironflow market data API — on-chain derivatives data
5
+ Project-URL: Homepage, https://ironflow.sh
6
+ Project-URL: Documentation, https://docs.ironflow.sh
7
+ Project-URL: Support, https://docs.ironflow.sh
8
+ Author-email: Ironflow <hello@ironflow.sh>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: crypto,defi,hyperliquid,ironflow,market-data,perpetuals,sdk,trading,websocket
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Framework :: AsyncIO
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: httpx>=0.27
25
+ Requires-Dist: websockets>=12
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
28
+ Requires-Dist: pytest>=8; extra == 'dev'
29
+ Requires-Dist: respx>=0.21; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # ironflow
33
+
34
+ Python SDK for the [Ironflow](https://ironflow.sh) market data API — on-chain derivatives data.
35
+
36
+ - Async-first with `httpx` and `websockets`
37
+ - Typed dataclass responses for all endpoints
38
+ - Automatic pagination with `await page.next()`
39
+ - Typed WebSocket streams with async generators
40
+ - Full type annotations (`py.typed`)
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install ironflow-sdk
46
+ ```
47
+
48
+ Requires Python 3.10+.
49
+
50
+ ## Quick Start
51
+
52
+ ```python
53
+ from ironflow_sdk import Ironflow
54
+
55
+ async with Ironflow("if_your_api_key") as client:
56
+ # Get recent trades
57
+ page = await client.trades("BTC-PERP", limit=10)
58
+ for trade in page.data:
59
+ print(trade.price, trade.size, trade.side)
60
+
61
+ # Paginate
62
+ if page.has_more:
63
+ next_page = await page.next()
64
+ ```
65
+
66
+ ## Configuration
67
+
68
+ ```python
69
+ client = Ironflow(
70
+ "if_your_api_key",
71
+ base_url="https://api.ironflow.sh", # default
72
+ source="hyperliquid", # default
73
+ timeout=30.0, # request timeout in seconds (default: 30)
74
+ )
75
+ ```
76
+
77
+ ## REST Endpoints
78
+
79
+ ### Market Data
80
+
81
+ ```python
82
+ async with Ironflow("if_your_api_key") as client:
83
+ # Trades
84
+ trades = await client.trades("BTC-PERP", limit=100)
85
+
86
+ # Fills (requires address)
87
+ fills = await client.fills("0xabc...", market="ETH-PERP")
88
+
89
+ # Order book snapshot
90
+ book = await client.book("BTC-PERP")
91
+ # book.bids[0].price, book.bids[0].size
92
+
93
+ # OHLCV candles
94
+ candles = await client.candles("BTC-PERP", "1h", limit=24)
95
+
96
+ # Liquidations
97
+ liqs = await client.liquidations("BTC-PERP")
98
+
99
+ # Funding rates
100
+ rates = await client.funding("BTC-PERP")
101
+
102
+ # Open interest
103
+ oi = await client.open_interest("BTC-PERP")
104
+
105
+ # Mark prices
106
+ prices = await client.mark_prices("BTC-PERP")
107
+
108
+ # Deposits & withdrawals
109
+ deps = await client.deposits(address="0xabc...")
110
+ wds = await client.withdrawals(address="0xabc...")
111
+
112
+ # Order statuses
113
+ orders = await client.order_statuses(address="0xabc...")
114
+
115
+ # Vault operations
116
+ vaults = await client.vault_operations(vault="HLP")
117
+ ```
118
+
119
+ ### Analytics (Builder+)
120
+
121
+ ```python
122
+ flows = await client.net_flows(interval="1d", limit=7)
123
+ # flows[0].deposits, flows[0].withdrawals, flows[0].net_flow
124
+
125
+ levels = await client.liquidation_levels("BTC-PERP", bucket_size=100)
126
+ # levels[0].price_bucket, levels[0].count, levels[0].total_size
127
+
128
+ order_flow = await client.order_flow()
129
+ # order_flow[0].total_orders, order_flow[0].filled_orders, order_flow[0].fill_rate
130
+
131
+ leaderboard = await client.vault_leaderboard()
132
+ # leaderboard[0].vault, leaderboard[0].total_deposits, leaderboard[0].net_flow
133
+
134
+ funding = await client.funding_stats("BTC-PERP", interval="8h")
135
+ # funding[0].avg_rate, funding[0].min_rate, funding[0].max_rate
136
+ ```
137
+
138
+ ### Triggers
139
+
140
+ ```python
141
+ # Create a webhook trigger
142
+ trigger = await client.create_trigger(
143
+ name="whale-alert",
144
+ channel="trades",
145
+ webhook_url="https://your-server.com/hook",
146
+ rule={"condition": {"field": "data.size", "op": "gt", "value": "100"}},
147
+ )
148
+
149
+ # List, toggle, delete
150
+ triggers = await client.list_triggers()
151
+ await client.toggle_trigger(trigger.id, is_active=False)
152
+ await client.delete_trigger(trigger.id)
153
+
154
+ # Test a rule without creating
155
+ matched = await client.test_trigger(
156
+ rule={"condition": {"field": "data.size", "op": "gt", "value": "10"}},
157
+ event={"data": {"size": "50", "market": "BTC-PERP"}},
158
+ )
159
+ print(matched) # True
160
+ ```
161
+
162
+ ### Cohorts (Enterprise)
163
+
164
+ ```python
165
+ cohorts = await client.list_cohorts()
166
+ addrs = await client.cohort_addresses("top_pnl_30d")
167
+ await client.create_cohort("my_whales", ["0xabc...", "0xdef..."])
168
+ await client.delete_cohort("my_whales")
169
+ ```
170
+
171
+ ### Export (Builder+)
172
+
173
+ ```python
174
+ data = await client.export_data(
175
+ "fills",
176
+ market="BTC-PERP",
177
+ format="csv",
178
+ )
179
+ # data is bytes — write to file or parse with pandas
180
+ import pandas as pd
181
+ df = pd.read_csv(io.BytesIO(data))
182
+ ```
183
+
184
+ ### Status
185
+
186
+ ```python
187
+ status = await client.status()
188
+ print(status.status) # "ok"
189
+ print(status.venues["hyperliquid"].streams["fills"].age_seconds)
190
+ ```
191
+
192
+ ### Info API Proxy
193
+
194
+ ```python
195
+ meta = await client.info({"type": "metaAndAssetCtxs"})
196
+ ```
197
+
198
+ ## WebSocket Streaming
199
+
200
+ All stream methods return typed async generators:
201
+
202
+ ```python
203
+ # Real-time trades
204
+ async for trade in client.stream.trades("BTC-PERP"):
205
+ print(trade.price, trade.size, trade.side)
206
+
207
+ # Wallet fills (copy trading)
208
+ async for fill in client.stream.fills("0xleader"):
209
+ print(fill.side, fill.size, fill.market)
210
+
211
+ # Order book updates
212
+ async for snap in client.stream.book("ETH-PERP"):
213
+ print(snap.bids[0].price, snap.asks[0].price)
214
+
215
+ # Filter by minimum size
216
+ async for trade in client.stream.trades("BTC-PERP", min_size="10"):
217
+ pass # Only trades >= 10 BTC
218
+ ```
219
+
220
+ Available streams: `trades`, `fills`, `book`, `book_l4`, `orders`, `liquidations`, `funding_rates`, `deposits`, `withdrawals`, `vault_operations`.
221
+
222
+ ## Error Handling
223
+
224
+ ```python
225
+ from ironflow_sdk import Ironflow, RateLimitError, AuthError, TierError, QueryWindowError
226
+
227
+ try:
228
+ trades = await client.trades("BTC-PERP")
229
+ except RateLimitError as e:
230
+ print(f"Rate limited, retry in {e.retry_after_ms}ms")
231
+ except AuthError:
232
+ print("Invalid API key")
233
+ except TierError:
234
+ print("Upgrade your plan for this endpoint")
235
+ except QueryWindowError:
236
+ print("Time range too wide for your tier")
237
+ ```
238
+
239
+ ## Pagination
240
+
241
+ All list endpoints return a `Page[T]` with async pagination:
242
+
243
+ ```python
244
+ page = await client.trades("BTC-PERP", limit=1000)
245
+ all_trades = list(page.data)
246
+
247
+ while page.has_more:
248
+ page = await page.next()
249
+ all_trades.extend(page.data)
250
+ ```
251
+
252
+ ## License
253
+
254
+ MIT
@@ -0,0 +1,223 @@
1
+ # ironflow
2
+
3
+ Python SDK for the [Ironflow](https://ironflow.sh) market data API — on-chain derivatives data.
4
+
5
+ - Async-first with `httpx` and `websockets`
6
+ - Typed dataclass responses for all endpoints
7
+ - Automatic pagination with `await page.next()`
8
+ - Typed WebSocket streams with async generators
9
+ - Full type annotations (`py.typed`)
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pip install ironflow-sdk
15
+ ```
16
+
17
+ Requires Python 3.10+.
18
+
19
+ ## Quick Start
20
+
21
+ ```python
22
+ from ironflow_sdk import Ironflow
23
+
24
+ async with Ironflow("if_your_api_key") as client:
25
+ # Get recent trades
26
+ page = await client.trades("BTC-PERP", limit=10)
27
+ for trade in page.data:
28
+ print(trade.price, trade.size, trade.side)
29
+
30
+ # Paginate
31
+ if page.has_more:
32
+ next_page = await page.next()
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ ```python
38
+ client = Ironflow(
39
+ "if_your_api_key",
40
+ base_url="https://api.ironflow.sh", # default
41
+ source="hyperliquid", # default
42
+ timeout=30.0, # request timeout in seconds (default: 30)
43
+ )
44
+ ```
45
+
46
+ ## REST Endpoints
47
+
48
+ ### Market Data
49
+
50
+ ```python
51
+ async with Ironflow("if_your_api_key") as client:
52
+ # Trades
53
+ trades = await client.trades("BTC-PERP", limit=100)
54
+
55
+ # Fills (requires address)
56
+ fills = await client.fills("0xabc...", market="ETH-PERP")
57
+
58
+ # Order book snapshot
59
+ book = await client.book("BTC-PERP")
60
+ # book.bids[0].price, book.bids[0].size
61
+
62
+ # OHLCV candles
63
+ candles = await client.candles("BTC-PERP", "1h", limit=24)
64
+
65
+ # Liquidations
66
+ liqs = await client.liquidations("BTC-PERP")
67
+
68
+ # Funding rates
69
+ rates = await client.funding("BTC-PERP")
70
+
71
+ # Open interest
72
+ oi = await client.open_interest("BTC-PERP")
73
+
74
+ # Mark prices
75
+ prices = await client.mark_prices("BTC-PERP")
76
+
77
+ # Deposits & withdrawals
78
+ deps = await client.deposits(address="0xabc...")
79
+ wds = await client.withdrawals(address="0xabc...")
80
+
81
+ # Order statuses
82
+ orders = await client.order_statuses(address="0xabc...")
83
+
84
+ # Vault operations
85
+ vaults = await client.vault_operations(vault="HLP")
86
+ ```
87
+
88
+ ### Analytics (Builder+)
89
+
90
+ ```python
91
+ flows = await client.net_flows(interval="1d", limit=7)
92
+ # flows[0].deposits, flows[0].withdrawals, flows[0].net_flow
93
+
94
+ levels = await client.liquidation_levels("BTC-PERP", bucket_size=100)
95
+ # levels[0].price_bucket, levels[0].count, levels[0].total_size
96
+
97
+ order_flow = await client.order_flow()
98
+ # order_flow[0].total_orders, order_flow[0].filled_orders, order_flow[0].fill_rate
99
+
100
+ leaderboard = await client.vault_leaderboard()
101
+ # leaderboard[0].vault, leaderboard[0].total_deposits, leaderboard[0].net_flow
102
+
103
+ funding = await client.funding_stats("BTC-PERP", interval="8h")
104
+ # funding[0].avg_rate, funding[0].min_rate, funding[0].max_rate
105
+ ```
106
+
107
+ ### Triggers
108
+
109
+ ```python
110
+ # Create a webhook trigger
111
+ trigger = await client.create_trigger(
112
+ name="whale-alert",
113
+ channel="trades",
114
+ webhook_url="https://your-server.com/hook",
115
+ rule={"condition": {"field": "data.size", "op": "gt", "value": "100"}},
116
+ )
117
+
118
+ # List, toggle, delete
119
+ triggers = await client.list_triggers()
120
+ await client.toggle_trigger(trigger.id, is_active=False)
121
+ await client.delete_trigger(trigger.id)
122
+
123
+ # Test a rule without creating
124
+ matched = await client.test_trigger(
125
+ rule={"condition": {"field": "data.size", "op": "gt", "value": "10"}},
126
+ event={"data": {"size": "50", "market": "BTC-PERP"}},
127
+ )
128
+ print(matched) # True
129
+ ```
130
+
131
+ ### Cohorts (Enterprise)
132
+
133
+ ```python
134
+ cohorts = await client.list_cohorts()
135
+ addrs = await client.cohort_addresses("top_pnl_30d")
136
+ await client.create_cohort("my_whales", ["0xabc...", "0xdef..."])
137
+ await client.delete_cohort("my_whales")
138
+ ```
139
+
140
+ ### Export (Builder+)
141
+
142
+ ```python
143
+ data = await client.export_data(
144
+ "fills",
145
+ market="BTC-PERP",
146
+ format="csv",
147
+ )
148
+ # data is bytes — write to file or parse with pandas
149
+ import pandas as pd
150
+ df = pd.read_csv(io.BytesIO(data))
151
+ ```
152
+
153
+ ### Status
154
+
155
+ ```python
156
+ status = await client.status()
157
+ print(status.status) # "ok"
158
+ print(status.venues["hyperliquid"].streams["fills"].age_seconds)
159
+ ```
160
+
161
+ ### Info API Proxy
162
+
163
+ ```python
164
+ meta = await client.info({"type": "metaAndAssetCtxs"})
165
+ ```
166
+
167
+ ## WebSocket Streaming
168
+
169
+ All stream methods return typed async generators:
170
+
171
+ ```python
172
+ # Real-time trades
173
+ async for trade in client.stream.trades("BTC-PERP"):
174
+ print(trade.price, trade.size, trade.side)
175
+
176
+ # Wallet fills (copy trading)
177
+ async for fill in client.stream.fills("0xleader"):
178
+ print(fill.side, fill.size, fill.market)
179
+
180
+ # Order book updates
181
+ async for snap in client.stream.book("ETH-PERP"):
182
+ print(snap.bids[0].price, snap.asks[0].price)
183
+
184
+ # Filter by minimum size
185
+ async for trade in client.stream.trades("BTC-PERP", min_size="10"):
186
+ pass # Only trades >= 10 BTC
187
+ ```
188
+
189
+ Available streams: `trades`, `fills`, `book`, `book_l4`, `orders`, `liquidations`, `funding_rates`, `deposits`, `withdrawals`, `vault_operations`.
190
+
191
+ ## Error Handling
192
+
193
+ ```python
194
+ from ironflow_sdk import Ironflow, RateLimitError, AuthError, TierError, QueryWindowError
195
+
196
+ try:
197
+ trades = await client.trades("BTC-PERP")
198
+ except RateLimitError as e:
199
+ print(f"Rate limited, retry in {e.retry_after_ms}ms")
200
+ except AuthError:
201
+ print("Invalid API key")
202
+ except TierError:
203
+ print("Upgrade your plan for this endpoint")
204
+ except QueryWindowError:
205
+ print("Time range too wide for your tier")
206
+ ```
207
+
208
+ ## Pagination
209
+
210
+ All list endpoints return a `Page[T]` with async pagination:
211
+
212
+ ```python
213
+ page = await client.trades("BTC-PERP", limit=1000)
214
+ all_trades = list(page.data)
215
+
216
+ while page.has_more:
217
+ page = await page.next()
218
+ all_trades.extend(page.data)
219
+ ```
220
+
221
+ ## License
222
+
223
+ MIT
@@ -0,0 +1,49 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ironflow-sdk"
7
+ version = "0.1.0"
8
+ description = "Python SDK for Ironflow market data API — on-chain derivatives data"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Ironflow", email = "hello@ironflow.sh" }]
13
+ keywords = ["ironflow", "market-data", "crypto", "defi", "perpetuals", "hyperliquid", "sdk", "trading", "websocket"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Framework :: AsyncIO",
24
+ "Topic :: Software Development :: Libraries",
25
+ "Typing :: Typed",
26
+ ]
27
+ dependencies = [
28
+ "httpx>=0.27",
29
+ "websockets>=12",
30
+ ]
31
+
32
+ [project.urls]
33
+ Homepage = "https://ironflow.sh"
34
+ Documentation = "https://docs.ironflow.sh"
35
+ Support = "https://docs.ironflow.sh"
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=8",
40
+ "pytest-asyncio>=0.24",
41
+ "respx>=0.21",
42
+ ]
43
+
44
+ [tool.hatch.build.targets.wheel]
45
+ packages = ["src/ironflow_sdk"]
46
+
47
+ [tool.pytest.ini_options]
48
+ asyncio_mode = "auto"
49
+ testpaths = ["tests"]