thordata-sdk 1.4.0__tar.gz → 1.5.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.
- {thordata_sdk-1.4.0/src/thordata_sdk.egg-info → thordata_sdk-1.5.0}/PKG-INFO +73 -50
- thordata_sdk-1.5.0/README.md +187 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/pyproject.toml +1 -1
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/__init__.py +4 -40
- thordata_sdk-1.5.0/src/thordata/async_client.py +1064 -0
- thordata_sdk-1.5.0/src/thordata/client.py +1596 -0
- thordata_sdk-1.5.0/src/thordata/core/__init__.py +23 -0
- thordata_sdk-1.5.0/src/thordata/core/async_http_client.py +91 -0
- thordata_sdk-1.5.0/src/thordata/core/http_client.py +79 -0
- thordata_sdk-1.5.0/src/thordata/core/tunnel.py +287 -0
- thordata_sdk-1.5.0/src/thordata/enums.py +45 -0
- thordata_sdk-1.5.0/src/thordata/models.py +41 -0
- thordata_sdk-1.5.0/src/thordata/tools/__init__.py +28 -0
- thordata_sdk-1.5.0/src/thordata/tools/base.py +42 -0
- thordata_sdk-1.5.0/src/thordata/tools/code.py +26 -0
- thordata_sdk-1.5.0/src/thordata/tools/ecommerce.py +67 -0
- thordata_sdk-1.5.0/src/thordata/tools/search.py +73 -0
- thordata_sdk-1.5.0/src/thordata/tools/social.py +190 -0
- thordata_sdk-1.5.0/src/thordata/tools/video.py +81 -0
- thordata_sdk-1.5.0/src/thordata/types/__init__.py +77 -0
- thordata_sdk-1.5.0/src/thordata/types/common.py +141 -0
- thordata_sdk-1.5.0/src/thordata/types/proxy.py +340 -0
- thordata_sdk-1.5.0/src/thordata/types/serp.py +224 -0
- thordata_sdk-1.5.0/src/thordata/types/task.py +144 -0
- thordata_sdk-1.5.0/src/thordata/types/universal.py +66 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/unlimited.py +67 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0/src/thordata_sdk.egg-info}/PKG-INFO +73 -50
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata_sdk.egg-info/SOURCES.txt +18 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_async_client.py +37 -21
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_async_client_errors.py +26 -9
- thordata_sdk-1.5.0/tests/test_tools.py +22 -0
- thordata_sdk-1.4.0/README.md +0 -164
- thordata_sdk-1.4.0/src/thordata/async_client.py +0 -2362
- thordata_sdk-1.4.0/src/thordata/client.py +0 -2479
- thordata_sdk-1.4.0/src/thordata/enums.py +0 -384
- thordata_sdk-1.4.0/src/thordata/models.py +0 -1197
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/LICENSE +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/setup.cfg +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/_example_utils.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/_utils.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/async_unlimited.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/demo.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/exceptions.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/retry.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata/serp_engines.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata_sdk.egg-info/dependency_links.txt +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata_sdk.egg-info/requires.txt +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/src/thordata_sdk.egg-info/top_level.txt +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_client.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_client_errors.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_enums.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_examples.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_exceptions.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_integration_proxy_protocols.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_models.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_spec_parity.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_task_status_and_wait.py +0 -0
- {thordata_sdk-1.4.0 → thordata_sdk-1.5.0}/tests/test_user_agent.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: thordata-sdk
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: The Official Python SDK for Thordata - AI Data Infrastructure & Proxy Network.
|
|
5
5
|
Author-email: Thordata Developer Team <support@thordata.com>
|
|
6
6
|
License: MIT
|
|
@@ -63,14 +63,13 @@ Dynamic: license-file
|
|
|
63
63
|
|
|
64
64
|
## 📖 Introduction
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
The **Thordata Python SDK v1.5.0** is a production-ready wrapper for Thordata's AI data infrastructure. It is architected for high reliability, strict type safety, and maximum performance.
|
|
67
67
|
|
|
68
|
-
**
|
|
69
|
-
*
|
|
70
|
-
* **⚡ Async
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* **🧩 Lazy Validation:** Only validate credentials for the features you actually use.
|
|
68
|
+
**Why v1.5.0?**
|
|
69
|
+
* **🛡️ Bulletproof Networking**: Custom core handles `HTTP`, `HTTPS`, and `SOCKS5h` (Remote DNS) tunneling, solving common SSL/TLS handshake issues in complex network environments.
|
|
70
|
+
* **⚡ Async First**: First-class `asyncio` support with `aiohttp` for high-concurrency scraping (1000+ RPS).
|
|
71
|
+
* **🧩 100% API Coverage**: Every endpoint documented by Thordata (including Hourly Usage, Server Monitor, and Task Management) is implemented.
|
|
72
|
+
* **🤖 Type Safe**: Fully typed (`mypy` strict) for excellent IDE autocompletion and error checking.
|
|
74
73
|
|
|
75
74
|
---
|
|
76
75
|
|
|
@@ -84,72 +83,74 @@ pip install thordata-sdk
|
|
|
84
83
|
|
|
85
84
|
## 🔐 Configuration
|
|
86
85
|
|
|
87
|
-
Set environment variables to avoid hardcoding credentials.
|
|
86
|
+
Set environment variables to avoid hardcoding credentials.
|
|
88
87
|
|
|
89
88
|
```bash
|
|
90
|
-
# [
|
|
91
|
-
export THORDATA_SCRAPER_TOKEN="
|
|
89
|
+
# [Scraping APIs]
|
|
90
|
+
export THORDATA_SCRAPER_TOKEN="your_scraper_token"
|
|
92
91
|
|
|
93
|
-
# [
|
|
92
|
+
# [Management APIs]
|
|
93
|
+
export THORDATA_PUBLIC_TOKEN="your_public_token"
|
|
94
|
+
export THORDATA_PUBLIC_KEY="your_public_key"
|
|
95
|
+
|
|
96
|
+
# [Proxy Network]
|
|
94
97
|
export THORDATA_RESIDENTIAL_USERNAME="your_username"
|
|
95
98
|
export THORDATA_RESIDENTIAL_PASSWORD="your_password"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
# [Required for Task Management]
|
|
99
|
-
export THORDATA_PUBLIC_TOKEN="public_token"
|
|
100
|
-
export THORDATA_PUBLIC_KEY="public_key"
|
|
99
|
+
# Optional: Set upstream proxy for local dev (e.g., Clash)
|
|
100
|
+
# export THORDATA_UPSTREAM_PROXY="http://127.0.0.1:7890"
|
|
101
101
|
```
|
|
102
102
|
|
|
103
103
|
---
|
|
104
104
|
|
|
105
105
|
## 🚀 Quick Start
|
|
106
106
|
|
|
107
|
-
### 1. SERP Search (Google/Bing
|
|
107
|
+
### 1. SERP Search (Google/Bing)
|
|
108
108
|
|
|
109
109
|
```python
|
|
110
110
|
from thordata import ThordataClient, Engine
|
|
111
111
|
|
|
112
|
-
client = ThordataClient()
|
|
112
|
+
client = ThordataClient()
|
|
113
113
|
|
|
114
|
-
#
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
# Search Google
|
|
115
|
+
results = client.serp_search(
|
|
116
|
+
query="latest AI trends",
|
|
117
|
+
engine=Engine.GOOGLE,
|
|
118
|
+
num=10,
|
|
119
|
+
location="United States"
|
|
120
|
+
)
|
|
117
121
|
|
|
118
|
-
for
|
|
119
|
-
print(f"
|
|
122
|
+
for item in results.get("organic", []):
|
|
123
|
+
print(f"{item['title']} - {item['link']}")
|
|
120
124
|
```
|
|
121
125
|
|
|
122
126
|
### 2. Universal Scrape (Web Unlocker)
|
|
123
127
|
|
|
124
|
-
|
|
128
|
+
Automatically handles JS rendering, CAPTCHAs, and fingerprinting.
|
|
125
129
|
|
|
126
130
|
```python
|
|
127
131
|
html = client.universal_scrape(
|
|
128
|
-
url="https://example.com
|
|
132
|
+
url="https://example.com",
|
|
129
133
|
js_render=True,
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
country="us",
|
|
135
|
+
wait_for=".content-loaded" # Smart waiting
|
|
132
136
|
)
|
|
133
|
-
print(f"Scraped {len(html)} bytes")
|
|
134
137
|
```
|
|
135
138
|
|
|
136
|
-
### 3. High-Performance Proxy
|
|
139
|
+
### 3. High-Performance Proxy Tunneling
|
|
137
140
|
|
|
138
|
-
Use Thordata's residential IPs with
|
|
141
|
+
Use Thordata's residential IPs directly with `requests` (Sync) or `aiohttp` (Async). The SDK handles the complex authentication and rotation logic.
|
|
139
142
|
|
|
140
143
|
```python
|
|
141
144
|
from thordata import ProxyConfig, ProxyProduct
|
|
142
145
|
|
|
143
|
-
# Config is optional if env vars are set
|
|
146
|
+
# Config is optional if env vars are set
|
|
144
147
|
proxy = ProxyConfig(
|
|
145
148
|
product=ProxyProduct.RESIDENTIAL,
|
|
146
149
|
country="jp",
|
|
147
|
-
city="tokyo",
|
|
148
|
-
session_id="session-001",
|
|
149
150
|
session_duration=10 # Sticky IP for 10 mins
|
|
150
151
|
)
|
|
151
152
|
|
|
152
|
-
#
|
|
153
|
+
# The client automatically routes this through Thordata's network
|
|
153
154
|
response = client.get("https://httpbin.org/ip", proxy_config=proxy)
|
|
154
155
|
print(response.json())
|
|
155
156
|
```
|
|
@@ -158,9 +159,9 @@ print(response.json())
|
|
|
158
159
|
|
|
159
160
|
## ⚙️ Advanced Usage
|
|
160
161
|
|
|
161
|
-
### Async
|
|
162
|
+
### Async High-Concurrency
|
|
162
163
|
|
|
163
|
-
|
|
164
|
+
Perfect for building high-throughput AI agents.
|
|
164
165
|
|
|
165
166
|
```python
|
|
166
167
|
import asyncio
|
|
@@ -168,20 +169,17 @@ from thordata import AsyncThordataClient
|
|
|
168
169
|
|
|
169
170
|
async def main():
|
|
170
171
|
async with AsyncThordataClient() as client:
|
|
171
|
-
# Fire off
|
|
172
|
-
tasks = [
|
|
173
|
-
client.serp_search(f"query {i}")
|
|
174
|
-
for i in range(5)
|
|
175
|
-
]
|
|
172
|
+
# Fire off 10 requests in parallel
|
|
173
|
+
tasks = [client.serp_search(f"query {i}") for i in range(10)]
|
|
176
174
|
results = await asyncio.gather(*tasks)
|
|
177
175
|
print(f"Completed {len(results)} searches")
|
|
178
176
|
|
|
179
177
|
asyncio.run(main())
|
|
180
178
|
```
|
|
181
179
|
|
|
182
|
-
###
|
|
180
|
+
### Task Management (Batch Scraping)
|
|
183
181
|
|
|
184
|
-
|
|
182
|
+
Handle large-scale scraping jobs asynchronously.
|
|
185
183
|
|
|
186
184
|
```python
|
|
187
185
|
# 1. Create a task
|
|
@@ -192,13 +190,38 @@ task_id = client.create_scraper_task(
|
|
|
192
190
|
parameters={"url": "https://example.com"}
|
|
193
191
|
)
|
|
194
192
|
|
|
195
|
-
# 2.
|
|
196
|
-
status = client.wait_for_task(task_id)
|
|
193
|
+
# 2. Poll for completion (Helper method)
|
|
194
|
+
status = client.wait_for_task(task_id, max_wait=600)
|
|
195
|
+
|
|
196
|
+
# 3. Download results
|
|
197
|
+
if status == "finished":
|
|
198
|
+
data_url = client.get_task_result(task_id)
|
|
199
|
+
print(f"Download: {data_url}")
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 🛠️ Management APIs
|
|
205
|
+
|
|
206
|
+
Manage your infrastructure programmatically.
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
# Check Balance
|
|
210
|
+
balance = client.get_traffic_balance()
|
|
197
211
|
|
|
198
|
-
#
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
212
|
+
# Manage Whitelist
|
|
213
|
+
client.add_whitelist_ip("1.2.3.4")
|
|
214
|
+
|
|
215
|
+
# Create Sub-users
|
|
216
|
+
client.create_proxy_user("new_user", "pass123", traffic_limit=500)
|
|
217
|
+
|
|
218
|
+
# Monitor Unlimited Proxies
|
|
219
|
+
monitor = client.unlimited.get_server_monitor(
|
|
220
|
+
ins_id="ins-123",
|
|
221
|
+
region="us",
|
|
222
|
+
start_time=1700000000,
|
|
223
|
+
end_time=1700003600
|
|
224
|
+
)
|
|
202
225
|
```
|
|
203
226
|
|
|
204
227
|
---
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Thordata Python SDK
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<img src="https://img.shields.io/badge/Thordata-AI%20Infrastructure-blue?style=for-the-badge" alt="Thordata Logo">
|
|
6
|
+
|
|
7
|
+
**The Official Python Client for Thordata APIs**
|
|
8
|
+
|
|
9
|
+
*Proxy Network • SERP API • Web Unlocker • Web Scraper API*
|
|
10
|
+
|
|
11
|
+
[](https://pypi.org/project/thordata-sdk/)
|
|
12
|
+
[](https://pypi.org/project/thordata-sdk/)
|
|
13
|
+
[](LICENSE)
|
|
14
|
+
[](https://github.com/Thordata/thordata-python-sdk/actions)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 📖 Introduction
|
|
21
|
+
|
|
22
|
+
The **Thordata Python SDK v1.5.0** is a production-ready wrapper for Thordata's AI data infrastructure. It is architected for high reliability, strict type safety, and maximum performance.
|
|
23
|
+
|
|
24
|
+
**Why v1.5.0?**
|
|
25
|
+
* **🛡️ Bulletproof Networking**: Custom core handles `HTTP`, `HTTPS`, and `SOCKS5h` (Remote DNS) tunneling, solving common SSL/TLS handshake issues in complex network environments.
|
|
26
|
+
* **⚡ Async First**: First-class `asyncio` support with `aiohttp` for high-concurrency scraping (1000+ RPS).
|
|
27
|
+
* **🧩 100% API Coverage**: Every endpoint documented by Thordata (including Hourly Usage, Server Monitor, and Task Management) is implemented.
|
|
28
|
+
* **🤖 Type Safe**: Fully typed (`mypy` strict) for excellent IDE autocompletion and error checking.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 📦 Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install thordata-sdk
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 🔐 Configuration
|
|
41
|
+
|
|
42
|
+
Set environment variables to avoid hardcoding credentials.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# [Scraping APIs]
|
|
46
|
+
export THORDATA_SCRAPER_TOKEN="your_scraper_token"
|
|
47
|
+
|
|
48
|
+
# [Management APIs]
|
|
49
|
+
export THORDATA_PUBLIC_TOKEN="your_public_token"
|
|
50
|
+
export THORDATA_PUBLIC_KEY="your_public_key"
|
|
51
|
+
|
|
52
|
+
# [Proxy Network]
|
|
53
|
+
export THORDATA_RESIDENTIAL_USERNAME="your_username"
|
|
54
|
+
export THORDATA_RESIDENTIAL_PASSWORD="your_password"
|
|
55
|
+
# Optional: Set upstream proxy for local dev (e.g., Clash)
|
|
56
|
+
# export THORDATA_UPSTREAM_PROXY="http://127.0.0.1:7890"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🚀 Quick Start
|
|
62
|
+
|
|
63
|
+
### 1. SERP Search (Google/Bing)
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from thordata import ThordataClient, Engine
|
|
67
|
+
|
|
68
|
+
client = ThordataClient()
|
|
69
|
+
|
|
70
|
+
# Search Google
|
|
71
|
+
results = client.serp_search(
|
|
72
|
+
query="latest AI trends",
|
|
73
|
+
engine=Engine.GOOGLE,
|
|
74
|
+
num=10,
|
|
75
|
+
location="United States"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
for item in results.get("organic", []):
|
|
79
|
+
print(f"{item['title']} - {item['link']}")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2. Universal Scrape (Web Unlocker)
|
|
83
|
+
|
|
84
|
+
Automatically handles JS rendering, CAPTCHAs, and fingerprinting.
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
html = client.universal_scrape(
|
|
88
|
+
url="https://example.com",
|
|
89
|
+
js_render=True,
|
|
90
|
+
country="us",
|
|
91
|
+
wait_for=".content-loaded" # Smart waiting
|
|
92
|
+
)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 3. High-Performance Proxy Tunneling
|
|
96
|
+
|
|
97
|
+
Use Thordata's residential IPs directly with `requests` (Sync) or `aiohttp` (Async). The SDK handles the complex authentication and rotation logic.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from thordata import ProxyConfig, ProxyProduct
|
|
101
|
+
|
|
102
|
+
# Config is optional if env vars are set
|
|
103
|
+
proxy = ProxyConfig(
|
|
104
|
+
product=ProxyProduct.RESIDENTIAL,
|
|
105
|
+
country="jp",
|
|
106
|
+
session_duration=10 # Sticky IP for 10 mins
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
# The client automatically routes this through Thordata's network
|
|
110
|
+
response = client.get("https://httpbin.org/ip", proxy_config=proxy)
|
|
111
|
+
print(response.json())
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ⚙️ Advanced Usage
|
|
117
|
+
|
|
118
|
+
### Async High-Concurrency
|
|
119
|
+
|
|
120
|
+
Perfect for building high-throughput AI agents.
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
import asyncio
|
|
124
|
+
from thordata import AsyncThordataClient
|
|
125
|
+
|
|
126
|
+
async def main():
|
|
127
|
+
async with AsyncThordataClient() as client:
|
|
128
|
+
# Fire off 10 requests in parallel
|
|
129
|
+
tasks = [client.serp_search(f"query {i}") for i in range(10)]
|
|
130
|
+
results = await asyncio.gather(*tasks)
|
|
131
|
+
print(f"Completed {len(results)} searches")
|
|
132
|
+
|
|
133
|
+
asyncio.run(main())
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Task Management (Batch Scraping)
|
|
137
|
+
|
|
138
|
+
Handle large-scale scraping jobs asynchronously.
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
# 1. Create a task
|
|
142
|
+
task_id = client.create_scraper_task(
|
|
143
|
+
file_name="daily_scrape",
|
|
144
|
+
spider_id="universal",
|
|
145
|
+
spider_name="universal",
|
|
146
|
+
parameters={"url": "https://example.com"}
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
# 2. Poll for completion (Helper method)
|
|
150
|
+
status = client.wait_for_task(task_id, max_wait=600)
|
|
151
|
+
|
|
152
|
+
# 3. Download results
|
|
153
|
+
if status == "finished":
|
|
154
|
+
data_url = client.get_task_result(task_id)
|
|
155
|
+
print(f"Download: {data_url}")
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 🛠️ Management APIs
|
|
161
|
+
|
|
162
|
+
Manage your infrastructure programmatically.
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
# Check Balance
|
|
166
|
+
balance = client.get_traffic_balance()
|
|
167
|
+
|
|
168
|
+
# Manage Whitelist
|
|
169
|
+
client.add_whitelist_ip("1.2.3.4")
|
|
170
|
+
|
|
171
|
+
# Create Sub-users
|
|
172
|
+
client.create_proxy_user("new_user", "pass123", traffic_limit=500)
|
|
173
|
+
|
|
174
|
+
# Monitor Unlimited Proxies
|
|
175
|
+
monitor = client.unlimited.get_server_monitor(
|
|
176
|
+
ins_id="ins-123",
|
|
177
|
+
region="us",
|
|
178
|
+
start_time=1700000000,
|
|
179
|
+
end_time=1700003600
|
|
180
|
+
)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 📄 License
|
|
186
|
+
|
|
187
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
|
|
6
6
|
[project]
|
|
7
7
|
name = "thordata-sdk"
|
|
8
|
-
version = "1.
|
|
8
|
+
version = "1.5.0"
|
|
9
9
|
description = "The Official Python SDK for Thordata - AI Data Infrastructure & Proxy Network."
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3.9"
|
|
@@ -3,47 +3,17 @@ Thordata Python SDK
|
|
|
3
3
|
|
|
4
4
|
Official Python client for Thordata's Proxy Network, SERP API,
|
|
5
5
|
Universal Scraping API (Web Unlocker), and Web Scraper API.
|
|
6
|
-
|
|
7
|
-
Basic Usage:
|
|
8
|
-
>>> from thordata import ThordataClient
|
|
9
|
-
>>>
|
|
10
|
-
>>> client = ThordataClient(
|
|
11
|
-
... scraper_token="your_token",
|
|
12
|
-
... public_token="your_public_token",
|
|
13
|
-
... public_key="your_public_key"
|
|
14
|
-
... )
|
|
15
|
-
>>>
|
|
16
|
-
>>> # Proxy request
|
|
17
|
-
>>> response = client.get("https://httpbin.org/ip")
|
|
18
|
-
>>>
|
|
19
|
-
>>> # SERP search
|
|
20
|
-
>>> results = client.serp_search("python tutorial", engine="google")
|
|
21
|
-
>>>
|
|
22
|
-
>>> # Universal scrape
|
|
23
|
-
>>> html = client.universal_scrape("https://example.com", js_render=True)
|
|
24
|
-
|
|
25
|
-
Async Usage:
|
|
26
|
-
>>> from thordata import AsyncThordataClient
|
|
27
|
-
>>> import asyncio
|
|
28
|
-
>>>
|
|
29
|
-
>>> async def main():
|
|
30
|
-
... async with AsyncThordataClient(
|
|
31
|
-
... scraper_token="your_token"
|
|
32
|
-
... ) as client:
|
|
33
|
-
... response = await client.get("https://httpbin.org/ip")
|
|
34
|
-
>>>
|
|
35
|
-
>>> asyncio.run(main())
|
|
36
6
|
"""
|
|
37
7
|
|
|
38
|
-
__version__ = "1.
|
|
39
|
-
__author__ = "Thordata Developer Team"
|
|
8
|
+
__version__ = "1.5.0"
|
|
9
|
+
__author__ = "Thordata Developer Team/Kael Odin"
|
|
40
10
|
__email__ = "support@thordata.com"
|
|
41
11
|
|
|
42
12
|
# Main clients
|
|
43
13
|
from .async_client import AsyncThordataClient
|
|
44
14
|
from .client import ThordataClient
|
|
45
15
|
|
|
46
|
-
# Enums
|
|
16
|
+
# Enums (Legacy Import Path)
|
|
47
17
|
from .enums import (
|
|
48
18
|
BingSearchType,
|
|
49
19
|
Continent,
|
|
@@ -76,7 +46,7 @@ from .exceptions import (
|
|
|
76
46
|
ThordataValidationError,
|
|
77
47
|
)
|
|
78
48
|
|
|
79
|
-
# Models
|
|
49
|
+
# Models (Legacy Import Path)
|
|
80
50
|
from .models import (
|
|
81
51
|
CommonSettings,
|
|
82
52
|
ProxyConfig,
|
|
@@ -99,12 +69,9 @@ from .retry import RetryConfig
|
|
|
99
69
|
|
|
100
70
|
# Public API
|
|
101
71
|
__all__ = [
|
|
102
|
-
# Version
|
|
103
72
|
"__version__",
|
|
104
|
-
# Clients
|
|
105
73
|
"ThordataClient",
|
|
106
74
|
"AsyncThordataClient",
|
|
107
|
-
# Enums
|
|
108
75
|
"Engine",
|
|
109
76
|
"GoogleSearchType",
|
|
110
77
|
"BingSearchType",
|
|
@@ -120,7 +87,6 @@ __all__ = [
|
|
|
120
87
|
"ProxyHost",
|
|
121
88
|
"ProxyPort",
|
|
122
89
|
"GoogleTbm",
|
|
123
|
-
# Models
|
|
124
90
|
"ProxyConfig",
|
|
125
91
|
"ProxyProduct",
|
|
126
92
|
"ProxyServer",
|
|
@@ -135,7 +101,6 @@ __all__ = [
|
|
|
135
101
|
"CommonSettings",
|
|
136
102
|
"VideoTaskConfig",
|
|
137
103
|
"TaskStatusResponse",
|
|
138
|
-
# Exceptions
|
|
139
104
|
"ThordataError",
|
|
140
105
|
"ThordataConfigError",
|
|
141
106
|
"ThordataNetworkError",
|
|
@@ -146,6 +111,5 @@ __all__ = [
|
|
|
146
111
|
"ThordataServerError",
|
|
147
112
|
"ThordataValidationError",
|
|
148
113
|
"ThordataNotCollectedError",
|
|
149
|
-
# Retry
|
|
150
114
|
"RetryConfig",
|
|
151
115
|
]
|