Skip to content

Commit b81ffb4

Browse files
author
nextcaptcha
committed
python sdk upload
0 parents  commit b81ffb4

File tree

8 files changed

+642
-0
lines changed

8 files changed

+642
-0
lines changed

.github/workflows/publish-to-pypi.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to PyPI
2+
on: push
3+
jobs:
4+
build-n-publish:
5+
name: Build and publish to PyPI
6+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@master
10+
- name: Set up Python 3.10
11+
uses: actions/setup-python@v3
12+
with:
13+
python-version: "3.10"
14+
- name: Install pypa/build
15+
run: >-
16+
python -m
17+
pip install
18+
build
19+
--user
20+
- name: Build a binary wheel and a source tarball
21+
run: >-
22+
python -m
23+
build
24+
--sdist
25+
--wheel
26+
--outdir dist/
27+
.
28+
- name: Publish to Test PyPI
29+
continue-on-error: true
30+
uses: pypa/gh-action-pypi-publish@release/v1
31+
with:
32+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
33+
repository_url: https://test.pypi.org/legacy/
34+
- name: Publish to PyPI
35+
if: startsWith(github.ref, 'refs/tags')
36+
uses: pypa/gh-action-pypi-publish@release/v1
37+
with:
38+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
.idea/

LICENSE

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The MIT License (MIT)
2+
Copyright © 2024 NextCaptcha, https://nextcaptcha.com <[email protected]>
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# NextCaptcha Python SDK
2+
NextCaptcha is a powerful captcha solving service that supports various types of captchas including reCAPTCHA v2,
3+
reCAPTCHA v2 Enterprise, reCAPTCHA v3, reCAPTCHA Mobile, hCaptcha, and FunCaptcha. With NextCaptcha, you can easily
4+
solve a variety of captcha challenges in your automation scripts and programs.
5+
6+
This SDK provides a simple and easy-to-use Python interface for interacting with the NextCaptcha API. It supports all
7+
available captcha types and offers intuitive methods for solving different types of captchas.
8+
9+
## Installation
10+
11+
You can install the NextCaptcha Python SDK using pip:
12+
13+
```shell
14+
pip install nextcaptcha-python
15+
```
16+
17+
## Usage
18+
19+
To start using the NextCaptcha Python SDK, you first need to obtain your API key (clientKey) from the (
20+
NextCaptcha)[https://dashboard.nextcaptcha.com] Dashboard. Then, you can create a NextCaptchaAPI instance:
21+
22+
```python
23+
from nextcaptcha import NextCaptchaAPI
24+
25+
api = NextCaptchaAPI(client_key="YOUR_CLIENT_KEY")
26+
```
27+
28+
Now, you can use the api object to solve various types of captchas.
29+
To solve reCAPTCHA v2 challenges, use the recaptchav2 method:
30+
31+
```python
32+
result = api.recaptchav2(website_url="https://example.com", website_key="SITE_KEY")
33+
```
34+
35+
Solving reCAPTCHA v2 Enterprise
36+
To solve reCAPTCHA v2 Enterprise challenges, use the recaptchav2enterprise method:
37+
38+
```python
39+
result = api.recaptchav2enterprise(website_url="https://example.com", website_key="SITE_KEY")
40+
```
41+
42+
Solving reCAPTCHA v3
43+
To solve reCAPTCHA v3 challenges, use the recaptchav3 method:
44+
45+
```python
46+
result = api.recaptchav3(website_url="https://example.com", website_key="SITE_KEY")
47+
```
48+
49+
Solving reCAPTCHA Mobile
50+
To solve reCAPTCHA Mobile challenges, use the recaptcha_mobile method:
51+
52+
```python
53+
result = api.recaptcha_mobile(app_key="APP_KEY")
54+
```
55+
56+
Solving hCaptcha
57+
To solve hCaptcha challenges, use the hcaptcha method:
58+
59+
```python
60+
result = api.hcaptcha(website_url="https://example.com", website_key="SITE_KEY")
61+
```
62+
63+
Solving hCaptcha Enterprise
64+
To solve hCaptcha Enterprise challenges, use the hcaptcha_enterprise method:
65+
66+
```python
67+
result = api.hcaptcha_enterprise(website_url="https://example.com", website_key="SITE_KEY")
68+
```
69+
70+
Solving FunCaptcha
71+
To solve FunCaptcha challenges, use the funcaptcha method:
72+
73+
```python
74+
result = api.funcaptcha(website_public_key="WEBSITE_PUBLIC_KEY")
75+
```
76+
77+
Checking Account Balance
78+
To check your NextCaptcha account balance, use the get_balance method:
79+
80+
```python
81+
balance = api.get_balance()
82+
print(f"Account balance: {balance}")
83+
```
84+
85+
Here is a complete example of using the NextCaptcha Python SDK to solve a reCAPTCHA v2 challenge:
86+
87+
```python
88+
from nextcaptcha import NextCaptchaAPI
89+
90+
CLIENT_KEY = "YOUR_CLIENT_KEY"
91+
WEBSITE_URL = "https://example.com"
92+
WEBSITE_KEY = "SITE_KEY"
93+
94+
api = NextCaptchaAPI(client_key=CLIENT_KEY)
95+
result = api.recaptchav2(website_url=WEBSITE_URL, website_key=WEBSITE_KEY)
96+
97+
if result["status"] == "ready":
98+
print(f"reCAPTCHA solved: {result['solution']}")
99+
else:
100+
print(f"Failed to solve reCAPTCHA: {result['error']}")
101+
```
102+
103+
## Error Handling
104+
105+
If an error occurs while solving a captcha, the SDK will return a dictionary containing the error information. You can
106+
check the status field to determine if the request was successful. If the status is "ready", the captcha has been
107+
successfully solved and the solution will be provided in the solution field. If the status is "failed", the error field
108+
will contain a description of the error.
109+
110+
## Contributing
111+
112+
If you find any bugs or have suggestions for improvement, please feel free to submit an issue or send a pull request. We
113+
welcome all contributions!
114+
115+
## License
116+
117+
This project is licensed under the MIT License. For more information, please see the LICENSE file.
118+
119+

nextcaptcha/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
from .next import NextCaptchaAPI
3+
4+
5+
6+
__version__ = '1.0.0'

0 commit comments

Comments
 (0)