Skip to main content

yescaptcha-client

PyPI version Python versions License: ISC

Modern, typed Python client for the YesCaptcha Recognition API. Supports reCAPTCHA (v2/v3/Enterprise), hCaptcha, Cloudflare Turnstile, FunCaptcha, AWS WAF, and image captchas. Built on HTTPX.

Official API documentation: https://docs.yescaptcha.com


Features

  • 🧩 Multi-Captcha Support — Solves reCAPTCHA v2/v3/Enterprise, hCaptcha, Turnstile, FunCaptcha, AWS WAF, and ImageToText.
  • ⏳ Automated Polling — Built-in wait_for_result() and high-level solve() handle polling and timeouts seamlessly.
  • 💰 Balance Tracking — Check main balance, software points, and invite rewards via get_balance().
  • 🐍 Modern Python — Fully type-annotated, Google-style docstrings, context manager support (with YesCaptcha(...) as client:).
  • 🚨 Structured Errors — Clear YesCaptchaError exceptions with API error codes (ERROR_ZERO_BALANCE, ERROR_KEY_DOES_NOT_EXIST).

Installation

pip install yescaptcha-client

Requires Python 3.10 or higher.


Quick Start (Safe Check)

The quick check only inspects your account balance. It does not submit tasks or spend credits.

import os
from yescaptcha import YesCaptcha

client_key = os.environ["YESCAPTCHA_CLIENT_KEY"]

with YesCaptcha(client_key) as client:
    balance = client.get_balance()
    print(f"Balance: {balance['balance']} points")

Usage Guide

client.solve() submits the task and waits until the solution is ready:

import os
from yescaptcha import YesCaptcha

with YesCaptcha(os.environ["YESCAPTCHA_CLIENT_KEY"]) as client:
    # Solve Cloudflare Turnstile
    solution = client.solve({
        "type": "TurnstileTaskProxyless",
        "websiteURL": "https://example.com/",
        "websiteKey": "0x4AAAAAAAx...",
    })
    print("Turnstile Token:", solution["token"])

2. Solving reCAPTCHA v2

with YesCaptcha(os.environ["YESCAPTCHA_CLIENT_KEY"]) as client:
    solution = client.solve({
        "type": "NoCaptchaTaskProxyless",
        "websiteURL": "https://google.com/recaptcha/api2/demo",
        "websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
    })
    print("gRecaptchaResponse:", solution["gRecaptchaResponse"])

3. Manual Task Lifecycle

with YesCaptcha(os.environ["YESCAPTCHA_CLIENT_KEY"]) as client:
    # 1. Submit task
    task_id = client.create_task({
        "type": "TurnstileTaskProxyless",
        "websiteURL": "https://example.com/",
        "websiteKey": "0x4AAAAAAAx...",
    })
    print("Task ID:", task_id)

    # 2. Check result manually
    result = client.get_task_result(task_id)
    if result["status"] == "ready":
        print("Solution:", result["solution"])
    else:
        print("Task is still processing...")

Error Handling

When the API returns an error, the client raises a YesCaptchaError:

from yescaptcha import YesCaptcha, YesCaptchaError

try:
    with YesCaptcha("invalid_key") as client:
        client.get_balance()
except YesCaptchaError as err:
    print(f"YesCaptcha error #{err.error_id} [{err.error_code}]: {err.message}")

Common error codes:

  • ERROR_KEY_DOES_NOT_EXIST — Account key does not exist.
  • ERROR_ZERO_BALANCE — Account has 0 points remaining.
  • ERROR_NO_SLOT_AVAILABLE — Concurrency limit exceeded.
  • TIMEOUT — Polling in wait_for_result() exceeded the timeout duration.

License

ISC © api-kit contributors

Metadata

Release files for yescaptcha-client 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yescaptcha-client 0.1.0
File Size Uploaded Provenance
yescaptcha_client-0.1.0.tar.gz 72.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for yescaptcha-client 0.1.0
File Interpreter ABI Platform
yescaptcha_client-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 79.2 kB

Release files / yescaptcha_client-0.1.0.tar.gz

Download URL yescaptcha_client-0.1.0.tar.gz
Size 72.2 kB
Tags Source
SHA-256 checksum
How to use checksums
edd4d87bafb01f9bafa37edd72e30247468caaa2f69347f5c462a898a5f3130c
BLAKE2b-256 checksum
How to use checksums
9a138fb1da223ade6b78f5c8f1cc6d4db646824c70e1538d35647ee52777cbba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / yescaptcha_client-0.1.0-py3-none-any.whl

Download URL yescaptcha_client-0.1.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0aa412abe7a4d21527608e0110cef5866af77b56e67a2c910d8c28ba8febb1a6
BLAKE2b-256 checksum
How to use checksums
78e9b07df271617eee8a0a2547444212c2c27bd530cfc30c5365c34a58684f9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for yescaptcha-client 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page