owlproxy-sdk 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.
- owlproxy/__init__.py +20 -0
- owlproxy/client.py +133 -0
- owlproxy/exceptions.py +50 -0
- owlproxy/resources.py +201 -0
- owlproxy/types.py +10 -0
- owlproxy_sdk-0.1.0.dist-info/METADATA +256 -0
- owlproxy_sdk-0.1.0.dist-info/RECORD +9 -0
- owlproxy_sdk-0.1.0.dist-info/WHEEL +4 -0
- owlproxy_sdk-0.1.0.dist-info/licenses/LICENSE +21 -0
owlproxy/__init__.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from .client import Client, OwlProxyClient
|
|
2
|
+
from .exceptions import (
|
|
3
|
+
OwlProxyAPIError,
|
|
4
|
+
OwlProxyDecodeError,
|
|
5
|
+
OwlProxyError,
|
|
6
|
+
OwlProxyHTTPError,
|
|
7
|
+
OwlProxyTransportError,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"Client",
|
|
12
|
+
"OwlProxyAPIError",
|
|
13
|
+
"OwlProxyClient",
|
|
14
|
+
"OwlProxyDecodeError",
|
|
15
|
+
"OwlProxyError",
|
|
16
|
+
"OwlProxyHTTPError",
|
|
17
|
+
"OwlProxyTransportError",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
__version__ = "0.1.0"
|
owlproxy/client.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
from requests import Response, Session
|
|
8
|
+
|
|
9
|
+
from .exceptions import (
|
|
10
|
+
OwlProxyAPIError,
|
|
11
|
+
OwlProxyDecodeError,
|
|
12
|
+
OwlProxyHTTPError,
|
|
13
|
+
OwlProxyTransportError,
|
|
14
|
+
)
|
|
15
|
+
from .resources import DynamicAPI, StaticIPAPI
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class OwlProxyClient:
|
|
19
|
+
"""Client for OwlProxy's token-authenticated web API."""
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
site_token: str,
|
|
24
|
+
*,
|
|
25
|
+
user_id: str | int | None = None,
|
|
26
|
+
base_url: str = "https://api.owlproxy.com",
|
|
27
|
+
origin: str = "https://proxy.owlproxy.com",
|
|
28
|
+
app_version: str = "2007800",
|
|
29
|
+
client_type: str = "web",
|
|
30
|
+
request_source: str = "wechat-miniapp",
|
|
31
|
+
supplier_type: str = "0",
|
|
32
|
+
timeout: float | tuple[float, float] = 30.0,
|
|
33
|
+
session: Session | None = None,
|
|
34
|
+
raise_for_api_errors: bool = True,
|
|
35
|
+
) -> None:
|
|
36
|
+
if not site_token or not isinstance(site_token, str):
|
|
37
|
+
raise ValueError("site_token must be a non-empty string")
|
|
38
|
+
self.site_token = site_token
|
|
39
|
+
self.user_id = str(user_id) if user_id is not None else None
|
|
40
|
+
self.base_url = base_url.rstrip("/")
|
|
41
|
+
self.origin = origin.rstrip("/")
|
|
42
|
+
self.app_version = app_version
|
|
43
|
+
self.client_type = client_type
|
|
44
|
+
self.request_source = request_source
|
|
45
|
+
self.supplier_type = supplier_type
|
|
46
|
+
self.timeout = timeout
|
|
47
|
+
self.raise_for_api_errors = raise_for_api_errors
|
|
48
|
+
self.session = session or requests.Session()
|
|
49
|
+
self.static = StaticIPAPI(self)
|
|
50
|
+
self.dynamic = DynamicAPI(self)
|
|
51
|
+
|
|
52
|
+
def _headers(self, extra: Mapping[str, str] | None = None) -> dict[str, str]:
|
|
53
|
+
headers = {
|
|
54
|
+
"Accept": "application/json, text/plain, */*",
|
|
55
|
+
"Content-Type": "application/json",
|
|
56
|
+
"Origin": self.origin,
|
|
57
|
+
"Referer": f"{self.origin}/",
|
|
58
|
+
"User-Agent": "owlproxy-python/0.1.0",
|
|
59
|
+
"appversion": self.app_version,
|
|
60
|
+
"clienttype": self.client_type,
|
|
61
|
+
"requestsource": self.request_source,
|
|
62
|
+
"suppliertype": self.supplier_type,
|
|
63
|
+
"token": self.site_token,
|
|
64
|
+
}
|
|
65
|
+
if self.user_id is not None:
|
|
66
|
+
headers["userid"] = self.user_id
|
|
67
|
+
if extra:
|
|
68
|
+
headers.update(extra)
|
|
69
|
+
return headers
|
|
70
|
+
|
|
71
|
+
def _url(self, path: str) -> str:
|
|
72
|
+
return f"{self.base_url}/owlproxy/api/{path.lstrip('/')}"
|
|
73
|
+
|
|
74
|
+
def request(
|
|
75
|
+
self,
|
|
76
|
+
method: str,
|
|
77
|
+
path: str,
|
|
78
|
+
*,
|
|
79
|
+
params: Mapping[str, Any] | None = None,
|
|
80
|
+
json: Any = None,
|
|
81
|
+
headers: Mapping[str, str] | None = None,
|
|
82
|
+
timeout: float | tuple[float, float] | None = None,
|
|
83
|
+
) -> Any:
|
|
84
|
+
query = {key: value for key, value in (params or {}).items() if value is not None}
|
|
85
|
+
try:
|
|
86
|
+
response = self.session.request(
|
|
87
|
+
method.upper(),
|
|
88
|
+
self._url(path),
|
|
89
|
+
params=query,
|
|
90
|
+
json=json,
|
|
91
|
+
headers=self._headers(headers),
|
|
92
|
+
timeout=self.timeout if timeout is None else timeout,
|
|
93
|
+
)
|
|
94
|
+
except requests.RequestException as exc:
|
|
95
|
+
raise OwlProxyTransportError(str(exc), cause=exc) from exc
|
|
96
|
+
body = self._decode(response)
|
|
97
|
+
if not response.ok:
|
|
98
|
+
raise OwlProxyHTTPError(
|
|
99
|
+
response.status_code,
|
|
100
|
+
response.reason or "request failed",
|
|
101
|
+
response=response,
|
|
102
|
+
body=body,
|
|
103
|
+
)
|
|
104
|
+
if (
|
|
105
|
+
self.raise_for_api_errors
|
|
106
|
+
and isinstance(body, Mapping)
|
|
107
|
+
and body.get("code") not in (None, 200, "200")
|
|
108
|
+
):
|
|
109
|
+
raise OwlProxyAPIError(
|
|
110
|
+
body.get("code"),
|
|
111
|
+
str(body.get("msg", "request failed")),
|
|
112
|
+
data=body.get("data"),
|
|
113
|
+
response=response,
|
|
114
|
+
)
|
|
115
|
+
return body
|
|
116
|
+
|
|
117
|
+
def get(self, path: str, **params: Any) -> Any:
|
|
118
|
+
return self.request("GET", path, params=params)
|
|
119
|
+
|
|
120
|
+
def post(self, path: str, json: Any = None, **params: Any) -> Any:
|
|
121
|
+
return self.request("POST", path, params=params or None, json=json)
|
|
122
|
+
|
|
123
|
+
def _decode(self, response: Response) -> Any:
|
|
124
|
+
try:
|
|
125
|
+
return response.json()
|
|
126
|
+
except ValueError as exc:
|
|
127
|
+
raise OwlProxyDecodeError(
|
|
128
|
+
"OwlProxy returned a non-JSON response",
|
|
129
|
+
response=response,
|
|
130
|
+
) from exc
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
Client = OwlProxyClient
|
owlproxy/exceptions.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class OwlProxyError(Exception):
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class OwlProxyTransportError(OwlProxyError):
|
|
11
|
+
def __init__(self, message: str, *, cause: Exception | None = None) -> None:
|
|
12
|
+
super().__init__(message)
|
|
13
|
+
self.cause = cause
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class OwlProxyHTTPError(OwlProxyError):
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
status_code: int,
|
|
20
|
+
message: str,
|
|
21
|
+
*,
|
|
22
|
+
response: Any = None,
|
|
23
|
+
body: Any = None,
|
|
24
|
+
) -> None:
|
|
25
|
+
super().__init__(f"HTTP {status_code}: {message}")
|
|
26
|
+
self.status_code = status_code
|
|
27
|
+
self.response = response
|
|
28
|
+
self.body = body
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class OwlProxyAPIError(OwlProxyError):
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
code: int | str | None,
|
|
35
|
+
message: str,
|
|
36
|
+
*,
|
|
37
|
+
data: Any = None,
|
|
38
|
+
response: Any = None,
|
|
39
|
+
) -> None:
|
|
40
|
+
super().__init__(f"OwlProxy API error {code}: {message}")
|
|
41
|
+
self.code = code
|
|
42
|
+
self.message = message
|
|
43
|
+
self.data = data
|
|
44
|
+
self.response = response
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class OwlProxyDecodeError(OwlProxyError):
|
|
48
|
+
def __init__(self, message: str, *, response: Any = None) -> None:
|
|
49
|
+
super().__init__(message)
|
|
50
|
+
self.response = response
|
owlproxy/resources.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING, Any
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from .client import OwlProxyClient
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class StaticIPAPI:
|
|
10
|
+
def __init__(self, client: OwlProxyClient) -> None:
|
|
11
|
+
self._client = client
|
|
12
|
+
|
|
13
|
+
def proxy_types(self, proxy_mode: int | None = None) -> Any:
|
|
14
|
+
return self._client.get("vcProxyShop/getProxyTypeList", proxyMode=proxy_mode)
|
|
15
|
+
|
|
16
|
+
def countries(self, proxy_type: int) -> Any:
|
|
17
|
+
return self._client.get("vcProxyGood/getProxyCountry", proxyType=proxy_type)
|
|
18
|
+
|
|
19
|
+
def quality_options(self, proxy_type: int) -> Any:
|
|
20
|
+
return self._client.get("vcProxyGood/proxyIdType", proxyType=proxy_type)
|
|
21
|
+
|
|
22
|
+
def providers(self, country_code: str, proxy_type: int | str, proxy_id_type: str) -> Any:
|
|
23
|
+
return self._client.post("vcProxyShop/getProxyShopList", {
|
|
24
|
+
"countryCode": country_code,
|
|
25
|
+
"proxyType": proxy_type,
|
|
26
|
+
"proxyIdType": proxy_id_type,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
def packages(
|
|
30
|
+
self,
|
|
31
|
+
proxy_shop_id: int,
|
|
32
|
+
country_code: str,
|
|
33
|
+
proxy_type: int,
|
|
34
|
+
proxy_id_type: str,
|
|
35
|
+
) -> Any:
|
|
36
|
+
return self._client.get(
|
|
37
|
+
"vcProxyGood/proxyGoodList",
|
|
38
|
+
proxyShopId=proxy_shop_id,
|
|
39
|
+
countryCode=country_code,
|
|
40
|
+
proxyType=proxy_type,
|
|
41
|
+
proxyIdType=proxy_id_type,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def create_order(
|
|
45
|
+
self,
|
|
46
|
+
proxy_good_id: int,
|
|
47
|
+
num: int,
|
|
48
|
+
country: str,
|
|
49
|
+
proxy_shop_id: int,
|
|
50
|
+
auto_renew: bool = False,
|
|
51
|
+
back_url: str | None = None,
|
|
52
|
+
) -> Any:
|
|
53
|
+
body = {
|
|
54
|
+
"proxyGoodId": proxy_good_id,
|
|
55
|
+
"num": num,
|
|
56
|
+
"country": country,
|
|
57
|
+
"proxyShopId": proxy_shop_id,
|
|
58
|
+
"autoRenew": auto_renew,
|
|
59
|
+
}
|
|
60
|
+
if back_url is not None:
|
|
61
|
+
body["backUrl"] = back_url
|
|
62
|
+
return self._client.post("vcProxyGood/createProxyOrder", body)
|
|
63
|
+
|
|
64
|
+
def ip_info(self, order_ids: str | list[str]) -> Any:
|
|
65
|
+
if isinstance(order_ids, str):
|
|
66
|
+
order_ids = [order_ids]
|
|
67
|
+
return self._client.post("vcProxy/queryByorderIdList", {"orderIds": order_ids})
|
|
68
|
+
|
|
69
|
+
def list(
|
|
70
|
+
self,
|
|
71
|
+
current: int = 1,
|
|
72
|
+
size: int = 20,
|
|
73
|
+
proxy_name: str = "",
|
|
74
|
+
proxy_buy_status_id: int | str = "",
|
|
75
|
+
group_id_list: list[int] | None = None,
|
|
76
|
+
) -> Any:
|
|
77
|
+
body = {
|
|
78
|
+
"current": current,
|
|
79
|
+
"size": size,
|
|
80
|
+
"proxyName": proxy_name,
|
|
81
|
+
"proxyBuyStatusId": proxy_buy_status_id,
|
|
82
|
+
}
|
|
83
|
+
if group_id_list is not None:
|
|
84
|
+
body["groupIdList"] = group_id_list
|
|
85
|
+
return self._client.post("vcProxy/queryList", body)
|
|
86
|
+
|
|
87
|
+
def update_name(self, proxy_id: int, proxy_name: str) -> Any:
|
|
88
|
+
return self._client.get(
|
|
89
|
+
"vcProxy/updateProxyName",
|
|
90
|
+
proxyName=proxy_name,
|
|
91
|
+
proxyId=proxy_id,
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
def renew(
|
|
95
|
+
self,
|
|
96
|
+
proxy_good_id: int,
|
|
97
|
+
proxy_shop_id: int,
|
|
98
|
+
proxy_ips: str | list[str],
|
|
99
|
+
back_url: str | None = None,
|
|
100
|
+
) -> Any:
|
|
101
|
+
body = {
|
|
102
|
+
"proxyGoodId": proxy_good_id,
|
|
103
|
+
"proxyShopId": proxy_shop_id,
|
|
104
|
+
"proxyIps": ",".join(proxy_ips) if isinstance(proxy_ips, list) else proxy_ips,
|
|
105
|
+
}
|
|
106
|
+
if back_url is not None:
|
|
107
|
+
body["backurl"] = back_url
|
|
108
|
+
return self._client.post("vcProxyGood/createRenewProxyOrder", body)
|
|
109
|
+
|
|
110
|
+
def calculate_renew_price(self, proxy_ips: list[str], renewal_days: int) -> Any:
|
|
111
|
+
return self._client.post("vcProxy/batchCalculateRenewPrice", {
|
|
112
|
+
"proxyIps": proxy_ips,
|
|
113
|
+
"renewalDays": renewal_days,
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
def set_auto_renew(self, proxy_id: int, auto_renew: bool) -> Any:
|
|
117
|
+
return self._client.post("vcProxy/autoRenewClose", {
|
|
118
|
+
"proxyId": proxy_id,
|
|
119
|
+
"autoRenew": auto_renew,
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
def orders(
|
|
123
|
+
self,
|
|
124
|
+
page: int = 1,
|
|
125
|
+
rows: int = 20,
|
|
126
|
+
complete_start_time: str | None = None,
|
|
127
|
+
complete_end_time: str | None = None,
|
|
128
|
+
) -> Any:
|
|
129
|
+
body = {"page": page, "rows": rows}
|
|
130
|
+
if complete_start_time is not None:
|
|
131
|
+
body["completeStartTime"] = complete_start_time
|
|
132
|
+
if complete_end_time is not None:
|
|
133
|
+
body["completeEndTime"] = complete_end_time
|
|
134
|
+
return self._client.post("vcProxyOrder/selectProxyOrderList", body)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class DynamicAPI:
|
|
138
|
+
def __init__(self, client: OwlProxyClient) -> None:
|
|
139
|
+
self._client = client
|
|
140
|
+
|
|
141
|
+
def traffic_balance(self) -> Any:
|
|
142
|
+
return self._client.get("vcDynamicGood/queryCurrentTrafficBalance")
|
|
143
|
+
|
|
144
|
+
def packages(self) -> Any:
|
|
145
|
+
return self._client.get("vcDynamicGood/getDynamicGoodService")
|
|
146
|
+
|
|
147
|
+
def create_order(self, good_id: int, good_num: int = 1, auto_renew_order: int = 0) -> Any:
|
|
148
|
+
return self._client.post("vcDynamicGood/buyDynamicProxy", {
|
|
149
|
+
"goodId": good_id,
|
|
150
|
+
"goodNum": good_num,
|
|
151
|
+
"autoRenewOrder": auto_renew_order,
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
def regions(self) -> Any:
|
|
155
|
+
return self._client.get("vcDynamicGood/getDynamicProxyRegion")
|
|
156
|
+
|
|
157
|
+
def lines(self, region: str | None = None) -> Any:
|
|
158
|
+
params = {"region": region} if region is not None else {}
|
|
159
|
+
return self._client.get("vcDynamicGood/getDynamicProxyHost", **params)
|
|
160
|
+
|
|
161
|
+
def extract(
|
|
162
|
+
self,
|
|
163
|
+
country_code: str,
|
|
164
|
+
state: str,
|
|
165
|
+
city: str,
|
|
166
|
+
proxy_host: str,
|
|
167
|
+
proxy_type: str,
|
|
168
|
+
time: int,
|
|
169
|
+
good_num: int = 1,
|
|
170
|
+
) -> Any:
|
|
171
|
+
return self._client.post("vcDynamicGood/createProxy", {
|
|
172
|
+
"countryCode": country_code,
|
|
173
|
+
"state": state,
|
|
174
|
+
"city": city,
|
|
175
|
+
"proxyHost": proxy_host,
|
|
176
|
+
"proxyType": proxy_type,
|
|
177
|
+
"time": time,
|
|
178
|
+
"goodNum": good_num,
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
def automatic_renewal(self) -> Any:
|
|
182
|
+
return self._client.get("vcDynamicGood/getDynamicProxyAutomaticRenewal")
|
|
183
|
+
|
|
184
|
+
def set_auto_renew(self, auto_renew_order: int | bool) -> Any:
|
|
185
|
+
return self._client.post("vcDynamicGood/setAutoRenewSwitch", {
|
|
186
|
+
"autoRenewOrder": int(auto_renew_order),
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
def orders(
|
|
190
|
+
self,
|
|
191
|
+
page: int = 1,
|
|
192
|
+
rows: int = 20,
|
|
193
|
+
complete_start_time: str | None = None,
|
|
194
|
+
complete_end_time: str | None = None,
|
|
195
|
+
) -> Any:
|
|
196
|
+
body = {"page": page, "rows": rows}
|
|
197
|
+
if complete_start_time is not None:
|
|
198
|
+
body["completeStartTime"] = complete_start_time
|
|
199
|
+
if complete_end_time is not None:
|
|
200
|
+
body["completeEndTime"] = complete_end_time
|
|
201
|
+
return self._client.post("vcDynamicGood/getDynamicProxyOrders", body)
|
owlproxy/types.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping, Sequence
|
|
4
|
+
from typing import Any, Union
|
|
5
|
+
|
|
6
|
+
JsonPrimitive = Union[str, int, float, bool, None]
|
|
7
|
+
JsonValue = Union[JsonPrimitive, list["JsonValue"], dict[str, "JsonValue"]]
|
|
8
|
+
JsonObject = dict[str, JsonValue]
|
|
9
|
+
Params = Mapping[str, Any]
|
|
10
|
+
OrderIds = Union[str, Sequence[str]]
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: owlproxy-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for OwlProxy's token-authenticated site API
|
|
5
|
+
Project-URL: Documentation, https://www.owlproxy.com/owlproxy/doc/zh/server/OpenAPI.html
|
|
6
|
+
Project-URL: Homepage, https://www.owlproxy.com/
|
|
7
|
+
Author: OwlProxy Python contributors
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 OwlProxy Python contributors
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Keywords: api,owlproxy,proxy,sdk
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Operating System :: OS Independent
|
|
35
|
+
Classifier: Programming Language :: Python :: 3
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
40
|
+
Classifier: Typing :: Typed
|
|
41
|
+
Requires-Python: >=3.10
|
|
42
|
+
Requires-Dist: requests<3,>=2.31
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
45
|
+
Requires-Dist: hatch>=1.12; extra == 'dev'
|
|
46
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
47
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
48
|
+
Requires-Dist: ruff>=0.9; extra == 'dev'
|
|
49
|
+
Requires-Dist: twine>=5; extra == 'dev'
|
|
50
|
+
Description-Content-Type: text/markdown
|
|
51
|
+
|
|
52
|
+
# OwlProxy Python
|
|
53
|
+
|
|
54
|
+
A typed Python client for OwlProxy's token-authenticated site API. It adapts every callable endpoint in OwlProxy's public OpenAPI documentation to the equivalent working site route by removing the `openApi/` path segment and authenticating with a site token.
|
|
55
|
+
|
|
56
|
+
This is an unofficial library. OwlProxy's site API is not the same stability contract as its documented HMAC OpenAPI and may change without notice.
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install owlproxy
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
For local development:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
git clone <repository-url>
|
|
68
|
+
cd owlproxy
|
|
69
|
+
python -m pip install -e '.[dev]'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Authentication
|
|
73
|
+
|
|
74
|
+
Create a client with the `token` header value used by `proxy.owlproxy.com`:
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
import os
|
|
78
|
+
|
|
79
|
+
from owlproxy import OwlProxyClient
|
|
80
|
+
|
|
81
|
+
client = OwlProxyClient(os.environ["OWLPROXY_SITE_TOKEN"])
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A user ID can be supplied if an account or endpoint requires it:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
client = OwlProxyClient(
|
|
88
|
+
os.environ["OWLPROXY_SITE_TOKEN"],
|
|
89
|
+
user_id=os.environ.get("OWLPROXY_USER_ID"),
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Never commit site tokens. A token grants access to account data and purchasing or renewal actions.
|
|
94
|
+
|
|
95
|
+
## Response and error behavior
|
|
96
|
+
|
|
97
|
+
Methods return OwlProxy's decoded JSON response:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
response = client.static.list()
|
|
101
|
+
records = response["data"]["records"]
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
By default, a JSON response whose `code` is not `200` raises `OwlProxyAPIError`. HTTP, transport, and decoding failures raise dedicated exception classes:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from owlproxy import OwlProxyAPIError, OwlProxyError
|
|
108
|
+
|
|
109
|
+
try:
|
|
110
|
+
client.dynamic.traffic_balance()
|
|
111
|
+
except OwlProxyAPIError as error:
|
|
112
|
+
print(error.code, error.message)
|
|
113
|
+
except OwlProxyError as error:
|
|
114
|
+
print(error)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Set `raise_for_api_errors=False` to receive non-200 API responses directly.
|
|
118
|
+
|
|
119
|
+
## Static IP API
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
client.static.proxy_types(proxy_mode=1)
|
|
123
|
+
client.static.countries(proxy_type=4)
|
|
124
|
+
client.static.quality_options(proxy_type=4)
|
|
125
|
+
client.static.providers("US", proxy_type=4, proxy_id_type="ord")
|
|
126
|
+
client.static.packages(2, "US", proxy_type=4, proxy_id_type="ord")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
List proxies:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
response = client.static.list(
|
|
133
|
+
current=1,
|
|
134
|
+
size=20,
|
|
135
|
+
proxy_name="",
|
|
136
|
+
proxy_buy_status_id="",
|
|
137
|
+
group_id_list=[],
|
|
138
|
+
)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Find a proxy and disable automatic renewal:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
response = client.static.list(size=100, proxy_name="62.132.16.64")
|
|
145
|
+
proxy = next(
|
|
146
|
+
item
|
|
147
|
+
for item in response["data"]["records"]
|
|
148
|
+
if item["proxyHost"] == "62.132.16.64"
|
|
149
|
+
)
|
|
150
|
+
client.static.set_auto_renew(proxy["proxyId"], False)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Purchase and order information:
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
client.static.create_order(
|
|
157
|
+
proxy_good_id=1,
|
|
158
|
+
num=1,
|
|
159
|
+
country="US",
|
|
160
|
+
proxy_shop_id=1,
|
|
161
|
+
auto_renew=False,
|
|
162
|
+
back_url="https://example.com/owlproxy/callback",
|
|
163
|
+
)
|
|
164
|
+
client.static.ip_info(["Owl-PROXY123"])
|
|
165
|
+
client.static.orders(page=1, rows=20)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Maintenance:
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
client.static.update_name(proxy_id=93847, proxy_name="production")
|
|
172
|
+
client.static.calculate_renew_price(["192.0.2.10"], renewal_days=30)
|
|
173
|
+
client.static.renew(
|
|
174
|
+
proxy_good_id=1,
|
|
175
|
+
proxy_shop_id=1,
|
|
176
|
+
proxy_ips="192.0.2.10",
|
|
177
|
+
back_url="https://example.com/owlproxy/callback",
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Dynamic proxy API
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
client.dynamic.traffic_balance()
|
|
185
|
+
client.dynamic.packages()
|
|
186
|
+
client.dynamic.regions()
|
|
187
|
+
client.dynamic.lines()
|
|
188
|
+
client.dynamic.automatic_renewal()
|
|
189
|
+
client.dynamic.orders(page=1, rows=20)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Purchase, extract, and renewal settings:
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
client.dynamic.create_order(good_id=1, good_num=1, auto_renew_order=0)
|
|
196
|
+
client.dynamic.extract(
|
|
197
|
+
country_code="AE",
|
|
198
|
+
state="Sharjah",
|
|
199
|
+
city="Sharjahcity",
|
|
200
|
+
proxy_host="change4.owlproxy.com:7778",
|
|
201
|
+
proxy_type="socks5",
|
|
202
|
+
time=5,
|
|
203
|
+
good_num=1,
|
|
204
|
+
)
|
|
205
|
+
client.dynamic.set_auto_renew(False)
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Complete endpoint mapping
|
|
209
|
+
|
|
210
|
+
| Library method | Site route | Documented OpenAPI route |
|
|
211
|
+
|---|---|---|
|
|
212
|
+
| `static.proxy_types` | `GET /owlproxy/api/vcProxyShop/getProxyTypeList` | `GET /owlproxy/api/openApi/vcProxyShop/getProxyTypeList` |
|
|
213
|
+
| `static.countries` | `GET /owlproxy/api/vcProxyGood/getProxyCountry` | `GET /owlproxy/api/openApi/vcProxyGood/getProxyCountry` |
|
|
214
|
+
| `static.quality_options` | `GET /owlproxy/api/vcProxyGood/proxyIdType` | `GET /owlproxy/api/openApi/vcProxyGood/proxyIdType` |
|
|
215
|
+
| `static.providers` | `POST /owlproxy/api/vcProxyShop/getProxyShopList` | `POST /owlproxy/api/openApi/vcProxyShop/getProxyShopList` |
|
|
216
|
+
| `static.packages` | `GET /owlproxy/api/vcProxyGood/proxyGoodList` | `GET /owlproxy/api/openApi/vcProxyGood/proxyGoodList` |
|
|
217
|
+
| `static.create_order` | `POST /owlproxy/api/vcProxyGood/createProxyOrder` | `POST /owlproxy/api/openApi/vcProxyGood/createProxyOrder` |
|
|
218
|
+
| `static.ip_info` | `POST /owlproxy/api/vcProxy/queryByorderIdList` | `POST /owlproxy/api/openApi/vcProxy/queryByorderIdList` |
|
|
219
|
+
| `static.list` | `POST /owlproxy/api/vcProxy/queryList` | `POST /owlproxy/api/openApi/vcProxy/queryList` |
|
|
220
|
+
| `static.update_name` | `GET /owlproxy/api/vcProxy/updateProxyName` | `GET /owlproxy/api/openApi/vcProxy/updateProxyName` |
|
|
221
|
+
| `static.renew` | `POST /owlproxy/api/vcProxyGood/createRenewProxyOrder` | `POST /owlproxy/api/openApi/vcProxyGood/createRenewProxyOrder` |
|
|
222
|
+
| `static.calculate_renew_price` | `POST /owlproxy/api/vcProxy/batchCalculateRenewPrice` | `POST /owlproxy/api/openApi/vcProxy/batchCalculateRenewPrice` |
|
|
223
|
+
| `static.set_auto_renew` | `POST /owlproxy/api/vcProxy/autoRenewClose` | `POST /owlproxy/api/openApi/vcProxy/autoRenewClose` |
|
|
224
|
+
| `static.orders` | `POST /owlproxy/api/vcProxyOrder/selectProxyOrderList` | `POST /owlproxy/api/openApi/vcProxyOrder/selectProxyOrderList` |
|
|
225
|
+
| `dynamic.traffic_balance` | `GET /owlproxy/api/vcDynamicGood/queryCurrentTrafficBalance` | `GET /owlproxy/api/openApi/vcDynamicGood/queryCurrentTrafficBalance` |
|
|
226
|
+
| `dynamic.packages` | `GET /owlproxy/api/vcDynamicGood/getDynamicGoodService` | `GET /owlproxy/api/openApi/vcDynamicGood/getDynamicGoodService` |
|
|
227
|
+
| `dynamic.create_order` | `POST /owlproxy/api/vcDynamicGood/buyDynamicProxy` | `POST /owlproxy/api/openApi/vcDynamicGood/buyDynamicProxy` |
|
|
228
|
+
| `dynamic.regions` | `GET /owlproxy/api/vcDynamicGood/getDynamicProxyRegion` | `GET /owlproxy/api/openApi/vcDynamicGood/getDynamicProxyRegion` |
|
|
229
|
+
| `dynamic.lines` | `GET /owlproxy/api/vcDynamicGood/getDynamicProxyHost` | `GET /owlproxy/api/openApi/vcDynamicGood/getDynamicProxyHost` |
|
|
230
|
+
| `dynamic.extract` | `POST /owlproxy/api/vcDynamicGood/createProxy` | `POST /owlproxy/api/openApi/vcDynamicGood/createProxy` |
|
|
231
|
+
| `dynamic.automatic_renewal` | `GET /owlproxy/api/vcDynamicGood/getDynamicProxyAutomaticRenewal` | `GET /owlproxy/api/openApi/vcDynamicGood/getDynamicProxyAutomaticRenewal` |
|
|
232
|
+
| `dynamic.set_auto_renew` | `POST /owlproxy/api/vcDynamicGood/setAutoRenewSwitch` | `POST /owlproxy/api/openApi/vcDynamicGood/setAutoRenewSwitch` |
|
|
233
|
+
| `dynamic.orders` | `POST /owlproxy/api/vcDynamicGood/getDynamicProxyOrders` | `POST /owlproxy/api/openApi/vcDynamicGood/getDynamicProxyOrders` |
|
|
234
|
+
|
|
235
|
+
The payment callback is inbound rather than an OwlProxy request, so it is documented but is not a client method.
|
|
236
|
+
|
|
237
|
+
## Raw requests
|
|
238
|
+
|
|
239
|
+
New or undocumented site endpoints can be called without waiting for a release:
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
client.get("vcDynamicGood/getDynamicGoodService")
|
|
243
|
+
client.post("vcProxy/queryList", {"current": 1, "size": 20})
|
|
244
|
+
client.request("POST", "some/path", json={"key": "value"})
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Publishing
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
python -m pytest
|
|
251
|
+
python -m build
|
|
252
|
+
python -m twine check dist/*
|
|
253
|
+
python -m twine upload dist/*
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Verify that the `owlproxy` package name is available on PyPI before publishing. Change `project.name` if it is already owned by another publisher.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
owlproxy/__init__.py,sha256=aIzLOtFSjIsmdVoWyblKSHUugS3YMoxHvHDW9e_-32g,389
|
|
2
|
+
owlproxy/client.py,sha256=by41FCBPx2SqhudmkFujvB1QTsccdYxjgsU1UkoK9ZE,4517
|
|
3
|
+
owlproxy/exceptions.py,sha256=MTGHKYF0EgTITA0mOmpbnmOCUEKDpXAKK6cac3Acdmo,1222
|
|
4
|
+
owlproxy/resources.py,sha256=IatqLT7WBhH2wSTLhJhDudDKVYFRaOg9BKV6idZTge0,6630
|
|
5
|
+
owlproxy/types.py,sha256=3EZqYfGnrmxJn0Sn3mjSfOW1Sia6QtmENjBk5lQhlic,338
|
|
6
|
+
owlproxy_sdk-0.1.0.dist-info/METADATA,sha256=nNvhwJvT54dy_B3avSNEyITkVxhddws4Ynk52mBjSMM,9932
|
|
7
|
+
owlproxy_sdk-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
8
|
+
owlproxy_sdk-0.1.0.dist-info/licenses/LICENSE,sha256=vLax0gWH_rR6A2XHHJc0EvjyYvrE_s0VxAs4S6ZVWGE,1085
|
|
9
|
+
owlproxy_sdk-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OwlProxy Python contributors
|
|
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.
|