Examples of solving popular captcha types with
@captcha-solver-api/javascript-sdk
and Puppeteer.
Use the examples only on demo pages or websites you are authorized to test.
Important
Live examples create paid CAPTCHA tasks. Run them only with an API key you are authorized to use and against a target you own or have explicit permission to test.
Each browser example shows how to:
- Open a page and collect captcha parameters.
- Send a task to Captcha Solver.
- Apply the solution in the browser.
- Check the strongest acceptance signal exposed by the page and state its exact boundary.
Requirements:
- Node.js 22.12 or newer
- A Captcha Solver API key with a positive balance for live examples
git clone https://github.com/captcha-solver-api/captcha-solver-puppeteer-javascript-examples.git
cd captcha-solver-puppeteer-javascript-examples
npm ci
On macOS and Linux, create the local configuration file with:
cp .env.example .env
On Windows PowerShell:
Copy-Item .env.example .env
Set your API key in .env:
CAPTCHA_API_KEY=your_captcha_solver_api_key
The npm example commands load this file through Node.js --env-file-if-exists=.env; using
process.env in source code does not load .env by itself.
npm run recaptcha-v2
npm run recaptcha-v2-callback
npm run recaptcha-v2-callback-auto
npm run recaptcha-v2-proxy
npm run recaptcha-v2-callback-proxy
npm run recaptcha-v2-enterprise
npm run recaptcha-v3
npm run turnstile
npm run turnstile-challenge
npm run yandex
npm run yandex-image
npm run tencent
npm run geetest-v3
npm run geetest-v4
npm run image-to-text
npm run coordinates
npm run balance
Browser examples open Chrome in visible mode. Set HEADLESS=true in .env to run them in the
background. They launch Chrome through puppeteer-extra with puppeteer-extra-plugin-stealth,
which reduces common automation fingerprints. Stealth is not a substitute for permission to
automate a website.
Task examples log the ID returned by the SDK when the task is created, followed by the solver
result. Browser examples then separately verify page acceptance. Receiving a solution from the SDK
proves only that the service completed the task; it does not prove that the target page accepted
the result. When a page exposes only a callback-delivery signal, the example states that narrower
boundary instead of claiming server-side acceptance. Image and balance examples print their
applicable SDK result without inventing a browser acceptance step. The balance example does not
create a task and therefore has no task ID. Image bodies are never printed, and API keys must
remain in .env.
Token injection and submission are site-specific. The included browser code demonstrates one target's flow; for another target, you must inspect the page and determine the correct response field, callback, submission action, and acceptance signal yourself.
Tencent confirms that the intercepted page callback received the same ticket and random string. This proves callback delivery, not server-side acceptance; add a target-specific acceptance check when the page exposes one.
Every example is intentionally self-contained and written as a linear tutorial. Browser examples
show SDK and browser setup, page navigation, parameter collection, task creation, solver.solve(),
solution application, site-specific submission or callback delivery, and the applicable acceptance
check in one file. Image-only, coordinate, and balance examples show their complete SDK flow
without inventing browser steps. Some code is repeated so that an example can be copied without
also copying hidden project helpers.
| Captcha | File | Command |
|---|---|---|
| reCAPTCHA v2 form | recaptcha_v2.js |
npm run recaptcha-v2 |
| reCAPTCHA v2 named callback | recaptcha_v2_callback.js |
npm run recaptcha-v2-callback |
| reCAPTCHA v2 discovered callback | recaptcha_v2_callback_auto.js |
npm run recaptcha-v2-callback-auto |
| reCAPTCHA v2 with proxy | recaptcha_v2_proxy.js |
npm run recaptcha-v2-proxy |
| reCAPTCHA v2 callback + proxy | recaptcha_v2_callback_proxy.js |
npm run recaptcha-v2-callback-proxy |
| reCAPTCHA v2 Enterprise | recaptcha_v2_enterprise.js |
npm run recaptcha-v2-enterprise |
| reCAPTCHA v3 | recaptcha_v3.js |
npm run recaptcha-v3 |
| Cloudflare Turnstile | turnstile.js |
npm run turnstile |
| Cloudflare Challenge | turnstile_challenge.js |
npm run turnstile-challenge |
| Tencent CAPTCHA | tencent.js |
npm run tencent |
| Yandex SmartCaptcha | yandex_smartcaptcha.js |
npm run yandex |
| Yandex image challenge | yandex_smartcaptcha_image.js |
npm run yandex-image |
| GeeTest v3 | geetest_v3.js |
npm run geetest-v3 |
| GeeTest v4 | geetest_v4.js |
npm run geetest-v4 |
| Image-to-text | image_to_text.js |
npm run image-to-text |
| Coordinates | coordinates.js |
npm run coordinates |
| Balance | balance.js |
npm run balance |
The folders group examples by CAPTCHA family. Each file remains standalone and includes its own SDK setup, task creation, solution handling, and applicable result check. Browser examples also include browser setup, solution delivery, and an acceptance or callback-delivery check. SDK-only image, coordinate, and balance examples print the result relevant to their task.
The standard reCAPTCHA v2 form example and Yandex SmartCaptcha example use official provider demos
by default. The named-callback and discovered-callback reCAPTCHA examples require a page that
actually exposes the corresponding callback flow. Set RECAPTCHA_V2_TARGET_URL to a compatible
page you own or are authorized to test; for the named-callback variants, also set
RECAPTCHA_V2_CALLBACK to the page's callback name.
Other browser targets can be configured with RECAPTCHA_ENTERPRISE_TARGET_URL,
RECAPTCHA_V3_TARGET_URL, TURNSTILE_TARGET_URL, TURNSTILE_CHALLENGE_TARGET_URL,
TENCENT_TARGET_URL, YANDEX_TARGET_URL, GEETEST_V3_TARGET_URL, and
GEETEST_V4_TARGET_URL. The example.com/page_with_... values in .env.example are placeholders,
not working CAPTCHA demos. Replace them before running those examples. Changing a URL does not
automatically adapt selectors, callbacks, submission, or acceptance checks to a different page.
For Tencent, set TENCENT_SCRIPT_URL only when the example cannot capture the script URL from the
page.
The two proxy examples require PROXY_ADDRESS and PROXY_PORT. PROXY_TYPE defaults to http;
set PROXY_LOGIN and PROXY_PASSWORD when the proxy requires authentication:
PROXY_TYPE=http
PROXY_ADDRESS=127.0.0.1
PROXY_PORT=8080
PROXY_LOGIN=
PROXY_PASSWORD=
Both proxy examples send the same proxy settings to Chromium and Tasks.RecaptchaV2 so the
browser and solver present the same network identity.
Important
CAPTCHA-solving tasks are paid API operations. Local checks use fixtures and do not call the paid service. Run live tests only with explicit authorization.
npm run lint
npm run format:check
npm run check
npm test
npm run check runs linting, formatting, syntax and workflow-guide validation, and the complete
local regression suite. These checks use local fixtures and do not create paid tasks.
npm start runs the Turnstile Challenge example. To run one explicitly authorized live attempt,
pass an example name to the live runner:
npm run test:live -- recaptcha-v2
Running npm run test:live without an example name attempts every example command except Tencent
and can create multiple paid tasks. Some examples also require target, callback, or proxy settings
described above. Prefer selecting one example explicitly. Tencent is never included in the default
set and must be selected with npm run test:live -- tencent.
examples/normal_captcha/image_to_text.js reads a local sample image and sends its base64
contents through the SDK.
- Captcha Solver API documentation
- Captcha Solver JavaScript SDK
- Captcha Solver JavaScript Examples
- Captcha Solver Python SDK
- Captcha Solver Python Examples
- Selenium Python Examples
- Cloudflare Turnstile Puppeteer Demo
- Tencent CAPTCHA Automation Guide
This project is licensed under the MIT License.
