proxyhubb 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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ProxyHubb
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,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxyhubb
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the ProxyHubb Bulk Proxy Pool API
5
+ Author: ProxyHubb
6
+ License: MIT
7
+ Project-URL: Homepage, https://proxyhubb.com
8
+ Project-URL: Repository, https://github.com/proxyhubb/proxyhubb
9
+ Project-URL: Issues, https://github.com/proxyhubb/proxyhubb/issues
10
+ Keywords: proxyhubb,proxy,sdk,api
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: requests>=2.31.0
18
+ Requires-Dist: urllib3>=2.0.0
19
+ Dynamic: license-file
20
+
21
+ # proxyhubb
22
+
23
+ Official Python client for the ProxyHubb Bulk Proxy Pool API.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ pip install proxyhubb
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```python
34
+ from proxyhubb import ProxyHubClient
35
+
36
+ client = ProxyHubClient("phub_...") # default: https://api.proxyhubb.com
37
+ pool = client.create_pool("scrapers", size=5)
38
+ proxies = client.as_requests_proxy(pool["id"])
39
+ ```
40
+
41
+ Create an API key in the dashboard (`phub_…`).
42
+
43
+ Gateway helper (optional):
44
+
45
+ ```python
46
+ from proxyhubb import ProxyClient
47
+
48
+ gw = ProxyClient(proxy_auth="user:pass")
49
+ resp = gw.request("GET", "https://api.ipify.org")
50
+ ```
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1,34 @@
1
+ # proxyhubb
2
+
3
+ Official Python client for the ProxyHubb Bulk Proxy Pool API.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pip install proxyhubb
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```python
14
+ from proxyhubb import ProxyHubClient
15
+
16
+ client = ProxyHubClient("phub_...") # default: https://api.proxyhubb.com
17
+ pool = client.create_pool("scrapers", size=5)
18
+ proxies = client.as_requests_proxy(pool["id"])
19
+ ```
20
+
21
+ Create an API key in the dashboard (`phub_…`).
22
+
23
+ Gateway helper (optional):
24
+
25
+ ```python
26
+ from proxyhubb import ProxyClient
27
+
28
+ gw = ProxyClient(proxy_auth="user:pass")
29
+ resp = gw.request("GET", "https://api.ipify.org")
30
+ ```
31
+
32
+ ## License
33
+
34
+ MIT
@@ -0,0 +1,7 @@
1
+ """Official ProxyHubb Python SDK."""
2
+
3
+ from proxyhubb.client import ProxyHubClient, DEFAULT_BASE_URL
4
+ from proxyhubb.proxy import ProxyClient
5
+
6
+ __all__ = ["ProxyHubClient", "ProxyClient", "DEFAULT_BASE_URL"]
7
+ __version__ = "0.1.0"
@@ -0,0 +1,106 @@
1
+ """ProxyHubb Python SDK — Bulk Proxy Pool Control API client."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import requests
8
+
9
+ DEFAULT_BASE_URL = "https://api.proxyhubb.com"
10
+
11
+
12
+ class ProxyHubClient:
13
+ """Client for the ProxyHubb Bulk Proxy Pool API.
14
+
15
+ Parameters
16
+ ----------
17
+ api_key:
18
+ A ProxyHubb API key starting with ``phub_`` (or ``pk_``).
19
+ base_url:
20
+ Base URL of the Control API. Defaults to production.
21
+ """
22
+
23
+ def __init__(
24
+ self,
25
+ api_key: str,
26
+ base_url: str = DEFAULT_BASE_URL,
27
+ ) -> None:
28
+ if not api_key:
29
+ raise ValueError("api_key is required")
30
+ self._api_key = api_key
31
+ self._base_url = base_url.rstrip("/")
32
+ self._session = requests.Session()
33
+ self._session.headers.update({"X-API-Key": self._api_key})
34
+
35
+ def _url(self, path: str) -> str:
36
+ return f"{self._base_url}{path}"
37
+
38
+ def _get(self, path: str) -> dict[str, Any]:
39
+ resp = self._session.get(self._url(path))
40
+ resp.raise_for_status()
41
+ return resp.json()
42
+
43
+ def _post(self, path: str, payload: dict[str, Any]) -> dict[str, Any]:
44
+ resp = self._session.post(self._url(path), json=payload)
45
+ resp.raise_for_status()
46
+ return resp.json()
47
+
48
+ def _delete(self, path: str) -> None:
49
+ resp = self._session.delete(self._url(path))
50
+ resp.raise_for_status()
51
+
52
+ def create_pool(
53
+ self,
54
+ name: str,
55
+ size: int = 10,
56
+ session_type: str = "rotating",
57
+ description: str = "",
58
+ bytes_limit: int = 0,
59
+ ) -> dict[str, Any]:
60
+ """Create a new proxy pool."""
61
+ return self._post(
62
+ "/v1/bulk/pools",
63
+ {
64
+ "name": name,
65
+ "size": size,
66
+ "session_type": session_type,
67
+ "description": description,
68
+ "bytes_limit": bytes_limit,
69
+ },
70
+ )
71
+
72
+ def list_pools(self) -> dict[str, Any]:
73
+ """List proxy pools for the authenticated account."""
74
+ return self._get("/v1/bulk/pools")
75
+
76
+ def get_pool(self, pool_id: str) -> dict[str, Any]:
77
+ """Retrieve the endpoints of a proxy pool."""
78
+ return self._get(f"/v1/bulk/pools/{pool_id}/endpoints")
79
+
80
+ def get_proxies(self, pool_id: str) -> list[dict[str, Any]]:
81
+ """Return the list of endpoint dicts for a pool."""
82
+ data = self.get_pool(pool_id)
83
+ return data.get("endpoints", [])
84
+
85
+ def revoke_pool(self, pool_id: str) -> None:
86
+ """Soft-delete a proxy pool."""
87
+ self._delete(f"/v1/bulk/pools/{pool_id}")
88
+
89
+ def as_requests_proxy(self, pool_id: str, index: int = 0) -> dict[str, str]:
90
+ """Return a ``proxies`` dict compatible with the ``requests`` library.
91
+
92
+ Endpoint host/port come from the API (production buyer proxy is
93
+ ``proxy.proxyhubb.com:8090``).
94
+ """
95
+ endpoints = self.get_proxies(pool_id)
96
+ if not endpoints:
97
+ raise ValueError(f"Pool {pool_id!r} has no endpoints")
98
+ if index >= len(endpoints):
99
+ raise IndexError(
100
+ f"index {index} is out of range for pool with {len(endpoints)} endpoints"
101
+ )
102
+ ep = endpoints[index]
103
+ proxy_url = (
104
+ f"http://{ep['username']}:{ep['password']}@{ep['host']}:{ep['port']}"
105
+ )
106
+ return {"http": proxy_url, "https": proxy_url}
@@ -0,0 +1,47 @@
1
+ """Gateway helper for routing HTTP via the ProxyHubb buyer proxy."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import time
6
+ import uuid
7
+ from typing import Any, Optional
8
+
9
+ import requests
10
+
11
+ DEFAULT_GATEWAY = "http://proxy.proxyhubb.com:8090"
12
+
13
+
14
+ class ProxyClient:
15
+ """Thin helper that builds ``requests``-compatible proxy URLs for the gateway.
16
+
17
+ Prefer :class:`proxyhubb.ProxyHubClient` to create pools and obtain credentials.
18
+ """
19
+
20
+ def __init__(
21
+ self,
22
+ gateway_url: str = DEFAULT_GATEWAY,
23
+ proxy_auth: Optional[str] = None,
24
+ ) -> None:
25
+ self.gateway_url = gateway_url
26
+ self.proxy_auth = proxy_auth
27
+ self.current_session_id = str(uuid.uuid4())
28
+ self.session_start = time.time()
29
+
30
+ def get_proxy_config(self, rotate: bool = False) -> dict[str, str]:
31
+ if rotate:
32
+ self.current_session_id = str(uuid.uuid4())
33
+ self.session_start = time.time()
34
+
35
+ auth_str = self.proxy_auth if self.proxy_auth else "anonymous"
36
+ host = self.gateway_url.split("//")[-1]
37
+ proxy_str = f"http://{auth_str}:{self.current_session_id}@{host}"
38
+ return {"http": proxy_str, "https": proxy_str}
39
+
40
+ def request(self, method: str, url: str, rotate: bool = False, **kwargs: Any):
41
+ proxies = self.get_proxy_config(rotate=rotate)
42
+ try:
43
+ return requests.request(method, url, proxies=proxies, **kwargs)
44
+ except Exception:
45
+ return requests.request(
46
+ method, url, proxies=self.get_proxy_config(rotate=True), **kwargs
47
+ )
@@ -0,0 +1,54 @@
1
+ Metadata-Version: 2.4
2
+ Name: proxyhubb
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the ProxyHubb Bulk Proxy Pool API
5
+ Author: ProxyHubb
6
+ License: MIT
7
+ Project-URL: Homepage, https://proxyhubb.com
8
+ Project-URL: Repository, https://github.com/proxyhubb/proxyhubb
9
+ Project-URL: Issues, https://github.com/proxyhubb/proxyhubb/issues
10
+ Keywords: proxyhubb,proxy,sdk,api
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE
17
+ Requires-Dist: requests>=2.31.0
18
+ Requires-Dist: urllib3>=2.0.0
19
+ Dynamic: license-file
20
+
21
+ # proxyhubb
22
+
23
+ Official Python client for the ProxyHubb Bulk Proxy Pool API.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ pip install proxyhubb
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```python
34
+ from proxyhubb import ProxyHubClient
35
+
36
+ client = ProxyHubClient("phub_...") # default: https://api.proxyhubb.com
37
+ pool = client.create_pool("scrapers", size=5)
38
+ proxies = client.as_requests_proxy(pool["id"])
39
+ ```
40
+
41
+ Create an API key in the dashboard (`phub_…`).
42
+
43
+ Gateway helper (optional):
44
+
45
+ ```python
46
+ from proxyhubb import ProxyClient
47
+
48
+ gw = ProxyClient(proxy_auth="user:pass")
49
+ resp = gw.request("GET", "https://api.ipify.org")
50
+ ```
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ proxyhubb/__init__.py
5
+ proxyhubb/client.py
6
+ proxyhubb/proxy.py
7
+ proxyhubb.egg-info/PKG-INFO
8
+ proxyhubb.egg-info/SOURCES.txt
9
+ proxyhubb.egg-info/dependency_links.txt
10
+ proxyhubb.egg-info/requires.txt
11
+ proxyhubb.egg-info/top_level.txt
12
+ tests/test_client.py
@@ -0,0 +1,2 @@
1
+ requests>=2.31.0
2
+ urllib3>=2.0.0
@@ -0,0 +1 @@
1
+ proxyhubb
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "proxyhubb"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for the ProxyHubb Bulk Proxy Pool API"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.9"
12
+ authors = [{ name = "ProxyHubb" }]
13
+ keywords = ["proxyhubb", "proxy", "sdk", "api"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ "requests>=2.31.0",
21
+ "urllib3>=2.0.0",
22
+ ]
23
+
24
+ [project.urls]
25
+ Homepage = "https://proxyhubb.com"
26
+ Repository = "https://github.com/proxyhubb/proxyhubb"
27
+ Issues = "https://github.com/proxyhubb/proxyhubb/issues"
28
+
29
+ [tool.setuptools.packages.find]
30
+ include = ["proxyhubb*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,20 @@
1
+ from proxyhubb import ProxyHubClient, ProxyClient, DEFAULT_BASE_URL
2
+
3
+
4
+ def test_defaults():
5
+ assert DEFAULT_BASE_URL == "https://api.proxyhubb.com"
6
+ client = ProxyHubClient("phub_test")
7
+ assert client._base_url == "https://api.proxyhubb.com"
8
+
9
+
10
+ def test_requires_api_key():
11
+ try:
12
+ ProxyHubClient("")
13
+ assert False, "expected ValueError"
14
+ except ValueError:
15
+ pass
16
+
17
+
18
+ def test_proxy_client_default_gateway():
19
+ gw = ProxyClient()
20
+ assert "proxy.proxyhubb.com" in gw.gateway_url