👑 CaptchaKings
  • Home
  • Features
  • Pricing
  • Documentation
Login Sign Up

Node.js Captcha Solver

reCAPTCHA, hCaptcha & image captchas in Node.js — updated August 2026

TL;DR: No npm package needed — the API is plain JSON. Create a task with axios (or native fetch on Node 18+), poll every 3 seconds, inject the token. 50 free solves on signup, no credit card.

reCAPTCHA v2 / hCaptcha with Axios

Token captchas are solved asynchronously: create the task, poll for the result. The same class handles reCAPTCHA v2, hCaptcha and AWS WAF — only the type and key fields change (see hCaptcha solver and AWS WAF solver for their payloads):

solver.js — ESM
import axios from 'axios';

const API_KEY = process.env.CAPTCHAKINGS_KEY;
const API = 'https://api.captchakings.com';

const sleep = (ms) => new Promise(r => setTimeout(r, ms));

export async function solveRecaptchaV2(websiteURL, websiteKey) {
    // 1. Create the task
    const { data: created } = await axios.post(`${API}/createTask`, {
        clientKey: API_KEY,
        task: {
            type: 'RecaptchaV2TaskProxyless',
            websiteURL,
            websiteKey
        }
    });

    if (!created.taskId) throw new Error('createTask failed: ' + JSON.stringify(created));

    // 2. Poll until ready (timeout 120s)
    const deadline = Date.now() + 120_000;
    while (Date.now() < deadline) {
        await sleep(3000);
        const { data: result } = await axios.post(`${API}/getTaskResult`, {
            clientKey: API_KEY,
            taskId: created.taskId
        });
        if (result.status === 'ready') return result.solution.gRecaptchaResponse;
    }
    throw new Error('Solve timed out');
}

CommonJS? Change the import line to const axios = require('axios'); and drop the export — everything else is identical.

Image Captchas with Native Fetch (Zero Dependencies)

Node 18+ has global fetch, FormData and Blob, so image solving needs no packages at all. The endpoint returns the solved text synchronously:

image-solver.mjs
import { readFile } from 'node:fs/promises';

const API_KEY = process.env.CAPTCHAKINGS_KEY;

export async function solveImageCaptcha(path) {
    const buffer = await readFile(path);
    const form = new FormData();
    form.append('captcha', new Blob([buffer]), path);

    const res = await fetch('https://captchakings.com/api/process.php', {
        method: 'POST',
        headers: { Authorization: `Bearer ${API_KEY}` },
        body: form
    });

    const data = await res.json();
    if (!data.success) throw new Error(data.error.message);
    return {
        text: data.data.prediction,
        confidence: data.data.confidence,
        balance: data.billing.balance_remaining
    };
}

console.log(await solveImageCaptcha('captcha.jpg'));

Puppeteer: Inject the Token and Submit

Pair the solver with Puppeteer for full form automation. The challenge never runs in your browser — you just drop the token in:

puppeteer-flow.mjs
import puppeteer from 'puppeteer';
import { solveRecaptchaV2 } from './solver.js';

const browser = await puppeteer.launch({ headless: 'new' });
const page = await browser.newPage();
await page.goto('https://example.com/signup');

// Grab the site key from the page, then solve
const siteKey = await page.$eval('.g-recaptcha', el => el.dataset.sitekey);
const token = await solveRecaptchaV2(page.url(), siteKey);

// Inject token into the hidden textarea and submit
await page.evaluate((t) => {
    document.getElementById('g-recaptcha-response').value = t;
}, token);
await page.$eval('form', form => form.submit());

await browser.close();

Express Middleware Pattern

Building a scraping API? Wrap the solver in a route and let your own services call it internally:

server.mjs
import express from 'express';
import { solveRecaptchaV2 } from './solver.js';

const app = express();
app.use(express.json());

app.post('/solve', async (req, res) => {
    try {
        const token = await solveRecaptchaV2(req.body.url, req.body.siteKey);
        res.json({ token });
    } catch (err) {
        res.status(502).json({ error: err.message });
    }
});

app.listen(3000);

Concurrency: Solve Many at Once

Node's event loop makes bulk solving trivial — fire tasks concurrently instead of sequentially:

bulk.mjs
const jobs = [
    { url: 'https://site-a.com/form', key: 'SITE_KEY_A' },
    { url: 'https://site-b.com/form', key: 'SITE_KEY_B' },
    { url: 'https://site-c.com/form', key: 'SITE_KEY_C' }
];

const tokens = await Promise.all(
    jobs.map(j => solveRecaptchaV2(j.url, j.key))
);
console.log(tokens);

Endpoint Recap

Captcha TypeEndpointResult
Image captchacaptchakings.com/api/process.phpSolved text (synchronous)
reCAPTCHA / hCaptcha / AWS WAFapi.captchakings.com/createTaskToken (async, poll getTaskResult)
2Captcha-compatiblecaptchakings.com/in.php / res.phpDrop-in migration format

Best Practices

  • Node 18 or later — you get fetch/FormData natively and can skip axios entirely if you prefer.
  • Poll every 3 seconds with a 120-second deadline; typical reCAPTCHA v2 solves land in 5–20 seconds.
  • Keep the key in process.env — never commit it to a repo.
  • Cap concurrency (e.g. p-limit) when solving hundreds of tasks so your own process stays predictable.
  • Retry on network errors, not on status: "processing" — polling again is the correct behavior.

FAQ

Is there an npm package?

Not yet — but the API is plain JSON over HTTPS, so the axios snippets above are all you need. A full reCAPTCHA solve is under 30 lines.

How do I solve hCaptcha in Node.js?

Same flow as reCAPTCHA with HCaptchaTaskProxyless as the task type. Create the task, poll getTaskResult, use the token. See the hCaptcha solver page for details.

Does it work with Puppeteer / Playwright?

Yes — solve via the API, inject the token into g-recaptcha-response with page.evaluate, submit the form. Full Puppeteer example above.

What does it cost?

Image captchas: $0.50 per 1,000 solves, pay-as-you-go. 50 free solves on signup, no credit card. Compare in detail on the pricing page.

Integration Guides for Other Languages

  • Python Captcha Solver Guide
  • PHP Captcha Solver Guide
  • cURL / Terminal Guide
  • hCaptcha Solver — How It Works
  • Full API Documentation
  • Free Browser Tools (no code)

Start solving from Node.js today

50 free solves on signup — test with your own captchas.

Get Your API Key

👑 CaptchaKings

AI-powered captcha solving API with 95% success rate. Trusted by developers worldwide.

Compare

  • Price Comparison
  • vs 2Captcha
  • vs CapSolver
  • vs CapMonster
  • vs Anti-Captcha

Legal

  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Documentation

© 2026 CaptchaKings. All rights reserved.