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 aCaptchaInfo.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
ISC
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file capsolver_core-0.1.0.tar.gz.
File metadata
- Download URL: capsolver_core-0.1.0.tar.gz
- Upload date:
- Size: 29.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b5f3f3e566fbc92a6f7dcdf99222a964903872f4d2fce911a1ba72a5f005ba8
|
|
| MD5 |
515855f75b224b008fe85ca1c0293221
|
|
| BLAKE2b-256 |
02f90de632057e25af62bef3e6b71996595b2c122a5d9dd6b850c5baa9ed82ad
|
File details
Details for the file capsolver_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: capsolver_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcf3dce14d5d7033efbb15d729aab7b57708bad6fd7ce113e94c9c1528cfdb75
|
|
| MD5 |
247793a61c36d5ea83d06d4eb19c402c
|
|
| BLAKE2b-256 |
fe21f2b3ad4c1bd15d111bf82dc39c76df38f7798bf8d5747967c7884f9efee6
|