Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cdfad79
[github-actions] Bump actions/checkout from 4 to 5
dependabot[bot] Aug 12, 2025
47ee207
Merge pull request #153 from AndreiDrang/dependabot/github_actions/ac…
AndreiDrang Aug 13, 2025
58a7a93
[github-actions] Bump actions/setup-python from 5 to 6
dependabot[bot] Sep 4, 2025
5ea3a75
Merge pull request #154 from AndreiDrang/dependabot/github_actions/ac…
AndreiDrang Sep 5, 2025
f22e87e
Bump black from 25.1.0 to 25.9.0
dependabot[bot] Sep 22, 2025
e92c074
Merge pull request #155 from AndreiDrang/dependabot/pip/black-25.9.0
AndreiDrang Sep 24, 2025
9179c90
Bump black from 25.9.0 to 25.11.0
dependabot[bot] Nov 10, 2025
b6b9cae
[github-actions] Bump actions/checkout from 5 to 6
dependabot[bot] Nov 20, 2025
0c45757
Merge pull request #157 from AndreiDrang/dependabot/github_actions/ac…
AndreiDrang Nov 20, 2025
4282fd1
Merge pull request #156 from AndreiDrang/dependabot/pip/black-25.11.0
AndreiDrang Nov 20, 2025
1fc2f75
Update msgspec requirement from <0.20,>=0.18 to >=0.18,<0.21
dependabot[bot] Nov 24, 2025
9091605
Merge pull request #158 from AndreiDrang/dependabot/pip/msgspec-gte-0…
AndreiDrang Nov 25, 2025
820b1e2
Update isort requirement from ==6.* to ==7.*
dependabot[bot] Jan 5, 2026
24b6fb2
Bump black from 25.11.0 to 25.12.0
dependabot[bot] Jan 5, 2026
ef637fa
Bump sphinx from 8.2.3 to 9.1.0
dependabot[bot] Jan 5, 2026
235e22c
Update pytest requirement from ==8.* to ==9.*
dependabot[bot] Jan 5, 2026
f24815f
Merge pull request #159 from AndreiDrang/dependabot/pip/isort-eq-7.star
AndreiDrang Jan 13, 2026
3f728a7
Merge branch 'main' into dependabot/pip/black-25.12.0
AndreiDrang Jan 13, 2026
7d13520
Merge pull request #160 from AndreiDrang/dependabot/pip/black-25.12.0
AndreiDrang Jan 13, 2026
44ab740
Merge pull request #161 from AndreiDrang/dependabot/pip/sphinx-9.1.0
AndreiDrang Jan 13, 2026
20c7289
Merge pull request #162 from AndreiDrang/dependabot/pip/pytest-eq-9.star
AndreiDrang Jan 13, 2026
d047956
Create AGENTS.md
AndreiDrang Jan 13, 2026
4743d36
Update pyproject.toml
AndreiDrang Jan 13, 2026
684c702
Create AGENTS.md
AndreiDrang Jan 13, 2026
4c09799
Create AGENTS.md
AndreiDrang Jan 13, 2026
d07c421
Create AGENTS.md
AndreiDrang Jan 13, 2026
9428cb1
Update Makefile
AndreiDrang Jan 13, 2026
5cc21f8
1.1.1
AndreiDrang Jan 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: 3.11.6

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: 3.11.6

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
python-version: ["3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

Expand Down
41 changes: 41 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# PROJECT KNOWLEDGE BASE

**Generated:** 2026-01-13

## OVERVIEW
Python 3.8+ library for Capsolver service API. Supports both synchronous (`requests`) and asynchronous (`aiohttp`) operations. Uses `msgspec` for high-performance JSON serialization.

## STRUCTURE
```
./
├── src/python3_capsolver/ # Main library package
│ ├── core/ # Base classes, serializers, instruments
│ └── *.py # Service-specific implementations (ReCaptcha, Cloudflare, etc.)
├── tests/ # Pytest suite
└── docs/ # Sphinx documentation
```

## WHERE TO LOOK
| Task | Location | Notes |
|------|----------|-------|
| **Base Logic** | `src/python3_capsolver/core/` | `base.py`, `serializer.py`, `enum.py` |
| **Service Implementations** | `src/python3_capsolver/*.py` | `recaptcha.py`, `cloudflare.py`, etc. |
| **Tests** | `tests/` | Matches source structure |
| **Configuration** | `pyproject.toml` | Build, dependency, tool config |

## CONVENTIONS
- **Formatter**: `black` (line-length 120), `isort` (profile "black").
- **Serialization**: `msgspec` preferred over `json` for performance.
- **Concurrency**: Dual support (Sync/Async) required for all instruments.
- **Retries**: `tenacity` library used for resilience.

## COMMANDS
```bash
make tests # Run test suite
pip install . # Install package locally
```

## NOTES
- Dependencies: `requests`, `aiohttp`, `msgspec`, `tenacity`.
- Requires `API_KEY` in environment for tests.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: install remove refactor lint build upload tests doc

install:
pip3 install -e .

Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
sphinx==8.2.3
sphinx==9.1.0
pallets_sphinx_themes==2.3.0
myst-parser==4.0.1
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ classifiers = [
dependencies = [
"requests>=2.21.0",
"aiohttp>=3.9.2",
"msgspec>=0.18,<0.20",
"msgspec>=0.18,<=0.21",
"tenacity>=8,<10"
]

Expand Down
4 changes: 2 additions & 2 deletions requirements.style.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# codestyle
isort==6.*
black==25.1.0
isort==7.*
black==25.12.0
autoflake==2.*
2 changes: 1 addition & 1 deletion requirements.test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pytest==8.*
pytest==9.*
coverage==7.*
pytest-asyncio==1.*
43 changes: 43 additions & 0 deletions src/python3_capsolver/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# PYTHON3_CAPSOLVER PACKAGE

**Generated:** 2026-01-13

## OVERVIEW
Main library package containing service-specific captcha solving implementations. Provides high-level interfaces for various captcha types (ReCaptcha, Cloudflare Turnstile, DataDome, etc.) through a unified API.

Each service class inherits from `core.CaptchaParams` and implements synchronous (`requests`) and asynchronous (`aiohttp`) solving methods with automatic retry logic and response polling.

## STRUCTURE
```
src/python3_capsolver/
├── core/ # Base classes, instruments, serializers
├── control.py # Control class for direct API methods
├── recaptcha.py # ReCaptcha V2/V3/Enterprise implementations
├── cloudflare.py # Cloudflare Turnstile/Challenge solver
├── vision_engine.py # AI-based image recognition
├── image_to_text.py # OCR text extraction
├── datadome_slider.py # DataDome slider captcha
├── mt_captcha.py # MtCaptcha solver
├── gee_test.py # GeeTest solver
├── aws_waf.py # AWS WAF bypass
├── friendly_captcha.py # FriendlyCaptcha solver
└── yandex.py # Yandex captcha solver
```

## WHERE TO LOOK
| Task | Location | Notes |
|------|----------|-------|
| **Direct API Access** | `control.py` | `Control.get_balance()`, `create_task()`, `get_task_result()` |
| **ReCaptcha** | `recaptcha.py` | V2, V3, Enterprise variants |
| **Cloudflare** | `cloudflare.py` | Turnstile, Challenge modes |
| **Image-based** | `vision_engine.py`, `image_to_text.py` | AI recognition, OCR |
| **Other Services** | `*.py` | DataDome, GeeTest, AWS WAF, etc. |
| **Base Logic** | `core/` | `CaptchaParams`, instruments, serializers |

## CONVENTIONS
- **Service Pattern**: Each service class inherits from `CaptchaParams` with `api_key` and `captcha_type` params
- **Dual Handlers**: All services provide `captcha_handler()` (sync) and `aio_captcha_handler()` (async)
- **Retry Logic**: Built-in exponential backoff with configurable `sleep_time` (default: 5s)
- **Task Payload**: Passed via `task_payload` dict, merged with internal task params
- **Response Structure**: Returns dict with `errorId`, `taskId`, `status`, `solution` fields
- **Context Managers**: Support `with` and `async with` for session cleanup
2 changes: 1 addition & 1 deletion src/python3_capsolver/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.1.0"
__version__ = "1.1.1"
40 changes: 40 additions & 0 deletions src/python3_capsolver/core/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# CORE MODULE

**Generated:** 2026-01-13

## OVERVIEW
Core module provides foundational classes for synchronous (`requests`) and asynchronous (`aiohttp`) captcha solving operations.

Base classes establish patterns for Sync/Async instruments, enabling dual concurrency support across the library. Serialization leverages `msgspec` for high-performance JSON handling.

## STRUCTURE
```
src/python3_capsolver/core/
├── base.py # CaptchaParams entry class (Sync/Async handlers)
├── captcha_instrument.py # CaptchaInstrumentBase, FileInstrument
├── aio_captcha_instrument.py # AIOCaptchaInstrument (async implementation)
├── sio_captcha_instrument.py # SIOCaptchaInstrument (sync implementation)
├── serializer.py # Request/Response msgspec Struct classes
├── enum.py # EndpointPostfixEnm, CaptchaTypeEnm, ResponseStatusEnm
├── const.py # API URLs, retry configurations
└── utils.py # Utility functions (attempts_generator)
```

## WHERE TO LOOK
| Task | File | Notes |
|------|------|-------|
| **Entry Point** | `base.py` | `CaptchaParams` class with `captcha_handler()` and `aio_captcha_handler()` |
| **Base Classes** | `captcha_instrument.py` | `CaptchaInstrumentBase` for instruments, `FileInstrument` for file processing |
| **Sync Instrument** | `sio_captcha_instrument.py` | `SIOCaptchaInstrument` - requests-based implementation |
| **Async Instrument** | `aio_captcha_instrument.py` | `AIOCaptchaInstrument` - aiohttp-based implementation |
| **Serialization** | `serializer.py` | `PostRequestSer`, `CaptchaResponseSer`, `MyBaseModel.to_dict()` |
| **Enums** | `enum.py` | `CaptchaTypeEnm`, `ResponseStatusEnm`, `EndpointPostfixEnm` |
| **Configuration** | `const.py` | `REQUEST_URL`, `RETRIES`, `VALID_STATUS_CODES` |

## CONVENTIONS
- **Base Classes**: All instruments inherit from `CaptchaInstrumentBase`
- **Dual Support**: Every captcha operation provides both sync and async methods
- **Serialization**: `msgspec.Struct` classes with `to_dict()` method for API payloads
- **Retries**: `tenacity` for async, `requests.Retry` for sync (5 attempts, exponential backoff)
- **File Processing**: `FileInstrument` handles local files, URLs, and base64 in both sync/async contexts
- **Session Management**: Instruments maintain their own HTTP sessions with retry adapters
31 changes: 31 additions & 0 deletions tests/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# TESTS SUITE

## OVERVIEW
Pytest-based test suite validating API integration, dual-mode (sync/async) operations, and error handling for all captcha services.

## STRUCTURE
```
tests/
├── conftest.py # BaseTest class, fixtures, test utilities
├── test_*.py # Test modules (match source structure)
└── files/ # Test assets (e.g., captcha_example.jpeg)
```

## WHERE TO LOOK
| Task | Location | Notes |
|------|----------|-------|
| **Base Test Class** | `tests/conftest.py` | `BaseTest` with utilities (`get_random_string`, `read_image`) |
| **Fixtures** | `tests/conftest.py` | `delay_func` (1s), `delay_class` (2s) for rate limiting |
| **Core Tests** | `tests/test_core.py` | Base logic, retries, enums, context managers |
| **Service Tests** | `tests/test_*.py` | Per-service tests (recaptcha, cloudflare, datadome, etc.) |
| **Instrument Tests** | `tests/test_instrument.py` | File processing, instruments |
| **Pytest Config** | `pyproject.toml` | `asyncio_mode = "auto"`, testpaths |

## CONVENTIONS
- **Framework**: Pytest 7.0+ with `pytest-asyncio` (auto mode).
- **Dual Testing**: Every sync test (`def test_*`) has async counterpart (`async def test_aio_*`).
- **Parametrization**: Use `@pytest.mark.parametrize` for multiple captcha types in single test.
- **Base Class**: All tests inherit from `BaseTest` for common utilities and rate limiting.
- **Context Managers**: Test both `with` and `async with` patterns for resource cleanup.
- **Rate Limiting**: Default delays (1s function, 2s class) to avoid API throttling.
- **Error Testing**: Verify `errorId`, `errorCode`, and `solution=None` for invalid keys.
Loading