Skip to main content

Reusable captcha router with pluggable solver providers.

Project description

captcha-router

Reusable captcha router with pluggable providers.

Install

pip install .

Publish automation (GitHub Actions)

  1. Configure Trusted Publishers in PyPI:
  • Production: workflow /.github/workflows/publish.yml, environment pypi
  • Test: workflow /.github/workflows/publish-testpypi.yml, environment testpypi
  1. Bump version in pyproject.toml and commit.
  2. For TestPyPI (release candidate), tag with -rc:
git tag v0.1.1-rc1
git push origin v0.1.1-rc1
  1. For production PyPI, push a stable tag:
git tag v0.1.1
git push origin v0.1.1

Optional: publish on version change

The workflow /.github/workflows/publish-on-version-change.yml is manual-only by default.

  1. Open GitHub Actions and run Publish on Version Change (Optional).
  2. Choose target: testpypi or pypi.

If you want auto-publish on main when pyproject.toml changes, uncomment the push trigger block in that workflow file.

Supported providers

  • anticaptcha (alias: anti-captcha)
  • 2captcha (alias: twocaptcha)

Router methods

  • CaptchaRouter.list_providers(): returns all registered provider names and aliases.
  • CaptchaRouter.list_provider_capabilities(include_aliases=False): returns provider -> supported captcha kinds.
  • CaptchaRouter.get_supported_task_kinds(provider_name): returns supported captcha kinds for one provider.
  • CaptchaRouter.list_supported_task_kinds(): returns union of captcha kinds across providers.
  • CaptchaRouter.get_solver(provider_name=None, api_key=None, **kwargs): creates a solver instance and uses env fallbacks when api_key is omitted.

Usage

1) Create a solver

from captcha_router import CaptchaRouter

solver = CaptchaRouter.get_solver(provider_name="anticaptcha", api_key="YOUR_KEY")

2) Solve a task

import asyncio
from captcha_router import CaptchaRouter, CaptchaTaskSpec


async def main():
    solver = CaptchaRouter.get_solver(provider_name="anticaptcha", api_key="YOUR_KEY")
    try:
        result = await solver.solve_task(
            CaptchaTaskSpec(
                kind="recaptcha_v2",
                params={
                    "website_url": "https://example.com",
                    "site_key": "SITE_KEY_HERE",
                },
            )
        )
        print(result.status, result.token, result.error)
    finally:
        await solver.close()


asyncio.run(main())

3) Inspect capabilities

from captcha_router import CaptchaRouter

print(CaptchaRouter.list_providers())
print(CaptchaRouter.list_provider_capabilities())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

captcha_router-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

captcha_router-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file captcha_router-0.1.0.tar.gz.

File metadata

  • Download URL: captcha_router-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for captcha_router-0.1.0.tar.gz
Algorithm Hash digest
SHA256 27d3536293e33f862ccf5b43a3a0c40f34e605d34dfb0304875d46c77dd96f45
MD5 29bdda28bc774303783f788e6fd2efcc
BLAKE2b-256 3edff39f64dda241218e6cfc71b44f063ce9e002af4009b813d286a19d6da95d

See more details on using hashes here.

File details

Details for the file captcha_router-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: captcha_router-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for captcha_router-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ade70b712ddb27af870408820e96c08874f51c31f42b96eb30fb58dcf261911
MD5 e929d9e378a4fb503a0c72bd3d933f36
BLAKE2b-256 903d2a738ba724886140ca0b85b9853f568a2189dd17309fd009fd7db08e2315

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page