Examples of solving popular captcha types with
@captcha-solver-api/javascript-sdk
and Puppeteer.
Each example shows how to:
- Open a page and collect captcha parameters.
- Send a task to Captcha Solver.
- Apply the solution in the browser.
- Check that the page accepted the solution.
Requirements:
- Node.js 22.12 or newer
- A Captcha Solver API key with a positive balance
git clone https://github.com/captcha-solver-api/captcha-solver-puppeteer-javascript-examples.git
cd captcha-solver-puppeteer-javascript-examples
npm ciOn macOS and Linux, create the local configuration file with:
cp .env.example .envOn Windows PowerShell:
Copy-Item .env.example .envSet your API key in .env:
CAPTCHA_API_KEY=your_api_keynpm run example:recaptcha-v2Chrome opens in visible mode. Set HEADLESS=true in .env to run it in the
background. Every example launches 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.
Each run prints numbered steps, the CAPTCHA parameters sent to the API, the complete solution including its token, how the solution is applied, and the demo page's acceptance message. Image bodies are shown as their base64 length; API keys and proxy credentials are redacted.
Every example is intentionally self-contained and written as a linear tutorial:
SDK and browser setup, page navigation, parameter collection, task creation,
solver.solve(), solution application, form submission, and acceptance check
are all visible in the same file. Some code is repeated so that an example can
be copied without also copying hidden project helpers.
| Captcha | File | Command |
|---|---|---|
| reCAPTCHA v2 | recaptcha_v2.js |
npm run example:recaptcha-v2 |
| reCAPTCHA v2 + proxy | recaptcha_v2_proxy.js |
npm run example:recaptcha-v2-proxy |
| reCAPTCHA v2 callback | recaptcha_v2_callback_variant1.js |
npm run example:callback |
| reCAPTCHA v2 callback, automatic discovery | recaptcha_v2_callback_variant2.js |
npm run example:callback-auto |
| reCAPTCHA v2 callback + proxy | recaptcha_v2_callback_proxy.js |
npm run example:callback-proxy |
| reCAPTCHA v3 | recaptcha_v3.js |
npm run example:recaptcha-v3 |
| reCAPTCHA v3 interception | recaptcha_v3_extended_js_script.js |
npm run example:recaptcha-v3-extended |
| Cloudflare Turnstile | cloudflare_turnstile.js |
npm run example:turnstile |
| Cloudflare Challenge | cloudflare_challenge_page.js |
npm run example:challenge |
| Tencent CAPTCHA | tencent.js |
npm run example:tencent |
| Yandex SmartCaptcha | yandex_smartcaptcha.js |
npm run example:yandex-smartcaptcha |
| Image captcha, screenshot | normal_captcha_screenshot.js |
npm run example:image |
| Image captcha, original pixels through canvas | normal_captcha_canvas.js |
npm run example:image-canvas |
| Image captcha with parameters | normal_captcha_screenshot_params.js |
npm run example:image-params |
| Coordinates | coordinates.js |
npm run example:coordinates |
The reCAPTCHA v2 and Yandex SmartCaptcha examples use the official provider
demos by default. Every other browser example requires TARGET_URL in .env
for a page you are authorized to test.
PROXY_TYPE=http
PROXY_ADDRESS=proxy.example.com
PROXY_PORT=8080
PROXY_LOGIN=
PROXY_PASSWORD=The browser and API task use the same proxy.
npm run lint
npm run check
npm testnormal_captcha_screenshot.js sends the pixels as rendered by Chrome.
normal_captcha_canvas.js draws the loaded image into a canvas and sends its
original pixel data, avoiding viewport scaling and screenshot effects. Canvas
capture only works when the page permits reading the image without a CORS-tainted
canvas.
- 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.
