Commit 3a7840e
Add async support with AsyncAnticaptchaClient (#131)
* Add async support with AsyncAnticaptchaClient and AsyncJob
Add a new async_client module providing AsyncAnticaptchaClient and AsyncJob
classes that mirror the sync API but use httpx.AsyncClient and asyncio.sleep
for non-blocking operation in async frameworks (FastAPI, aiohttp, etc.).
This is a non-breaking change: the sync API is untouched, httpx remains an
optional dependency (pip install python-anticaptcha[async]), and the new
classes are lazily imported in __init__.py to avoid requiring httpx at
package import time.
https://claude.ai/code/session_01Pimg4VAco2v4srPeZj44Zm
* Extract shared mixins, add documentation and examples for async support
- Extract _BaseClientMixin and _BaseJobMixin into _common.py to share
init logic, payload builders, solution getters, and repr between
sync and async clients
- Refactor AnticaptchaClient and AsyncAnticaptchaClient to inherit
from shared mixins, reducing maintenance burden
- Add "Async Usage" section to README.md and docs/usage.rst
- Add async_client automodule to docs/api.rst
- Add CHANGELOG.rst entries for async support
- Add async example scripts (async_recaptcha_request.py, async_balance.py)
- Add "Framework :: AsyncIO" and "Topic :: Internet :: WWW/HTTP" classifiers
- Add "asyncio", "async", "httpx" keywords for PyPI discoverability
https://claude.ai/code/session_01Pimg4VAco2v4srPeZj44Zm
* Balance sync and async as equal first-class citizens
- Rename base.py → sync_client.py for symmetry with async_client.py;
add backward-compat base.py re-export shim
- Rename all sync example files with sync_ prefix to match async_ examples
- Rename test_base.py → test_sync_client.py
- Promote "Async Usage" to same heading level as sync in README and docs
- Add "Sync client" heading in docs/usage.rst for symmetry
- Rename "Base" → "Sync Client" in docs/api.rst
- Update __init__.py to import from sync_client instead of base
- All existing import paths preserved for backward compatibility
https://claude.ai/code/session_01Pimg4VAco2v4srPeZj44Zm
* Defer httpx ImportError to instantiation time for Sphinx compatibility
The module-level ImportError prevented Sphinx autodoc from importing
async_client when httpx is not installed. Now the module imports
successfully (setting httpx=None) and raises ImportError only when
AsyncAnticaptchaClient is instantiated without httpx.
https://claude.ai/code/session_01Pimg4VAco2v4srPeZj44Zm
* Fix CI: linter errors, mypy types, and add httpx to test deps
- Fix ruff import sorting in __init__.py, test_sync_client.py,
test_async_client.py
- Fix ruff-format: async_client.py await parenthesization,
string concatenation
- Fix mypy: add return type to __getattr__, add type:ignore for
optional httpx import
- Add httpx to test dependencies so async tests work in CI
- Remove redundant explicit imports from base.py shim (covered by *)
https://claude.ai/code/session_01Pimg4VAco2v4srPeZj44Zm
* Fix E2E tests: update example imports to use sync_ prefix
The example files were renamed with sync_ prefix but test_examples.py
still imported them by their old names.
https://claude.ai/code/session_01Pimg4VAco2v4srPeZj44Zm
* Remove import aliases in test_examples.py, use sync_ prefixed names directly
https://claude.ai/code/session_01Pimg4VAco2v4srPeZj44Zm
* Add six to test dependencies
Required by funcaptcha and hcaptcha example tests.
https://claude.ai/code/session_01Pimg4VAco2v4srPeZj44Zm
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent f6d348c commit 3a7840e
29 files changed
Lines changed: 982 additions & 310 deletions
File tree
- docs
- examples
- python_anticaptcha
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
| |||
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
45 | 74 | | |
46 | 75 | | |
47 | 76 | | |
| |||
60 | 89 | | |
61 | 90 | | |
62 | 91 | | |
63 | | - | |
| 92 | + | |
64 | 93 | | |
65 | 94 | | |
66 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
| 5 | + | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
24 | 53 | | |
25 | 54 | | |
26 | 55 | | |
| |||
40 | 69 | | |
41 | 70 | | |
42 | 71 | | |
43 | | - | |
| 72 | + | |
44 | 73 | | |
45 | 74 | | |
46 | 75 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
0 commit comments