Skip to main content

capsolver-core

A Python SDK for CapSolver — detect captchas on a page, read their parameters, solve them via the CapSolver API, and write the token back.

Token mode only. This SDK solves captchas by requesting a token from the CapSolver API (reCAPTCHA v2/v3, Cloudflare Turnstile).

Install

pip install capsolver-core

With Playwright support:

pip install capsolver-core[playwright]

Set your API key (or pass api_key= directly to create_capsolver()):

# bash / zsh
export CAPSOLVER_API_KEY="your-capsolver-api-key"

# PowerShell
$env:CAPSOLVER_API_KEY = "your-capsolver-api-key"

# cmd
set CAPSOLVER_API_KEY=your-capsolver-api-key

Two ways to use it

1. Pure API (you already have the sitekey)

No browser needed — give it the captcha parameters, get a token back.

import asyncio
from capsolver_core import create_capsolver, CaptchaType, CaptchaInfo

async def main():
    cap = create_capsolver(api_key="YOUR_API_KEY")

    info = CaptchaInfo(
        type=CaptchaType.RECAPTCHA_V2,
        website_url="https://example.com",
        website_key="6Lc...",
    )
    solution = await cap.solve(info)
    print(solution.token)  # submit this as g-recaptcha-response

asyncio.run(main())

2. Driving a real browser (Playwright)

Detect, read params, solve, and autofill — all from a live page.

import asyncio
from capsolver_core import create_capsolver
from playwright.async_api import async_playwright

async def main():
    cap = create_capsolver(api_key="YOUR_API_KEY")

    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto("https://example.com/login")

        # One-shot: detect every captcha, solve each, write tokens back.
        results = await cap.solve_on_page(page)
        for r in results:
            print(r.info.type, r.solution.token if r.solution else None, r.filled, r.error)

        # …or step by step:
        types = await cap.detect(page)
        infos = await cap.get_captcha_info(page)
        solution = await cap.solve(infos[0])

asyncio.run(main())

CLI

The capsolver command provides quick diagnostics without writing code.

# Show SDK version, Python version, and optional dependency status
capsolver info

# List all supported captcha types and registered handlers
capsolver list-types

# Check account balance (requires CAPSOLVER_API_KEY)
capsolver balance
capsolver balance --api-key YOUR_KEY

Also works via python -m capsolver_core info.

API

create_capsolver(**options) / Capsolver(**options)

Option Default Description
api_key — CapSolver client key (required to solve)
service https://api.capsolver.com API base URL
default_timeout 120 Polling budget, seconds
polling_interval 5 Delay between result polls, seconds
request_timeout_ms 30000 Per-HTTP-request timeout
app_id — Developer/affiliate id
handlers all built-ins Override the registered captcha handlers
source — Traffic source identifier
version — Client version tag
on_error — Callback for non-fatal errors

Resource cleanup

Capsolver holds an internal HTTP connection pool. Use it as an async context manager to ensure connections are released:

async with create_capsolver(api_key="YOUR_API_KEY") as cap:
    solution = await cap.solve(info)

Or call await cap.aclose() explicitly when done.

Methods

  • solve(info, wait_options?) → Solution — solve from a CaptchaInfo.
  • detect(page) → list[CaptchaType] — which captchas are present.
  • get_captcha_info(page) → list[CaptchaInfo] — structured params per widget.
  • solve_on_page(page, options?) → list[SolveOnPageResult] — detect → solve → autofill.
  • get_balance() → BalanceResp — account balance.
  • register(handler) / get_supported_captchas() / get_handler(key) — registry access.

Supported captchas

reCaptchaV2, reCaptchaV3 (incl. enterprise), cloudflare (Turnstile).

Architecture

src/capsolver_core/
  __init__.py   public API surface (all exports)
  __main__.py   CLI entry point (capsolver command)
  core/         pure-Python token solving (http, client, task builders, types)
  captcha/      handler registry + per-captcha handlers (the plugin layer)
  browser/      PageDriver adapter + self-contained in-page inject scripts
  capsolver.py  public Capsolver class

Development

git clone https://github.com/capsolver-ai/capsolver-core.git
cd capsolver-core
uv sync --all-extras          # or: pip install -r requirements-dev.txt
uv run pytest                 # run tests
uv run ruff check src tests   # lint

License

MIT

Metadata

Release files for capsolver-core 0.1.1

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

Source distribution (sdist)

Source distribution for capsolver-core 0.1.1
File Size Uploaded Provenance Actions
capsolver_core-0.1.1.tar.gz 74.6 kB Without provenance Details for capsolver_core-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for capsolver-core 0.1.1
File Interpreter ABI Platform Actions
capsolver_core-0.1.1-py3-none-any.whl Python 3 none any Details for capsolver_core-0.1.1-py3-none-any.whl

Total release size: 103.6 kB

Release files / capsolver_core-0.1.1.tar.gz

Download URL capsolver_core-0.1.1.tar.gz
Size 74.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d1c4cb56f43073262d7d55cc06ec013a1a32072cc9331e36cf079b54fefdfd59
BLAKE2b-256 checksum
How to use checksums
92d15697a98051cc5cf8d4d03e86cdf595e6865c0eafbba46fabf44c51c1d187
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Release files / capsolver_core-0.1.1-py3-none-any.whl

Download URL capsolver_core-0.1.1-py3-none-any.whl
Size 28.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
999fd0deced0c7a5fba82bfd360b26397b6d998004f842d0922f424624d12517
BLAKE2b-256 checksum
How to use checksums
44e70f3cc00e038ac65fcb1bee46af937a800dd8d79ee79aac4155c6be3be4cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.4

Security for capsolver-core 0.1.1

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.1 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