Examples

September 6, 2026 · View on GitHub

Runnable scripts for the unicaptcha library, one per use case, in blocking (sync/) and asyncio-native (async/) flavors.

Policy

The examples demonstrate the 2Captcha provider. Anti-Captcha, CapMonster Cloud, and Capsolver work exactly the same way: swap TwoCaptchaClient for AntiCaptchaClient, CapMonsterClient, or CapsolverClient (or their async twins) and adjust per-provider extras. Per-kind extras for each provider are documented in the challenge-class docstrings and in spec/docs/architecture.md §2 of the repository.

Running

Every script needs a real API key and solves real captchas (credits are deducted):

export UNICAPTCHA_TWOCAPTCHA_API_KEY=your_api_key
python examples/sync/recaptcha_v2.py
python examples/async/turnstile.py

Without the key a script prints how to set it and exits non-zero — nothing is submitted. Demo sitekeys are public 2Captcha demo pages (plus official hCaptcha/Arkose test keys), so the scripts run as-is once the key is set.

Illustrative examples: geetest_v3.py and funcaptcha.py are illustrative — the GeeTest v3 demo challenge is single-use and Arkose's public demo blob is not worker-solvable, so those solves are expected to end in NoSolutionError.

Index

File (sync/ + async/)Shows
universal_client.pySolver/AsyncSolver multi-adapter dispatch + capability introspection
auto_solve.pydetect + auto-solve a page's captcha (AutoSolveResult / fill)
image.pyimage captcha from bytes (uses images/captcha.png)
text.pytext question captcha
recaptcha_v2.pyreCAPTCHA v2 token
recaptcha_v3.pyreCAPTCHA v3 token with action/min_score
hcaptcha.pyhCaptcha token
funcaptcha.pyFunCaptcha/Arkose token
geetest_v3.pyGeeTest v3 challenge/validate/seccode
geetest_v4.pyGeeTest v4 (captcha_id)
turnstile.pyCloudflare Turnstile token
two_phase.pysubmit()/wait() batch with TaskTicket
aux_ops.pybalance, task status, good/bad reports
events.pyon_event task-lifecycle stream
errors.pyexception handling and ErrorKind
proxy.pyproxy on a challenge