proxyhat 0.2.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.
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any
5
+
6
+
7
+ @dataclass
8
+ class ProxyPreset:
9
+ id: str
10
+ name: str
11
+ data: dict[str, Any]
12
+ created_at: str | None = None
13
+
14
+ @classmethod
15
+ def from_dict(cls, data: dict[str, Any]) -> ProxyPreset:
16
+ return cls(
17
+ id=data.get("id", ""),
18
+ name=data.get("name", ""),
19
+ data=data.get("data", {}),
20
+ created_at=data.get("created_at"),
21
+ )
@@ -0,0 +1,69 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any
5
+
6
+
7
+ @dataclass
8
+ class SubUser:
9
+ uuid: str
10
+ proxy_username: str
11
+ is_default_user: bool
12
+ is_traffic_limited: bool
13
+ used_traffic: int
14
+ traffic_limit: int
15
+ lifecycle_status: str
16
+ name: str | None
17
+ notes: str | None
18
+ sub_user_group_id: str | None
19
+ created_at: str
20
+ # Gateway password: present on list/get, masked for suspended/deleting sub-users.
21
+ proxy_password: str | None = None
22
+ # ISO timestamp when the sub-user was suspended (traffic overage), else None.
23
+ suspended_at: str | None = None
24
+
25
+ @classmethod
26
+ def from_dict(cls, data: dict[str, Any]) -> SubUser:
27
+ return cls(
28
+ uuid=data.get("uuid", ""),
29
+ proxy_username=data.get("proxy_username", ""),
30
+ is_default_user=data.get("is_default_user", False),
31
+ is_traffic_limited=data.get("is_traffic_limited", False),
32
+ used_traffic=data.get("used_traffic", 0),
33
+ traffic_limit=data.get("traffic_limit", 0),
34
+ lifecycle_status=data.get("lifecycle_status", ""),
35
+ name=data.get("name"),
36
+ notes=data.get("notes"),
37
+ sub_user_group_id=data.get("sub_user_group_id"),
38
+ created_at=data.get("created_at", ""),
39
+ proxy_password=data.get("proxy_password"),
40
+ suspended_at=data.get("suspended_at"),
41
+ )
42
+
43
+
44
+ @dataclass
45
+ class ResetUsageResponse:
46
+ reset: int
47
+
48
+ @classmethod
49
+ def from_dict(cls, data: dict[str, Any]) -> ResetUsageResponse:
50
+ return cls(reset=data.get("reset", 0))
51
+
52
+
53
+ @dataclass
54
+ class BulkDeleteResponse:
55
+ requested: int
56
+ deleted: int
57
+ skipped: int
58
+ not_found: int
59
+ failed: int
60
+
61
+ @classmethod
62
+ def from_dict(cls, data: dict[str, Any]) -> BulkDeleteResponse:
63
+ return cls(
64
+ requested=data.get("requested", 0),
65
+ deleted=data.get("deleted", 0),
66
+ skipped=data.get("skipped", 0),
67
+ not_found=data.get("not_found", 0),
68
+ failed=data.get("failed", 0),
69
+ )
@@ -0,0 +1,25 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Any
5
+
6
+
7
+ @dataclass
8
+ class SubUserGroup:
9
+ id: str
10
+ name: str
11
+ description: str | None
12
+ sub_users_count: int
13
+ created_at: str
14
+ sub_users: list[Any] = field(default_factory=list)
15
+
16
+ @classmethod
17
+ def from_dict(cls, data: dict[str, Any]) -> SubUserGroup:
18
+ return cls(
19
+ id=data.get("id", ""),
20
+ name=data.get("name", ""),
21
+ description=data.get("description"),
22
+ sub_users_count=data.get("sub_users_count", 0),
23
+ created_at=data.get("created_at", ""),
24
+ sub_users=data.get("sub_users", []),
25
+ )
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Any
5
+
6
+
7
+ @dataclass
8
+ class TwoFactorStatus:
9
+ enabled: bool
10
+
11
+ @classmethod
12
+ def from_dict(cls, data: dict[str, Any]) -> TwoFactorStatus:
13
+ return cls(enabled=data.get("enabled", False))
14
+
15
+
16
+ @dataclass
17
+ class TwoFactorEnableResponse:
18
+ qr: str
19
+ secret: str
20
+ recovery_codes: list[str] = field(default_factory=list)
21
+
22
+ @classmethod
23
+ def from_dict(cls, data: dict[str, Any]) -> TwoFactorEnableResponse:
24
+ return cls(
25
+ qr=data.get("qr", ""),
26
+ secret=data.get("secret", ""),
27
+ recovery_codes=data.get("recovery_codes", []),
28
+ )
29
+
30
+
31
+ @dataclass
32
+ class RecoveryCodes:
33
+ codes: list[str] = field(default_factory=list)
34
+
35
+ @classmethod
36
+ def from_dict(cls, data: dict[str, Any]) -> RecoveryCodes:
37
+ return cls(codes=data if isinstance(data, list) else data.get("codes", []))
@@ -0,0 +1,195 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxyhat
3
+ Version: 0.2.0
4
+ Summary: The official Python SDK for the ProxyHat residential proxy API
5
+ Project-URL: Homepage, https://proxyhat.com
6
+ Project-URL: Documentation, https://docs.proxyhat.com
7
+ Project-URL: Repository, https://github.com/ProxyHatCom/python-sdk
8
+ Project-URL: Changelog, https://github.com/ProxyHatCom/python-sdk/blob/main/CHANGELOG.md
9
+ Author-email: ProxyHat <support@proxyhat.com>
10
+ License-Expression: MIT
11
+ License-File: LICENSE
12
+ Keywords: api,proxy,proxyhat,residential-proxy,sdk
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: httpx>=0.24.0
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
27
+ Requires-Dist: pytest>=7.0; extra == 'dev'
28
+ Requires-Dist: respx>=0.20; extra == 'dev'
29
+ Requires-Dist: ruff>=0.4; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # ProxyHat Python SDK
33
+
34
+ The official Python SDK for the [ProxyHat](https://proxyhat.com?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=hero) residential proxy API.
35
+
36
+ [![CI](https://github.com/ProxyHatCom/python-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/ProxyHatCom/python-sdk/actions/workflows/ci.yml)
37
+ [![PyPI](https://img.shields.io/pypi/v/proxyhat)](https://pypi.org/project/proxyhat/)
38
+ [![Python](https://img.shields.io/pypi/pyversions/proxyhat)](https://pypi.org/project/proxyhat/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
40
+
41
+ ## Features
42
+
43
+ - **One-call proxy connection** — `client.connection_url()` turns your API key into a ready-to-use residential proxy URL
44
+ - Full coverage of the ProxyHat API
45
+ - Local gateway URL builder (`build_connection_url`) — no network needed
46
+ - Sync (`ProxyHat`) and async (`AsyncProxyHat`) clients
47
+ - Typed responses using dataclasses
48
+ - Comprehensive error handling with typed exceptions
49
+ - Pagination support for location endpoints
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install proxyhat
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ ```python
60
+ from proxyhat import ProxyHat
61
+
62
+ client = ProxyHat(api_key="ph_your_api_key")
63
+
64
+ # List sub-users
65
+ users = client.sub_users.list()
66
+ for user in users:
67
+ print(user.proxy_username, user.lifecycle_status)
68
+
69
+ # Create a sub-user
70
+ new_user = client.sub_users.create(
71
+ proxy_password="secure_pass",
72
+ is_traffic_limited=True,
73
+ traffic_limit="5GB",
74
+ name="Scraper",
75
+ )
76
+ print(new_user.uuid)
77
+ ```
78
+
79
+ ### Async Usage
80
+
81
+ ```python
82
+ import asyncio
83
+ from proxyhat import AsyncProxyHat
84
+
85
+ async def main():
86
+ async with AsyncProxyHat(api_key="ph_your_api_key") as client:
87
+ users = await client.sub_users.list()
88
+ for user in users:
89
+ print(user.proxy_username)
90
+
91
+ asyncio.run(main())
92
+ ```
93
+
94
+ ## Connecting to a proxy
95
+
96
+ From an API key to actually routing traffic in one call — the SDK looks up an active sub-user and builds the gateway URL for you:
97
+
98
+ ```python
99
+ from proxyhat import ProxyHat
100
+
101
+ proxy = ProxyHat(api_key="ph_your_api_key")
102
+
103
+ # Rotating residential IP, US exit:
104
+ url = proxy.connection_url(country="us")
105
+ # → http://<user>-country-us:<pass>@gate.proxyhat.com:8080
106
+
107
+ # Sticky session (same IP for 30m), city-targeted, SOCKS5:
108
+ sticky = proxy.connection_url(country="de", city="berlin", sticky="30m", protocol="socks5")
109
+
110
+ # Use it with any HTTP client:
111
+ import httpx
112
+ resp = httpx.get("https://api.ipify.org", proxy=url)
113
+ ```
114
+
115
+ **Offline builder** — if you already have a sub-user's credentials, build the URL with no network call:
116
+
117
+ ```python
118
+ from proxyhat import build_connection_url
119
+
120
+ url = build_connection_url(username="ph-8f2a1c", password="PxSecret123", country="gb", filter="high")
121
+ ```
122
+
123
+ **Server-built descriptor** — let the API assemble it (validates the sub-user is active):
124
+
125
+ ```python
126
+ d = proxy.proxy_descriptors.create(
127
+ sub_user_uuid=user.uuid,
128
+ protocol="http",
129
+ location={"country": "us", "city": "new_york"},
130
+ session={"mode": "sticky", "ttl": "30m"},
131
+ )
132
+ print(d.url)
133
+ ```
134
+
135
+ ## Authentication
136
+
137
+ Get your API key from the [ProxyHat Dashboard](https://dashboard.proxyhat.com/register?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=signup).
138
+
139
+ See the [Authentication Guide](https://docs.proxyhat.com/authentication?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=auth-guide) for details.
140
+
141
+ ## API Reference
142
+
143
+ | Resource | Methods |
144
+ |----------|---------|
145
+ | `client.auth` | `register`, `login`, `user`, `logout`, `supported_providers`, `social_accounts`, `disconnect_social`, `oauth_redirect` |
146
+ | `client.sub_users` | `list`, `create`, `get`, `update`, `delete`, `reset_usage`, `bulk_delete`, `bulk_move_to_group` |
147
+ | `client.sub_user_groups` | `list`, `create`, `get`, `update`, `delete` |
148
+ | `client.locations` | `countries`, `regions`, `cities`, `isps`, `zipcodes` |
149
+ | `client.analytics` | `traffic`, `traffic_total`, `requests`, `requests_total`, `domain_breakdown` |
150
+ | `client.proxy_presets` | `list`, `create`, `get`, `update`, `delete` |
151
+ | `client.proxy_descriptors` | `create` |
152
+ | `client.connection_url(...)` | build a ready proxy URL from an active sub-user |
153
+ | `client.profile` | `get_preferences`, `update_preferences`, `list_api_keys`, `create_api_key`, `delete_api_key`, `regenerate_api_key` |
154
+ | `client.two_factor` | `status`, `enable`, `confirm`, `disable`, `qr_code`, `recovery_codes`, `disable_by_recovery`, `change_password` |
155
+ | `client.email` | `request_change`, `confirm_change`, `cancel_change`, `resend_verification` |
156
+ | `client.coupons` | `validate`, `apply`, `redeem` |
157
+ | `client.plans` | `list_regular`, `list_subscriptions`, `get_regular`, `get_subscription`, `pricing_regular`, `pricing_subscriptions` |
158
+ | `client.payments` | `list`, `create`, `get`, `check`, `invoice`, `cryptocurrencies` |
159
+
160
+ ## Error Handling
161
+
162
+ ```python
163
+ from proxyhat import ProxyHat, ProxyHatError, NotFoundError, RateLimitError, ValidationError
164
+
165
+ client = ProxyHat(api_key="ph_your_api_key")
166
+
167
+ try:
168
+ user = client.sub_users.get("nonexistent-id")
169
+ except NotFoundError as e:
170
+ print(f"Not found: {e.message}")
171
+ except RateLimitError as e:
172
+ print(f"Rate limited. Retry after {e.retry_after}s")
173
+ except ValidationError as e:
174
+ print(f"Validation failed: {e.errors}")
175
+ except ProxyHatError as e:
176
+ print(f"API error {e.status_code}: {e.message}")
177
+ ```
178
+
179
+ See the [Error Handling Guide](https://docs.proxyhat.com/errors?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=error-handling) for the full list of error codes.
180
+
181
+ ## Documentation
182
+
183
+ - [Getting Started](https://docs.proxyhat.com?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=getting-started)
184
+ - [API Reference](https://docs.proxyhat.com/api/auth?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=api-reference)
185
+ - [Full Documentation](https://docs.proxyhat.com?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=docs-home)
186
+
187
+ ## Links
188
+
189
+ - [ProxyHat](https://proxyhat.com?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=links) — Residential & mobile proxy network
190
+ - [Dashboard](https://dashboard.proxyhat.com?utm_source=github&utm_medium=readme&utm_campaign=sdk-python&utm_content=links) — Manage proxies, sub-users, and API keys
191
+ - [GitHub](https://github.com/ProxyHatCom/python-sdk) — Source code & issue tracker
192
+
193
+ ## License
194
+
195
+ MIT — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,39 @@
1
+ proxyhat/__init__.py,sha256=_gzwuxhQzFqx95etmCKysn-tjiEBT1NHGylPYholH8w,865
2
+ proxyhat/_base_client.py,sha256=19KsPRECsyhjl1cugoX-DfmXm85_WmO0rPGrI1eBouQ,2998
3
+ proxyhat/async_client.py,sha256=E9xNPz82VnJZIk2dX7drPEsyAAQFVjxKCyqOLV9Er5A,4943
4
+ proxyhat/client.py,sha256=32waqyQmS_kNJyaHoTmMvln0ixGX8Ef0Oj8HHDGaFD4,4893
5
+ proxyhat/connection.py,sha256=B8BbpKw_jiknvtAXxOn4QH9I_gL6ZkZh39eyL5BoQBs,2795
6
+ proxyhat/errors.py,sha256=6k_7oXxcgUvBpyjzZPC5T-vWlOepwMr9tF074Laybqo,2112
7
+ proxyhat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ proxyhat/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ proxyhat/resources/analytics.py,sha256=NfbvTAk59358krtsKe1EtEiWDGRxYoQ94gpAayFhYPg,4484
10
+ proxyhat/resources/auth.py,sha256=o1cIARdGuOEN45fXtNrR0SqQYqCfBIub5LC7F2G62Pk,5309
11
+ proxyhat/resources/coupons.py,sha256=5M3vmROrpAH7PMUQDKdGzpzhdbSemxIfj1nO-mmOdUs,3197
12
+ proxyhat/resources/email.py,sha256=ERBjWHe_VVxk30NjlvgwAg5NJCMAmJUgoAbalCZaqvI,2420
13
+ proxyhat/resources/locations.py,sha256=tn3bLccWNVwgK0Ni0Z9YUT7BsStyOFYJc2x_60bjz2E,7472
14
+ proxyhat/resources/payments.py,sha256=kP3ZSYb-dDZSgxPUzfeRs4rADw5Tz78QB1QQH08rv9M,3714
15
+ proxyhat/resources/plans.py,sha256=XuKz4V21Ag8ljVemNG2ksJWVORyVyHPcANAPGsOs_Rs,2972
16
+ proxyhat/resources/profile.py,sha256=ENgJCX838FfJMe_gVch92k1leu3riKKG6V-VqGKtrTI,2824
17
+ proxyhat/resources/proxy_descriptors.py,sha256=qZRxeY5JxuwfDCghjFD0_FFs6WnL-lie7FOnA9M_NUk,1869
18
+ proxyhat/resources/proxy_presets.py,sha256=BQkEVMVo_GrmkPRnXJGeFmAtmr-ehpr7I_LSjO5nOlM,2708
19
+ proxyhat/resources/sub_user_groups.py,sha256=jx7upneuErImc1mz2F64e_VwIruUAVzVLx1EhdBHZ6o,2995
20
+ proxyhat/resources/sub_users.py,sha256=CJ9PwbQnsjdU-y_dvRLEcDpCBrilWnIOIu_rrfFV_kQ,6109
21
+ proxyhat/resources/two_factor.py,sha256=S4d80eg-lQ5nnseTLCGs9x_wSzIxRI1-0D0k-N8WgAY,4003
22
+ proxyhat/types/__init__.py,sha256=wey2ENfU2Yi-U3nmOHi2SQofjdCMr-FJuGbWlBi5Rmg,1639
23
+ proxyhat/types/analytics.py,sha256=HyDWJzPDQMuo7c6lFqMoMdLTH6LytzCx1aZikQwbN5s,1290
24
+ proxyhat/types/auth.py,sha256=WH4QN8EkFhbgmLG2oJDht_h9yLBiipNR-wSNWE89Cco,2761
25
+ proxyhat/types/coupons.py,sha256=Jr_DT7ZH1_JVL1uPsSkhQRqUjnsWWnuadsd5mdd5Fgs,954
26
+ proxyhat/types/email.py,sha256=LOn4TtshkPvheuIE8TZn6k4I9XFUzkaEw2lH0KBacy0,289
27
+ proxyhat/types/locations.py,sha256=-9x50U3hW9ZheG5YhDDvbjUCUR9tZzL6HfFRzwWj6ks,2637
28
+ proxyhat/types/payments.py,sha256=WfprgboOW7OGsa_9E3Mys0SQgNcqebTnlRdYBTp7X6k,2579
29
+ proxyhat/types/plans.py,sha256=Y7Nkw3JDDTOWZJsbTHCyrXGZNAbrfr8MRz-AVrRRrns,1462
30
+ proxyhat/types/profile.py,sha256=kQT8WvQQHCSHrZaYWK-ceINpbm2lY4QBowpxbsiaOEg,673
31
+ proxyhat/types/proxy_descriptor.py,sha256=5ZBw-JIPKhLNHFW1uqERk0xNV8cViyMrzpo9oMXfRhQ,881
32
+ proxyhat/types/proxy_presets.py,sha256=jWv-ykfWSfoLKCN4zR8z6tbGAz4j3ltdIeS2GtPPsBA,479
33
+ proxyhat/types/sub_user.py,sha256=ZZcKkcd_XEhzJVRjfzDeaSPYu6kzdS0enBuyGxNqk0A,2080
34
+ proxyhat/types/sub_user_groups.py,sha256=MoRMkhnpEgFxV9hutVdtje5i5NlZATS8INiToy-NXf0,680
35
+ proxyhat/types/two_factor.py,sha256=NIe6uh43lQhpu94LcLAuoJaRznm_8UP2vJM2bYqE22w,932
36
+ proxyhat-0.2.0.dist-info/METADATA,sha256=RpPBha60ZdM0nUqbAmsn8hLbIfFBaZZH1OXo_tgJkbY,7710
37
+ proxyhat-0.2.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
38
+ proxyhat-0.2.0.dist-info/licenses/LICENSE,sha256=_yoC1-ij-yJ3LPoEUetu723duo_t9XcI08QcSS6jSiQ,1065
39
+ proxyhat-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ProxyHat
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.