capbypass-sdk 1.0.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.
- capbypass_sdk-1.0.0/LICENSE +21 -0
- capbypass_sdk-1.0.0/PKG-INFO +172 -0
- capbypass_sdk-1.0.0/README.md +137 -0
- capbypass_sdk-1.0.0/pyproject.toml +78 -0
- capbypass_sdk-1.0.0/setup.cfg +4 -0
- capbypass_sdk-1.0.0/src/capbypass/__init__.py +41 -0
- capbypass_sdk-1.0.0/src/capbypass/client.py +347 -0
- capbypass_sdk-1.0.0/src/capbypass/errors.py +80 -0
- capbypass_sdk-1.0.0/src/capbypass/types.py +24 -0
- capbypass_sdk-1.0.0/src/capbypass_sdk.egg-info/PKG-INFO +172 -0
- capbypass_sdk-1.0.0/src/capbypass_sdk.egg-info/SOURCES.txt +12 -0
- capbypass_sdk-1.0.0/src/capbypass_sdk.egg-info/dependency_links.txt +1 -0
- capbypass_sdk-1.0.0/src/capbypass_sdk.egg-info/requires.txt +9 -0
- capbypass_sdk-1.0.0/src/capbypass_sdk.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 CapBypass Development
|
|
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,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: capbypass-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for CapBypass CAPTCHA solving API
|
|
5
|
+
Author-email: CapBypass Development <dev@capbypass.dev>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://capbypass.dev
|
|
8
|
+
Project-URL: Documentation, https://capbypass.dev/docs/sdks/python
|
|
9
|
+
Project-URL: Repository, https://github.com/CapBypass-Development/capbypass-sdk-python
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/CapBypass-Development/capbypass-sdk-python/issues
|
|
11
|
+
Keywords: captcha,recaptcha,aws-waf,automation,solver
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
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: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests>=2.31.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-mock>=3.11.0; extra == "dev"
|
|
30
|
+
Requires-Dist: responses>=0.23.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
33
|
+
Requires-Dist: types-requests>=2.31.0; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# CapBypass Python SDK
|
|
37
|
+
|
|
38
|
+
[](https://pypi.org/project/capbypass-sdk/)
|
|
39
|
+
[](https://pypi.org/project/capbypass-sdk/)
|
|
40
|
+
[](https://pepy.tech/project/capbypass-sdk)
|
|
41
|
+
[](https://github.com/CapBypass-Development/capbypass-sdk-python)
|
|
42
|
+
|
|
43
|
+
Official Python SDK for CapBypass CAPTCHA solving API.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- โจ Simple `solve()` method with auto-polling
|
|
48
|
+
- ๐ฏ Advanced `createTask()` + `getTaskResult()` for granular control
|
|
49
|
+
- ๐ฐ `getBalance()` to check account balance
|
|
50
|
+
- ๐ Automatic retry logic for network failures
|
|
51
|
+
- ๐ก๏ธ Comprehensive error handling
|
|
52
|
+
- ๐ Type hints for better IDE support
|
|
53
|
+
- ๐งช 100% test coverage
|
|
54
|
+
|
|
55
|
+
## Supported CAPTCHA Types
|
|
56
|
+
|
|
57
|
+
- reCAPTCHA v2 (normal & invisible)
|
|
58
|
+
- reCAPTCHA v3
|
|
59
|
+
- reCAPTCHA v3 Enterprise
|
|
60
|
+
- AWS WAF CAPTCHA
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install capbypass-sdk
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from capbypass import CapBypass
|
|
72
|
+
|
|
73
|
+
# Initialize client
|
|
74
|
+
client = CapBypass(api_key="your-api-key")
|
|
75
|
+
# Or use environment variable: export CAPBYPASS_API_KEY="your-key"
|
|
76
|
+
|
|
77
|
+
# Solve CAPTCHA (auto-polling)
|
|
78
|
+
solution = client.solve({
|
|
79
|
+
"type": "ReCaptchaV2TaskProxyLess",
|
|
80
|
+
"websiteURL": "https://example.com",
|
|
81
|
+
"websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
print(solution["gRecaptchaResponse"])
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Advanced Usage
|
|
88
|
+
|
|
89
|
+
### Granular Control
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
# Create task
|
|
93
|
+
task_id = client.createTask({
|
|
94
|
+
"type": "ReCaptchaV2TaskProxyLess",
|
|
95
|
+
"websiteURL": "https://example.com",
|
|
96
|
+
"websiteKey": "site-key"
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
# Poll for result
|
|
100
|
+
import time
|
|
101
|
+
while True:
|
|
102
|
+
result = client.getTaskResult(task_id)
|
|
103
|
+
if result["status"] == "ready":
|
|
104
|
+
print(result["solution"])
|
|
105
|
+
break
|
|
106
|
+
time.sleep(5)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Check Balance
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
balance = client.getBalance()
|
|
113
|
+
print(f"Balance: ${balance:.4f}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Error Handling
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from capbypass import CapBypass
|
|
120
|
+
from capbypass.errors import (
|
|
121
|
+
AuthenticationError,
|
|
122
|
+
InsufficientBalanceError,
|
|
123
|
+
TimeoutError,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
solution = client.solve(task)
|
|
128
|
+
except AuthenticationError:
|
|
129
|
+
print("Invalid API key")
|
|
130
|
+
except InsufficientBalanceError:
|
|
131
|
+
print("Insufficient balance")
|
|
132
|
+
except TimeoutError:
|
|
133
|
+
print("Task timed out")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Documentation
|
|
137
|
+
|
|
138
|
+
Full documentation: https://capbypass.dev/docs/sdks/python
|
|
139
|
+
|
|
140
|
+
## Examples
|
|
141
|
+
|
|
142
|
+
See [examples/](examples/) directory for complete examples:
|
|
143
|
+
|
|
144
|
+
- [recaptcha_v2.py](examples/recaptcha_v2.py) - reCAPTCHA v2 solving
|
|
145
|
+
- [recaptcha_v3.py](examples/recaptcha_v3.py) - reCAPTCHA v3 solving
|
|
146
|
+
- [aws_waf.py](examples/aws_waf.py) - AWS WAF CAPTCHA solving
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Install dev dependencies
|
|
152
|
+
pip install -e ".[dev]"
|
|
153
|
+
|
|
154
|
+
# Run tests
|
|
155
|
+
pytest
|
|
156
|
+
|
|
157
|
+
# Run linter
|
|
158
|
+
ruff check .
|
|
159
|
+
|
|
160
|
+
# Run type checker
|
|
161
|
+
mypy src/
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|
|
167
|
+
|
|
168
|
+
## Support
|
|
169
|
+
|
|
170
|
+
- Documentation: https://capbypass.dev/docs
|
|
171
|
+
- Issues: https://github.com/CapBypass-Development/capbypass-sdk-python/issues
|
|
172
|
+
- Email: support@capbypass.dev
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# CapBypass Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/capbypass-sdk/)
|
|
4
|
+
[](https://pypi.org/project/capbypass-sdk/)
|
|
5
|
+
[](https://pepy.tech/project/capbypass-sdk)
|
|
6
|
+
[](https://github.com/CapBypass-Development/capbypass-sdk-python)
|
|
7
|
+
|
|
8
|
+
Official Python SDK for CapBypass CAPTCHA solving API.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- โจ Simple `solve()` method with auto-polling
|
|
13
|
+
- ๐ฏ Advanced `createTask()` + `getTaskResult()` for granular control
|
|
14
|
+
- ๐ฐ `getBalance()` to check account balance
|
|
15
|
+
- ๐ Automatic retry logic for network failures
|
|
16
|
+
- ๐ก๏ธ Comprehensive error handling
|
|
17
|
+
- ๐ Type hints for better IDE support
|
|
18
|
+
- ๐งช 100% test coverage
|
|
19
|
+
|
|
20
|
+
## Supported CAPTCHA Types
|
|
21
|
+
|
|
22
|
+
- reCAPTCHA v2 (normal & invisible)
|
|
23
|
+
- reCAPTCHA v3
|
|
24
|
+
- reCAPTCHA v3 Enterprise
|
|
25
|
+
- AWS WAF CAPTCHA
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install capbypass-sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from capbypass import CapBypass
|
|
37
|
+
|
|
38
|
+
# Initialize client
|
|
39
|
+
client = CapBypass(api_key="your-api-key")
|
|
40
|
+
# Or use environment variable: export CAPBYPASS_API_KEY="your-key"
|
|
41
|
+
|
|
42
|
+
# Solve CAPTCHA (auto-polling)
|
|
43
|
+
solution = client.solve({
|
|
44
|
+
"type": "ReCaptchaV2TaskProxyLess",
|
|
45
|
+
"websiteURL": "https://example.com",
|
|
46
|
+
"websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
print(solution["gRecaptchaResponse"])
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Advanced Usage
|
|
53
|
+
|
|
54
|
+
### Granular Control
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
# Create task
|
|
58
|
+
task_id = client.createTask({
|
|
59
|
+
"type": "ReCaptchaV2TaskProxyLess",
|
|
60
|
+
"websiteURL": "https://example.com",
|
|
61
|
+
"websiteKey": "site-key"
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
# Poll for result
|
|
65
|
+
import time
|
|
66
|
+
while True:
|
|
67
|
+
result = client.getTaskResult(task_id)
|
|
68
|
+
if result["status"] == "ready":
|
|
69
|
+
print(result["solution"])
|
|
70
|
+
break
|
|
71
|
+
time.sleep(5)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Check Balance
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
balance = client.getBalance()
|
|
78
|
+
print(f"Balance: ${balance:.4f}")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Error Handling
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from capbypass import CapBypass
|
|
85
|
+
from capbypass.errors import (
|
|
86
|
+
AuthenticationError,
|
|
87
|
+
InsufficientBalanceError,
|
|
88
|
+
TimeoutError,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
try:
|
|
92
|
+
solution = client.solve(task)
|
|
93
|
+
except AuthenticationError:
|
|
94
|
+
print("Invalid API key")
|
|
95
|
+
except InsufficientBalanceError:
|
|
96
|
+
print("Insufficient balance")
|
|
97
|
+
except TimeoutError:
|
|
98
|
+
print("Task timed out")
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
Full documentation: https://capbypass.dev/docs/sdks/python
|
|
104
|
+
|
|
105
|
+
## Examples
|
|
106
|
+
|
|
107
|
+
See [examples/](examples/) directory for complete examples:
|
|
108
|
+
|
|
109
|
+
- [recaptcha_v2.py](examples/recaptcha_v2.py) - reCAPTCHA v2 solving
|
|
110
|
+
- [recaptcha_v3.py](examples/recaptcha_v3.py) - reCAPTCHA v3 solving
|
|
111
|
+
- [aws_waf.py](examples/aws_waf.py) - AWS WAF CAPTCHA solving
|
|
112
|
+
|
|
113
|
+
## Development
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Install dev dependencies
|
|
117
|
+
pip install -e ".[dev]"
|
|
118
|
+
|
|
119
|
+
# Run tests
|
|
120
|
+
pytest
|
|
121
|
+
|
|
122
|
+
# Run linter
|
|
123
|
+
ruff check .
|
|
124
|
+
|
|
125
|
+
# Run type checker
|
|
126
|
+
mypy src/
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
MIT
|
|
132
|
+
|
|
133
|
+
## Support
|
|
134
|
+
|
|
135
|
+
- Documentation: https://capbypass.dev/docs
|
|
136
|
+
- Issues: https://github.com/CapBypass-Development/capbypass-sdk-python/issues
|
|
137
|
+
- Email: support@capbypass.dev
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "capbypass-sdk"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Official Python SDK for CapBypass CAPTCHA solving API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{name = "CapBypass Development", email = "dev@capbypass.dev"}
|
|
12
|
+
]
|
|
13
|
+
license = {text = "MIT"}
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.8",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
25
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
26
|
+
]
|
|
27
|
+
keywords = ["captcha", "recaptcha", "aws-waf", "automation", "solver"]
|
|
28
|
+
requires-python = ">=3.8"
|
|
29
|
+
dependencies = [
|
|
30
|
+
"requests>=2.31.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.urls]
|
|
34
|
+
Homepage = "https://capbypass.dev"
|
|
35
|
+
Documentation = "https://capbypass.dev/docs/sdks/python"
|
|
36
|
+
Repository = "https://github.com/CapBypass-Development/capbypass-sdk-python"
|
|
37
|
+
"Bug Tracker" = "https://github.com/CapBypass-Development/capbypass-sdk-python/issues"
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = [
|
|
41
|
+
"pytest>=7.4.0",
|
|
42
|
+
"pytest-mock>=3.11.0",
|
|
43
|
+
"responses>=0.23.0",
|
|
44
|
+
"ruff>=0.1.0",
|
|
45
|
+
"mypy>=1.5.0",
|
|
46
|
+
"types-requests>=2.31.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.packages.find]
|
|
50
|
+
where = ["src"]
|
|
51
|
+
|
|
52
|
+
[tool.setuptools.package-data]
|
|
53
|
+
capbypass = ["py.typed"]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
line-length = 100
|
|
57
|
+
target-version = "py38"
|
|
58
|
+
|
|
59
|
+
[tool.ruff.lint]
|
|
60
|
+
select = ["E", "F", "I", "N", "W", "UP"]
|
|
61
|
+
ignore = ["E501"] # Line too long (handled by formatter)
|
|
62
|
+
|
|
63
|
+
[tool.mypy]
|
|
64
|
+
python_version = "3.8"
|
|
65
|
+
warn_return_any = true
|
|
66
|
+
warn_unused_configs = true
|
|
67
|
+
disallow_untyped_defs = false
|
|
68
|
+
ignore_missing_imports = true
|
|
69
|
+
|
|
70
|
+
[tool.pytest.ini_options]
|
|
71
|
+
testpaths = ["tests"]
|
|
72
|
+
python_files = ["test_*.py"]
|
|
73
|
+
python_classes = ["Test*"]
|
|
74
|
+
python_functions = ["test_*"]
|
|
75
|
+
addopts = "-v --strict-markers"
|
|
76
|
+
markers = [
|
|
77
|
+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
78
|
+
]
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""CapBypass Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for CapBypass CAPTCHA solving API.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .client import CapBypass
|
|
7
|
+
from .errors import (
|
|
8
|
+
CapBypassError,
|
|
9
|
+
AuthenticationError,
|
|
10
|
+
InsufficientBalanceError,
|
|
11
|
+
ValidationError,
|
|
12
|
+
TaskNotFoundError,
|
|
13
|
+
SolverError,
|
|
14
|
+
TimeoutError,
|
|
15
|
+
InternalError,
|
|
16
|
+
NetworkError,
|
|
17
|
+
GatewayError,
|
|
18
|
+
ServerError,
|
|
19
|
+
RateLimitError,
|
|
20
|
+
ParseError,
|
|
21
|
+
)
|
|
22
|
+
from .types import TaskType
|
|
23
|
+
|
|
24
|
+
__version__ = "1.0.0"
|
|
25
|
+
__all__ = [
|
|
26
|
+
"CapBypass",
|
|
27
|
+
"CapBypassError",
|
|
28
|
+
"AuthenticationError",
|
|
29
|
+
"InsufficientBalanceError",
|
|
30
|
+
"ValidationError",
|
|
31
|
+
"TaskNotFoundError",
|
|
32
|
+
"SolverError",
|
|
33
|
+
"TimeoutError",
|
|
34
|
+
"InternalError",
|
|
35
|
+
"NetworkError",
|
|
36
|
+
"GatewayError",
|
|
37
|
+
"ServerError",
|
|
38
|
+
"RateLimitError",
|
|
39
|
+
"ParseError",
|
|
40
|
+
"TaskType",
|
|
41
|
+
]
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"""CapBypass API client."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import time
|
|
5
|
+
import random
|
|
6
|
+
from typing import Dict, Any, Optional
|
|
7
|
+
|
|
8
|
+
import requests
|
|
9
|
+
|
|
10
|
+
from .errors import (
|
|
11
|
+
AuthenticationError,
|
|
12
|
+
InsufficientBalanceError,
|
|
13
|
+
ValidationError,
|
|
14
|
+
TaskNotFoundError,
|
|
15
|
+
SolverError,
|
|
16
|
+
TimeoutError as CapBypassTimeoutError,
|
|
17
|
+
InternalError,
|
|
18
|
+
NetworkError,
|
|
19
|
+
GatewayError,
|
|
20
|
+
ServerError,
|
|
21
|
+
RateLimitError,
|
|
22
|
+
ParseError,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class CapBypass:
|
|
27
|
+
"""CapBypass API client for CAPTCHA solving.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
api_key: CapBypass API key. If not provided, reads from CAPBYPASS_API_KEY env var.
|
|
31
|
+
base_url: API gateway URL. Defaults to production gateway.
|
|
32
|
+
|
|
33
|
+
Raises:
|
|
34
|
+
ValueError: If api_key is not provided and CAPBYPASS_API_KEY env var is not set.
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
>>> from capbypass import CapBypass
|
|
38
|
+
>>> client = CapBypass(api_key="your-api-key")
|
|
39
|
+
>>> result = client.solve({
|
|
40
|
+
... "type": "ReCaptchaV2TaskProxyLess",
|
|
41
|
+
... "websiteURL": "https://example.com",
|
|
42
|
+
... "websiteKey": "site-key"
|
|
43
|
+
... })
|
|
44
|
+
>>> print(result["gRecaptchaResponse"])
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(
|
|
48
|
+
self,
|
|
49
|
+
api_key: Optional[str] = None,
|
|
50
|
+
base_url: str = "https://gateway.strayder.io",
|
|
51
|
+
):
|
|
52
|
+
self.api_key = api_key or os.getenv("CAPBYPASS_API_KEY")
|
|
53
|
+
if not self.api_key:
|
|
54
|
+
raise ValueError(
|
|
55
|
+
"API key is required. Provide via constructor or CAPBYPASS_API_KEY env var."
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
self.base_url = base_url.rstrip("/")
|
|
59
|
+
self.session = requests.Session()
|
|
60
|
+
self.session.headers.update({
|
|
61
|
+
"Content-Type": "application/json",
|
|
62
|
+
"User-Agent": "capbypass-sdk-python/1.0.0",
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
def _make_request(
|
|
66
|
+
self,
|
|
67
|
+
endpoint: str,
|
|
68
|
+
payload: Dict[str, Any],
|
|
69
|
+
max_retries: int = 3,
|
|
70
|
+
) -> Dict[str, Any]:
|
|
71
|
+
"""Make HTTP request with retry logic.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
endpoint: API endpoint path (e.g., "/createTask")
|
|
75
|
+
payload: Request JSON payload
|
|
76
|
+
max_retries: Maximum number of retry attempts for network failures
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
Parsed JSON response
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
NetworkError: On connection failures
|
|
83
|
+
GatewayError: On 502/503/504 responses
|
|
84
|
+
ServerError: On 500 responses
|
|
85
|
+
RateLimitError: On 429 responses
|
|
86
|
+
ParseError: On malformed JSON responses
|
|
87
|
+
"""
|
|
88
|
+
url = f"{self.base_url}{endpoint}"
|
|
89
|
+
attempt = 0
|
|
90
|
+
|
|
91
|
+
while attempt <= max_retries:
|
|
92
|
+
try:
|
|
93
|
+
response = self.session.post(url, json=payload, timeout=30)
|
|
94
|
+
|
|
95
|
+
# Handle HTTP-layer errors
|
|
96
|
+
if response.status_code in (502, 503, 504):
|
|
97
|
+
if attempt < max_retries:
|
|
98
|
+
# Exponential backoff with jitter for gateway errors
|
|
99
|
+
backoff = min(10, 2 ** attempt) + random.uniform(0, 1)
|
|
100
|
+
time.sleep(backoff)
|
|
101
|
+
attempt += 1
|
|
102
|
+
continue
|
|
103
|
+
raise GatewayError(
|
|
104
|
+
error_code="GATEWAY_ERROR",
|
|
105
|
+
error_description=f"Gateway error: HTTP {response.status_code}",
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
if response.status_code == 500:
|
|
109
|
+
raise ServerError(
|
|
110
|
+
error_code="SERVER_ERROR",
|
|
111
|
+
error_description="Internal server error",
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
if response.status_code == 429:
|
|
115
|
+
raise RateLimitError(
|
|
116
|
+
error_code="RATE_LIMIT",
|
|
117
|
+
error_description="Rate limit exceeded",
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# Parse JSON response
|
|
121
|
+
try:
|
|
122
|
+
return response.json()
|
|
123
|
+
except ValueError as e:
|
|
124
|
+
raise ParseError(
|
|
125
|
+
error_code="PARSE_ERROR",
|
|
126
|
+
error_description=f"Malformed JSON response: {e}",
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
except requests.exceptions.ConnectionError as e:
|
|
130
|
+
if attempt < max_retries:
|
|
131
|
+
backoff = min(10, 2 ** attempt) + random.uniform(0, 1)
|
|
132
|
+
time.sleep(backoff)
|
|
133
|
+
attempt += 1
|
|
134
|
+
continue
|
|
135
|
+
raise NetworkError(
|
|
136
|
+
error_code="NETWORK_ERROR",
|
|
137
|
+
error_description=f"Connection failed: {e}",
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
except requests.exceptions.Timeout as e:
|
|
141
|
+
if attempt < max_retries:
|
|
142
|
+
backoff = min(10, 2 ** attempt) + random.uniform(0, 1)
|
|
143
|
+
time.sleep(backoff)
|
|
144
|
+
attempt += 1
|
|
145
|
+
continue
|
|
146
|
+
raise NetworkError(
|
|
147
|
+
error_code="NETWORK_ERROR",
|
|
148
|
+
error_description=f"Request timeout: {e}",
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
except requests.exceptions.RequestException as e:
|
|
152
|
+
raise NetworkError(
|
|
153
|
+
error_code="NETWORK_ERROR",
|
|
154
|
+
error_description=f"Request failed: {e}",
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# Should never reach here, but just in case
|
|
158
|
+
raise NetworkError(
|
|
159
|
+
error_code="NETWORK_ERROR",
|
|
160
|
+
error_description="Max retries exceeded",
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
def _handle_error_response(self, response: Dict[str, Any]) -> None:
|
|
164
|
+
"""Handle error responses from API.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
response: API response dict
|
|
168
|
+
|
|
169
|
+
Raises:
|
|
170
|
+
AuthenticationError: On ERROR_KEY_DOES_NOT_EXIST
|
|
171
|
+
InsufficientBalanceError: On ERROR_ZERO_BALANCE
|
|
172
|
+
ValidationError: On ERROR_INVALID_TASK_DATA
|
|
173
|
+
TaskNotFoundError: On ERROR_TASK_NOT_FOUND
|
|
174
|
+
SolverError: On ERROR_CAPTCHA_UNSOLVABLE
|
|
175
|
+
CapBypassTimeoutError: On ERROR_TIMEOUT
|
|
176
|
+
InternalError: On ERROR_INTERNAL or other errors
|
|
177
|
+
"""
|
|
178
|
+
error_id = response.get("errorId", 0)
|
|
179
|
+
if error_id == 0:
|
|
180
|
+
return # Success
|
|
181
|
+
|
|
182
|
+
error_code = response.get("errorCode", "UNKNOWN_ERROR")
|
|
183
|
+
error_description = response.get("errorDescription", "Unknown error")
|
|
184
|
+
|
|
185
|
+
# Map error codes to exception classes
|
|
186
|
+
error_map = {
|
|
187
|
+
"ERROR_KEY_DOES_NOT_EXIST": AuthenticationError,
|
|
188
|
+
"ERROR_ZERO_BALANCE": InsufficientBalanceError,
|
|
189
|
+
"ERROR_INVALID_TASK_DATA": ValidationError,
|
|
190
|
+
"ERROR_TASK_NOT_FOUND": TaskNotFoundError,
|
|
191
|
+
"ERROR_CAPTCHA_UNSOLVABLE": SolverError,
|
|
192
|
+
"ERROR_TIMEOUT": CapBypassTimeoutError,
|
|
193
|
+
"ERROR_INTERNAL": InternalError,
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
exception_class = error_map.get(error_code, InternalError)
|
|
197
|
+
raise exception_class(
|
|
198
|
+
error_code=error_code,
|
|
199
|
+
error_description=error_description,
|
|
200
|
+
error_id=error_id,
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
def createTask(self, task: Dict[str, Any]) -> str:
|
|
204
|
+
"""Create a CAPTCHA solving task.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
task: Task configuration dict with "type" and task-specific parameters
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
Task ID (UUID string)
|
|
211
|
+
|
|
212
|
+
Raises:
|
|
213
|
+
AuthenticationError: Invalid API key
|
|
214
|
+
InsufficientBalanceError: Account balance is zero
|
|
215
|
+
ValidationError: Invalid task data
|
|
216
|
+
|
|
217
|
+
Example:
|
|
218
|
+
>>> task_id = client.createTask({
|
|
219
|
+
... "type": "ReCaptchaV2TaskProxyLess",
|
|
220
|
+
... "websiteURL": "https://example.com",
|
|
221
|
+
... "websiteKey": "site-key"
|
|
222
|
+
... })
|
|
223
|
+
"""
|
|
224
|
+
payload = {
|
|
225
|
+
"clientKey": self.api_key,
|
|
226
|
+
"task": task,
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
response = self._make_request("/createTask", payload)
|
|
230
|
+
self._handle_error_response(response)
|
|
231
|
+
|
|
232
|
+
return response["taskId"]
|
|
233
|
+
|
|
234
|
+
def getTaskResult(self, task_id: str) -> Dict[str, Any]:
|
|
235
|
+
"""Get result of a CAPTCHA solving task.
|
|
236
|
+
|
|
237
|
+
Args:
|
|
238
|
+
task_id: Task ID returned from createTask()
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
Dict with "status" (processing/ready/failed), "solution" (if ready), error details (if failed)
|
|
242
|
+
|
|
243
|
+
Raises:
|
|
244
|
+
TaskNotFoundError: Task ID does not exist
|
|
245
|
+
AuthenticationError: Invalid API key
|
|
246
|
+
|
|
247
|
+
Example:
|
|
248
|
+
>>> result = client.getTaskResult(task_id)
|
|
249
|
+
>>> if result["status"] == "ready":
|
|
250
|
+
... print(result["solution"])
|
|
251
|
+
"""
|
|
252
|
+
payload = {
|
|
253
|
+
"clientKey": self.api_key,
|
|
254
|
+
"taskId": task_id,
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
response = self._make_request("/getTaskResult", payload)
|
|
258
|
+
self._handle_error_response(response)
|
|
259
|
+
|
|
260
|
+
return response
|
|
261
|
+
|
|
262
|
+
def solve(
|
|
263
|
+
self,
|
|
264
|
+
task: Dict[str, Any],
|
|
265
|
+
timeout: int = 120,
|
|
266
|
+
) -> Dict[str, Any]:
|
|
267
|
+
"""Create task and poll until solved (auto-polling).
|
|
268
|
+
|
|
269
|
+
Args:
|
|
270
|
+
task: Task configuration dict
|
|
271
|
+
timeout: Maximum time to wait in seconds (default: 120)
|
|
272
|
+
|
|
273
|
+
Returns:
|
|
274
|
+
Solution dict (varies by task type)
|
|
275
|
+
|
|
276
|
+
Raises:
|
|
277
|
+
CapBypassTimeoutError: Task exceeded timeout
|
|
278
|
+
SolverError: Task failed to solve
|
|
279
|
+
AuthenticationError: Invalid API key
|
|
280
|
+
InsufficientBalanceError: Account balance is zero
|
|
281
|
+
ValidationError: Invalid task data
|
|
282
|
+
|
|
283
|
+
Example:
|
|
284
|
+
>>> solution = client.solve({
|
|
285
|
+
... "type": "ReCaptchaV2TaskProxyLess",
|
|
286
|
+
... "websiteURL": "https://example.com",
|
|
287
|
+
... "websiteKey": "site-key"
|
|
288
|
+
... })
|
|
289
|
+
>>> print(solution["gRecaptchaResponse"])
|
|
290
|
+
"""
|
|
291
|
+
# Create task
|
|
292
|
+
task_id = self.createTask(task)
|
|
293
|
+
|
|
294
|
+
# Poll with adaptive intervals
|
|
295
|
+
start_time = time.time()
|
|
296
|
+
attempt = 0
|
|
297
|
+
|
|
298
|
+
while True:
|
|
299
|
+
# Check timeout (wall-clock time)
|
|
300
|
+
elapsed = time.time() - start_time
|
|
301
|
+
if elapsed > timeout:
|
|
302
|
+
raise CapBypassTimeoutError(
|
|
303
|
+
error_code="TIMEOUT",
|
|
304
|
+
error_description=f"Task exceeded timeout of {timeout}s",
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
# Get task result
|
|
308
|
+
result = self.getTaskResult(task_id)
|
|
309
|
+
status = result.get("status")
|
|
310
|
+
|
|
311
|
+
if status == "ready":
|
|
312
|
+
return result.get("solution", {})
|
|
313
|
+
|
|
314
|
+
if status == "failed":
|
|
315
|
+
error_description = result.get("errorDescription", "Task failed")
|
|
316
|
+
raise SolverError(
|
|
317
|
+
error_code="SOLVER_ERROR",
|
|
318
|
+
error_description=error_description,
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
# Adaptive polling: min(5, ceil(attempt / 2)) seconds
|
|
322
|
+
# Attempts 1-2 โ 1s, 3-4 โ 2s, 5-6 โ 3s, 7+ โ 5s
|
|
323
|
+
attempt += 1
|
|
324
|
+
poll_interval = min(5, (attempt + 1) // 2)
|
|
325
|
+
time.sleep(poll_interval)
|
|
326
|
+
|
|
327
|
+
def getBalance(self) -> float:
|
|
328
|
+
"""Get account balance.
|
|
329
|
+
|
|
330
|
+
Returns:
|
|
331
|
+
Account balance as float
|
|
332
|
+
|
|
333
|
+
Raises:
|
|
334
|
+
AuthenticationError: Invalid API key
|
|
335
|
+
|
|
336
|
+
Example:
|
|
337
|
+
>>> balance = client.getBalance()
|
|
338
|
+
>>> print(f"Balance: ${balance:.4f}")
|
|
339
|
+
"""
|
|
340
|
+
payload = {
|
|
341
|
+
"clientKey": self.api_key,
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
response = self._make_request("/getBalance", payload)
|
|
345
|
+
self._handle_error_response(response)
|
|
346
|
+
|
|
347
|
+
return float(response["balance"])
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Exception classes for CapBypass SDK."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class CapBypassError(Exception):
|
|
5
|
+
"""Base exception for all CapBypass errors.
|
|
6
|
+
|
|
7
|
+
Attributes:
|
|
8
|
+
error_code: Capsolver-compatible error code (e.g., "ERROR_KEY_DOES_NOT_EXIST")
|
|
9
|
+
error_description: Human-readable error message
|
|
10
|
+
error_id: Numeric error ID from API response
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, error_code: str = None, error_description: str = None, error_id: int = None):
|
|
14
|
+
self.error_code = error_code
|
|
15
|
+
self.error_description = error_description or str(error_code)
|
|
16
|
+
self.error_id = error_id
|
|
17
|
+
super().__init__(self.error_description)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class AuthenticationError(CapBypassError):
|
|
21
|
+
"""Raised when API key is invalid or missing."""
|
|
22
|
+
pass
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class InsufficientBalanceError(CapBypassError):
|
|
26
|
+
"""Raised when account balance is zero or insufficient."""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ValidationError(CapBypassError):
|
|
31
|
+
"""Raised when task data is invalid."""
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class TaskNotFoundError(CapBypassError):
|
|
36
|
+
"""Raised when task ID does not exist."""
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SolverError(CapBypassError):
|
|
41
|
+
"""Raised when CAPTCHA cannot be solved."""
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class TimeoutError(CapBypassError):
|
|
46
|
+
"""Raised when solve() exceeds timeout."""
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class InternalError(CapBypassError):
|
|
51
|
+
"""Raised when server encounters an internal error."""
|
|
52
|
+
pass
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# HTTP-layer errors
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class NetworkError(CapBypassError):
|
|
59
|
+
"""Raised when network connection fails (DNS, refused, timeout)."""
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class GatewayError(CapBypassError):
|
|
64
|
+
"""Raised when gateway returns 502/503/504 (retryable)."""
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class ServerError(CapBypassError):
|
|
69
|
+
"""Raised when server returns 500 error."""
|
|
70
|
+
pass
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class RateLimitError(CapBypassError):
|
|
74
|
+
"""Raised when request is rate-limited (429)."""
|
|
75
|
+
pass
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class ParseError(CapBypassError):
|
|
79
|
+
"""Raised when response JSON is malformed."""
|
|
80
|
+
pass
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Task type definitions for CapBypass API."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class TaskType:
|
|
5
|
+
"""Supported CAPTCHA task types.
|
|
6
|
+
|
|
7
|
+
Use these constants when creating tasks to ensure correct type strings.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
# AWS WAF tasks
|
|
11
|
+
ANTI_AWS_WAF_TASK = "AntiAwsWafTask"
|
|
12
|
+
ANTI_AWS_WAF_TASK_PROXYLESS = "AntiAwsWafTaskProxyLess"
|
|
13
|
+
|
|
14
|
+
# reCAPTCHA v2 tasks
|
|
15
|
+
RECAPTCHA_V2_TASK = "ReCaptchaV2Task"
|
|
16
|
+
RECAPTCHA_V2_TASK_PROXYLESS = "ReCaptchaV2TaskProxyLess"
|
|
17
|
+
|
|
18
|
+
# reCAPTCHA v3 tasks
|
|
19
|
+
RECAPTCHA_V3_TASK = "ReCaptchaV3Task"
|
|
20
|
+
RECAPTCHA_V3_TASK_PROXYLESS = "ReCaptchaV3TaskProxyLess"
|
|
21
|
+
|
|
22
|
+
# reCAPTCHA v3 Enterprise tasks
|
|
23
|
+
RECAPTCHA_V3_ENTERPRISE_TASK = "ReCaptchaV3EnterpriseTask"
|
|
24
|
+
RECAPTCHA_V3_ENTERPRISE_TASK_PROXYLESS = "ReCaptchaV3EnterpriseTaskProxyLess"
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: capbypass-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for CapBypass CAPTCHA solving API
|
|
5
|
+
Author-email: CapBypass Development <dev@capbypass.dev>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://capbypass.dev
|
|
8
|
+
Project-URL: Documentation, https://capbypass.dev/docs/sdks/python
|
|
9
|
+
Project-URL: Repository, https://github.com/CapBypass-Development/capbypass-sdk-python
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/CapBypass-Development/capbypass-sdk-python/issues
|
|
11
|
+
Keywords: captcha,recaptcha,aws-waf,automation,solver
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
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: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests>=2.31.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-mock>=3.11.0; extra == "dev"
|
|
30
|
+
Requires-Dist: responses>=0.23.0; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
32
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
33
|
+
Requires-Dist: types-requests>=2.31.0; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# CapBypass Python SDK
|
|
37
|
+
|
|
38
|
+
[](https://pypi.org/project/capbypass-sdk/)
|
|
39
|
+
[](https://pypi.org/project/capbypass-sdk/)
|
|
40
|
+
[](https://pepy.tech/project/capbypass-sdk)
|
|
41
|
+
[](https://github.com/CapBypass-Development/capbypass-sdk-python)
|
|
42
|
+
|
|
43
|
+
Official Python SDK for CapBypass CAPTCHA solving API.
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- โจ Simple `solve()` method with auto-polling
|
|
48
|
+
- ๐ฏ Advanced `createTask()` + `getTaskResult()` for granular control
|
|
49
|
+
- ๐ฐ `getBalance()` to check account balance
|
|
50
|
+
- ๐ Automatic retry logic for network failures
|
|
51
|
+
- ๐ก๏ธ Comprehensive error handling
|
|
52
|
+
- ๐ Type hints for better IDE support
|
|
53
|
+
- ๐งช 100% test coverage
|
|
54
|
+
|
|
55
|
+
## Supported CAPTCHA Types
|
|
56
|
+
|
|
57
|
+
- reCAPTCHA v2 (normal & invisible)
|
|
58
|
+
- reCAPTCHA v3
|
|
59
|
+
- reCAPTCHA v3 Enterprise
|
|
60
|
+
- AWS WAF CAPTCHA
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pip install capbypass-sdk
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Quick Start
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from capbypass import CapBypass
|
|
72
|
+
|
|
73
|
+
# Initialize client
|
|
74
|
+
client = CapBypass(api_key="your-api-key")
|
|
75
|
+
# Or use environment variable: export CAPBYPASS_API_KEY="your-key"
|
|
76
|
+
|
|
77
|
+
# Solve CAPTCHA (auto-polling)
|
|
78
|
+
solution = client.solve({
|
|
79
|
+
"type": "ReCaptchaV2TaskProxyLess",
|
|
80
|
+
"websiteURL": "https://example.com",
|
|
81
|
+
"websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-"
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
print(solution["gRecaptchaResponse"])
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Advanced Usage
|
|
88
|
+
|
|
89
|
+
### Granular Control
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
# Create task
|
|
93
|
+
task_id = client.createTask({
|
|
94
|
+
"type": "ReCaptchaV2TaskProxyLess",
|
|
95
|
+
"websiteURL": "https://example.com",
|
|
96
|
+
"websiteKey": "site-key"
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
# Poll for result
|
|
100
|
+
import time
|
|
101
|
+
while True:
|
|
102
|
+
result = client.getTaskResult(task_id)
|
|
103
|
+
if result["status"] == "ready":
|
|
104
|
+
print(result["solution"])
|
|
105
|
+
break
|
|
106
|
+
time.sleep(5)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Check Balance
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
balance = client.getBalance()
|
|
113
|
+
print(f"Balance: ${balance:.4f}")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Error Handling
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from capbypass import CapBypass
|
|
120
|
+
from capbypass.errors import (
|
|
121
|
+
AuthenticationError,
|
|
122
|
+
InsufficientBalanceError,
|
|
123
|
+
TimeoutError,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
solution = client.solve(task)
|
|
128
|
+
except AuthenticationError:
|
|
129
|
+
print("Invalid API key")
|
|
130
|
+
except InsufficientBalanceError:
|
|
131
|
+
print("Insufficient balance")
|
|
132
|
+
except TimeoutError:
|
|
133
|
+
print("Task timed out")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Documentation
|
|
137
|
+
|
|
138
|
+
Full documentation: https://capbypass.dev/docs/sdks/python
|
|
139
|
+
|
|
140
|
+
## Examples
|
|
141
|
+
|
|
142
|
+
See [examples/](examples/) directory for complete examples:
|
|
143
|
+
|
|
144
|
+
- [recaptcha_v2.py](examples/recaptcha_v2.py) - reCAPTCHA v2 solving
|
|
145
|
+
- [recaptcha_v3.py](examples/recaptcha_v3.py) - reCAPTCHA v3 solving
|
|
146
|
+
- [aws_waf.py](examples/aws_waf.py) - AWS WAF CAPTCHA solving
|
|
147
|
+
|
|
148
|
+
## Development
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Install dev dependencies
|
|
152
|
+
pip install -e ".[dev]"
|
|
153
|
+
|
|
154
|
+
# Run tests
|
|
155
|
+
pytest
|
|
156
|
+
|
|
157
|
+
# Run linter
|
|
158
|
+
ruff check .
|
|
159
|
+
|
|
160
|
+
# Run type checker
|
|
161
|
+
mypy src/
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
MIT
|
|
167
|
+
|
|
168
|
+
## Support
|
|
169
|
+
|
|
170
|
+
- Documentation: https://capbypass.dev/docs
|
|
171
|
+
- Issues: https://github.com/CapBypass-Development/capbypass-sdk-python/issues
|
|
172
|
+
- Email: support@capbypass.dev
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/capbypass/__init__.py
|
|
5
|
+
src/capbypass/client.py
|
|
6
|
+
src/capbypass/errors.py
|
|
7
|
+
src/capbypass/types.py
|
|
8
|
+
src/capbypass_sdk.egg-info/PKG-INFO
|
|
9
|
+
src/capbypass_sdk.egg-info/SOURCES.txt
|
|
10
|
+
src/capbypass_sdk.egg-info/dependency_links.txt
|
|
11
|
+
src/capbypass_sdk.egg-info/requires.txt
|
|
12
|
+
src/capbypass_sdk.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
capbypass
|