depthy-python 0.1.0__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.
depthy/__init__.py ADDED
@@ -0,0 +1,13 @@
1
+ """Depthy Python SDK — real-time crypto liquidity intelligence."""
2
+
3
+ from .client import AsyncDepthyClient, DepthyClient
4
+ from .exceptions import AuthError, DepthyError, NotFoundError, RateLimitError
5
+
6
+ __all__ = [
7
+ "DepthyClient",
8
+ "AsyncDepthyClient",
9
+ "DepthyError",
10
+ "AuthError",
11
+ "RateLimitError",
12
+ "NotFoundError",
13
+ ]
depthy/client.py ADDED
@@ -0,0 +1,200 @@
1
+ """Depthy Python SDK — sync and async clients for the Depthy REST API."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import httpx
6
+
7
+ from .exceptions import AuthError, DepthyError, NotFoundError, RateLimitError
8
+
9
+ DEFAULT_BASE_URL = "https://depthy.io"
10
+ DEFAULT_TIMEOUT = 30
11
+
12
+
13
+ def _normalize(symbol: str) -> str:
14
+ s = symbol.upper().strip()
15
+ if not s.endswith("-PERP"):
16
+ s += "-PERP"
17
+ return s
18
+
19
+
20
+ def _handle_error(resp: httpx.Response) -> None:
21
+ if resp.status_code == 401:
22
+ raise AuthError("Invalid API key. Get a free key at https://depthy.io", 401)
23
+ if resp.status_code == 403:
24
+ raise AuthError("This endpoint requires a Pro key. Upgrade at https://depthy.io", 403)
25
+ if resp.status_code == 404:
26
+ raise NotFoundError(f"Resource not found: {resp.url}", 404)
27
+ if resp.status_code == 429:
28
+ raise RateLimitError("Rate limit exceeded. Free tier: 30 req/min, 100/day", 429)
29
+ if resp.status_code >= 500:
30
+ raise DepthyError("Depthy API temporarily unavailable", resp.status_code)
31
+ resp.raise_for_status()
32
+
33
+
34
+ class DepthyClient:
35
+ """Synchronous Depthy API client."""
36
+
37
+ def __init__(
38
+ self,
39
+ api_key: str,
40
+ base_url: str = DEFAULT_BASE_URL,
41
+ timeout: float = DEFAULT_TIMEOUT,
42
+ ):
43
+ if not api_key:
44
+ raise ValueError("api_key is required. Get a free key at https://depthy.io")
45
+ self._client = httpx.Client(
46
+ base_url=base_url,
47
+ timeout=timeout,
48
+ headers={"Authorization": f"Bearer {api_key}"},
49
+ )
50
+
51
+ def close(self) -> None:
52
+ self._client.close()
53
+
54
+ def __enter__(self):
55
+ return self
56
+
57
+ def __exit__(self, *args):
58
+ self.close()
59
+
60
+ def _get(self, path: str, params: dict | None = None) -> dict:
61
+ resp = self._client.get(path, params=params)
62
+ _handle_error(resp)
63
+ return resp.json()
64
+
65
+ # ── Hyperliquid ────────────────────────────────────────────
66
+
67
+ def list_symbols(self, exchange: str = "hyperliquid") -> dict:
68
+ """List all available trading symbols."""
69
+ return self._get("/v1/symbols", {"exchange": exchange})
70
+
71
+ def get_depth(self, symbol: str, levels: int = 20) -> dict:
72
+ """Get order book depth and bid/ask imbalance."""
73
+ return self._get(f"/v1/depth/hyperliquid/{_normalize(symbol)}", {"levels": levels})
74
+
75
+ def get_depth_recent(self, symbol: str, minutes: int = 30) -> dict:
76
+ """Get recent depth snapshots over the last N minutes."""
77
+ return self._get(
78
+ f"/v1/depth/hyperliquid/{_normalize(symbol)}/recent", {"minutes": minutes}
79
+ )
80
+
81
+ def get_walls(self, symbol: str, min_size_usd: float = 100000) -> dict:
82
+ """Find large resting orders (walls) in the order book."""
83
+ return self._get(
84
+ f"/v1/walls/hyperliquid/{_normalize(symbol)}", {"min_size_usd": min_size_usd}
85
+ )
86
+
87
+ def get_liquidation_clusters(self, symbol: str) -> dict:
88
+ """Get liquidation cluster zones."""
89
+ return self._get(f"/v1/liquidations/hyperliquid/{_normalize(symbol)}/clusters")
90
+
91
+ def get_market(self, symbol: str) -> dict:
92
+ """Get market overview: price, volume, funding, open interest."""
93
+ return self._get(f"/v1/market/hyperliquid/{_normalize(symbol)}")
94
+
95
+ def get_oi_change(self, symbol: str) -> dict:
96
+ """Get open interest changes over recent time windows."""
97
+ return self._get("/api/oi/change", {"symbol": _normalize(symbol)})
98
+
99
+ def compare_symbols(self, symbols: list[str]) -> dict:
100
+ """Compare depth and liquidity across symbols. Requires Pro key."""
101
+ return self._get("/v1/compare/hyperliquid", {"symbols": ",".join(symbols)})
102
+
103
+ # ── Polymarket ─────────────────────────────────────────────
104
+
105
+ def list_pm_markets(self, market_type: str = "", limit: int = 20) -> dict:
106
+ """List active Polymarket prediction markets."""
107
+ params = {"limit": limit}
108
+ if market_type:
109
+ params["market_type"] = market_type
110
+ return self._get("/v1/polymarket/markets/active", params)
111
+
112
+ def get_pm_signals(self, limit: int = 10) -> dict:
113
+ """Get latest Polymarket trading signals."""
114
+ return self._get("/v1/pm/signals/latest", {"limit": limit})
115
+
116
+ def get_pm_top_wallets(self, limit: int = 10) -> dict:
117
+ """Get top-performing Polymarket wallets by profit."""
118
+ return self._get("/v1/pm/wallets/top", {"limit": limit})
119
+
120
+
121
+ class AsyncDepthyClient:
122
+ """Asynchronous Depthy API client."""
123
+
124
+ def __init__(
125
+ self,
126
+ api_key: str,
127
+ base_url: str = DEFAULT_BASE_URL,
128
+ timeout: float = DEFAULT_TIMEOUT,
129
+ ):
130
+ if not api_key:
131
+ raise ValueError("api_key is required. Get a free key at https://depthy.io")
132
+ self._client = httpx.AsyncClient(
133
+ base_url=base_url,
134
+ timeout=timeout,
135
+ headers={"Authorization": f"Bearer {api_key}"},
136
+ )
137
+
138
+ async def close(self) -> None:
139
+ await self._client.aclose()
140
+
141
+ async def __aenter__(self):
142
+ return self
143
+
144
+ async def __aexit__(self, *args):
145
+ await self.close()
146
+
147
+ async def _get(self, path: str, params: dict | None = None) -> dict:
148
+ resp = await self._client.get(path, params=params)
149
+ _handle_error(resp)
150
+ return resp.json()
151
+
152
+ # ── Hyperliquid ────────────────────────────────────────────
153
+
154
+ async def list_symbols(self, exchange: str = "hyperliquid") -> dict:
155
+ return await self._get("/v1/symbols", {"exchange": exchange})
156
+
157
+ async def get_depth(self, symbol: str, levels: int = 20) -> dict:
158
+ return await self._get(
159
+ f"/v1/depth/hyperliquid/{_normalize(symbol)}", {"levels": levels}
160
+ )
161
+
162
+ async def get_depth_recent(self, symbol: str, minutes: int = 30) -> dict:
163
+ return await self._get(
164
+ f"/v1/depth/hyperliquid/{_normalize(symbol)}/recent", {"minutes": minutes}
165
+ )
166
+
167
+ async def get_walls(self, symbol: str, min_size_usd: float = 100000) -> dict:
168
+ return await self._get(
169
+ f"/v1/walls/hyperliquid/{_normalize(symbol)}", {"min_size_usd": min_size_usd}
170
+ )
171
+
172
+ async def get_liquidation_clusters(self, symbol: str) -> dict:
173
+ return await self._get(
174
+ f"/v1/liquidations/hyperliquid/{_normalize(symbol)}/clusters"
175
+ )
176
+
177
+ async def get_market(self, symbol: str) -> dict:
178
+ return await self._get(f"/v1/market/hyperliquid/{_normalize(symbol)}")
179
+
180
+ async def get_oi_change(self, symbol: str) -> dict:
181
+ return await self._get("/api/oi/change", {"symbol": _normalize(symbol)})
182
+
183
+ async def compare_symbols(self, symbols: list[str]) -> dict:
184
+ return await self._get(
185
+ "/v1/compare/hyperliquid", {"symbols": ",".join(symbols)}
186
+ )
187
+
188
+ # ── Polymarket ─────────────────────────────────────────────
189
+
190
+ async def list_pm_markets(self, market_type: str = "", limit: int = 20) -> dict:
191
+ params = {"limit": limit}
192
+ if market_type:
193
+ params["market_type"] = market_type
194
+ return await self._get("/v1/polymarket/markets/active", params)
195
+
196
+ async def get_pm_signals(self, limit: int = 10) -> dict:
197
+ return await self._get("/v1/pm/signals/latest", {"limit": limit})
198
+
199
+ async def get_pm_top_wallets(self, limit: int = 10) -> dict:
200
+ return await self._get("/v1/pm/wallets/top", {"limit": limit})
depthy/exceptions.py ADDED
@@ -0,0 +1,24 @@
1
+ """Depthy SDK exceptions."""
2
+
3
+
4
+ class DepthyError(Exception):
5
+ """Base exception for Depthy SDK errors."""
6
+
7
+ def __init__(self, message: str, status_code: int | None = None):
8
+ self.status_code = status_code
9
+ super().__init__(message)
10
+
11
+
12
+ class AuthError(DepthyError):
13
+ """Invalid or missing API key."""
14
+ pass
15
+
16
+
17
+ class RateLimitError(DepthyError):
18
+ """Rate limit exceeded."""
19
+ pass
20
+
21
+
22
+ class NotFoundError(DepthyError):
23
+ """Resource not found."""
24
+ pass
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.4
2
+ Name: depthy-python
3
+ Version: 0.1.0
4
+ Summary: Python SDK for Depthy — real-time crypto liquidity intelligence
5
+ Project-URL: Homepage, https://depthy.io
6
+ Project-URL: Documentation, https://depthy.io/api-docs
7
+ Project-URL: Repository, https://github.com/depthy-io/depthy-python
8
+ Author-email: Depthy <hello@depthy.io>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: crypto,hyperliquid,liquidity,order-book,polymarket,sdk
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Topic :: Office/Business :: Financial
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: httpx>=0.24.0
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Depthy Python SDK
22
+
23
+ Python client for the [Depthy](https://depthy.io) API — real-time crypto order book depth, liquidity walls, liquidation clusters, and Polymarket signals.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ pip install depthy-python
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```python
34
+ from depthy import DepthyClient
35
+
36
+ client = DepthyClient(api_key="dk_live_your_key_here")
37
+
38
+ # List available symbols
39
+ symbols = client.list_symbols()
40
+
41
+ # Order book depth
42
+ depth = client.get_depth("BTC")
43
+
44
+ # Liquidity walls
45
+ walls = client.get_walls("ETH", min_size_usd=200000)
46
+
47
+ # Liquidation clusters
48
+ clusters = client.get_liquidation_clusters("SOL")
49
+
50
+ # Market overview
51
+ market = client.get_market("BTC")
52
+
53
+ # Open interest changes
54
+ oi = client.get_oi_change("BTC")
55
+
56
+ # Compare multiple symbols (Pro key required)
57
+ comparison = client.compare_symbols(["BTC", "ETH", "SOL"])
58
+ ```
59
+
60
+ ## Async Usage
61
+
62
+ ```python
63
+ from depthy import AsyncDepthyClient
64
+
65
+ async with AsyncDepthyClient(api_key="dk_live_your_key_here") as client:
66
+ depth = await client.get_depth("BTC")
67
+ walls = await client.get_walls("ETH")
68
+ ```
69
+
70
+ ## Polymarket
71
+
72
+ ```python
73
+ # Active prediction markets
74
+ markets = client.list_pm_markets(market_type="crypto_15m")
75
+
76
+ # Smart-money signals
77
+ signals = client.get_pm_signals(limit=10)
78
+
79
+ # Top wallets by profit
80
+ wallets = client.get_pm_top_wallets(limit=5)
81
+ ```
82
+
83
+ ## Error Handling
84
+
85
+ ```python
86
+ from depthy import DepthyClient, AuthError, RateLimitError, NotFoundError
87
+
88
+ client = DepthyClient(api_key="dk_live_...")
89
+
90
+ try:
91
+ depth = client.get_depth("BTC")
92
+ except AuthError:
93
+ print("Check your API key")
94
+ except RateLimitError:
95
+ print("Slow down — free tier: 30 req/min")
96
+ except NotFoundError:
97
+ print("Symbol not found")
98
+ ```
99
+
100
+ ## API Methods
101
+
102
+ | Method | Description | Free Tier |
103
+ |---|---|---|
104
+ | `list_symbols()` | List tradable symbols | Yes |
105
+ | `get_depth(symbol)` | Order book depth & imbalance | Yes (T1) |
106
+ | `get_depth_recent(symbol)` | Depth snapshots over time | Yes (T1) |
107
+ | `get_walls(symbol)` | Large resting orders | Yes (T1) |
108
+ | `get_liquidation_clusters(symbol)` | Liquidation risk zones | Yes (T1) |
109
+ | `get_market(symbol)` | Price, volume, funding, OI | Yes (T1) |
110
+ | `get_oi_change(symbol)` | Open interest changes | Yes |
111
+ | `compare_symbols(symbols)` | Multi-symbol comparison | Pro+ |
112
+ | `list_pm_markets()` | Polymarket markets | Yes |
113
+ | `get_pm_signals()` | Smart-money signals | Yes |
114
+ | `get_pm_top_wallets()` | Top wallets by profit | Yes |
115
+
116
+ ## Get an API Key
117
+
118
+ Sign up for a free key at [depthy.io](https://depthy.io).
119
+
120
+ ## Links
121
+
122
+ - [MCP Server](https://github.com/depthy-io/depthy-mcp) — For Claude Desktop, Cursor, etc.
123
+ - [API Docs](https://depthy.io/api-docs) — Full endpoint reference
124
+
125
+ ## License
126
+
127
+ MIT
@@ -0,0 +1,7 @@
1
+ depthy/__init__.py,sha256=0MyYyPhue7j3wdRRgMcDluxpA9xsnL39l7vCuAWYXfQ,339
2
+ depthy/client.py,sha256=OObrnpm6VQf61bRqxaYO2P5vXD_pQHu09fPD9AlXfrc,7734
3
+ depthy/exceptions.py,sha256=CmEGhS6SCtaVZ3h9-FguAEJQRMaGfUmxe4OA9Hh76cc,484
4
+ depthy_python-0.1.0.dist-info/METADATA,sha256=Zi_GSHQrFJgjWL-lnuVvhBtZeEQsTbnQbSpQ9Ns5H_w,3446
5
+ depthy_python-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
6
+ depthy_python-0.1.0.dist-info/licenses/LICENSE,sha256=__w8pkSfkWSCMHTk7FflzEl_EgIMWeVXjIfW1sbm7LY,1063
7
+ depthy_python-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Depthy
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.