NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

reCAPTCHA

How to solve reCAPTCHA v3 in Node.js with Playwright

reCAPTCHA v3 tokens are requested by the page's own JavaScript at the moment of an action. In Playwright you can answer that request yourself: wrap grecaptcha.execute so it returns a token from GateSolver.

The idea in one paragraph

On a v3 page, the site's script calls grecaptcha.execute(siteKey, {action}) and waits for a promise that resolves to a token. It then puts that token into whatever request it sends next. If your automation replaces execute with a function that asks the API for a token with the same site key and action, the site's code continues exactly as before, building its request with your token in the right field. You do not have to reverse engineer the field name or rebuild the request, which is the hard part of doing v3 without a browser.

This guide uses Playwright for Node.js and the fetch built into Node 18 and newer. Install Playwright with npm install playwright and its browsers with npx playwright install chromium.

A compact task client

The client is a single exported function. It takes the task fields, creates a ReCaptchaV3TaskProxyLess task, and resolves with the token. Errors carry the API's code in a code property so callers can decide whether to retry.

// gate-v3.js
const BASE = 'https://gatesolver.com';

function apiPost(path, payload, clientKey) {
  return fetch(new URL(path, BASE), {
    method: 'POST',
    headers: { 'content-type': 'application/json', accept: 'application/json' },
    body: JSON.stringify({ clientKey, ...payload }),
  })
    .then((r) => r.json())
    .then((j) => {
      if (j.errorId) throw Object.assign(new Error(j.errorDescription || j.errorCode), { code: j.errorCode });
      return j;
    });
}

export async function solveScoreTask(fields, opts = {}) {
  const clientKey = opts.key ?? process.env.GATE_KEY;
  const everyMs = opts.everyMs ?? 3000;
  const { taskId } = await apiPost('/createTask',
    { task: { type: 'ReCaptchaV3TaskProxyLess', ...fields } }, clientKey);
  const started = Date.now();
  while (Date.now() - started < 125_000) {
    await new Promise((done) => setTimeout(done, everyMs));
    const res = await apiPost('/getTaskResult', { taskId }, clientKey);
    if (res.status === 'ready') return res.solution.gRecaptchaResponse;
    if (res.status === 'failed') throw Object.assign(new Error('v3 task failed'), { code: 'FAILED' });
  }
  throw Object.assign(new Error('v3 task timed out'), { code: 'TIMEOUT' });
}

Passing everyMs as an option keeps tests fast. The 125 second ceiling follows the API rule that a task still unsolved after 120 seconds is closed as failed and not charged.

Wrap grecaptcha.execute in the page

Two Playwright features do the work. page.exposeFunction makes a Node function callable from the page, and it returns a promise there, which is exactly the shape grecaptcha.execute must have. page.addInitScript runs your code in every document before the site's scripts, so the wrapper is ready early.

// run-v3.js
import * as pw from 'playwright';
import { solveScoreTask } from './gate-v3.js';

const target = 'https://example.com/search';
const browser = await pw.chromium.launch({ headless: true });
const tab = await browser.newPage();

await tab.exposeFunction('gateV3', (siteKey, action) =>
  solveScoreTask({ websiteURL: target, websiteKey: siteKey, pageAction: action }));

await tab.addInitScript(() => {
  const swap = () => {
    const g = window.grecaptcha;
    if (!g || typeof g.execute !== 'function' || g.execute.gateWrapped) return;
    const wrapped = (key, options) => window.gateV3(key, (options && options.action) || '');
    wrapped.gateWrapped = true;
    g.execute = wrapped;
  };
  const timer = setInterval(swap, 20);
  setTimeout(() => clearInterval(timer), 60_000);
});

await tab.goto(target);
await tab.fill('input[name="q"]', 'usb-c hub');
const [reply] = await Promise.all([
  tab.waitForResponse((r) => r.url().includes('/api/search') && r.request().method() === 'POST'),
  tab.click('form#search button[type="submit"]'),
]);
console.log(reply.status(), await reply.text());
await browser.close();

The init script checks every 20 milliseconds whether the reCAPTCHA library has defined execute, and swaps it once. The gateWrapped marker stops it from wrapping its own wrapper, and it also lets the swap happen again if the library replaces the object later. When the site's search code runs, it awaits execute, gets a token from your Node process, and sends the search request as usual. The selectors and the /api/search filter are placeholders for your target.

Pages that use grecaptcha.enterprise

If the script tag loads enterprise.js, the function to wrap is grecaptcha.enterprise.execute and the task type is ReCaptchaV3EnterpriseTaskProxyLess. The wrapper looks the same with one more property step. Read the Enterprise guide for the extra fields.

When the page calls execute too early

Some sites request a token the moment the library is ready, sometimes before the 20 millisecond check catches up. You will notice because the first request carries a token your code never produced. Two fixes work well:

  • Trigger the action again. Many pages call execute again on the real user action, and that second call goes through your wrapper.
  • Rewrite the request. Use page.route() on the site's endpoint, read route.request().postDataJSON(), replace the token field with one from solveScoreTask, and continue with route.continue({ postData: JSON.stringify(body) }). This needs the field name from the network panel, but it never races.

The route approach is also the right one when the site keeps the token in a hidden input that it refreshes every couple of minutes, because the value submitted with the form is then whatever was last written there.

Keep the action honest

The wrapper forwards the action the page itself passes, which is the main advantage of this method: the action in the token always matches what the site's server expects for that request. If you solve outside the browser, you have to find the action by hand, as described in the guide on how to find the reCAPTCHA v3 action name. A mismatched action is one of the most common reasons a site refuses an otherwise valid token.

Performance and cost

Each call to the wrapper creates one task, so count how often the page calls execute. Some sites call it on every keystroke in a search box or on a timer, which would create many tasks you do not need. In that case, cache the promise for a short time inside the exposed function, for example reuse the same token request for calls with the same action within a few seconds, or switch to the route method and solve only when the request you care about leaves the page.

Solved v3 tasks cost $0.70 per 1,000 and usually come back under 3 seconds; failed ones are free. Several pages can run at once because there is no limit on concurrent tasks, as long as the total stays under 600 API requests per minute per key.

Troubleshooting checklist

  • The wrapper never runs. Log from inside swap with console.log and listen with page.on('console'). If grecaptcha never appears, the site may load reCAPTCHA in an iframe; attach the init script with context.addInitScript so frames get it too.
  • The site says the token is invalid. Check that the action reached the task, and that the token was used within two minutes.
  • The score seems low. The site decides how to treat each score. The article on reCAPTCHA v3 scores covers what you can influence.
  • The IP matters. If the site compares networks, use ReCaptchaV3Task with the proxy your Playwright context uses.

Field details are on the reCAPTCHA v3 page, and the Playwright integration guide covers contexts, proxies and parallel runs.

Common questions

Why wrap execute instead of filling a field?

v3 has no field to fill. Wrapping execute lets the page put the token into its own request, under the right name, with the right action.

Does exposeFunction work across navigations?

Yes. Functions exposed on a page survive navigations, and init scripts run again in every new document.

What if the site uses grecaptcha.enterprise?

Wrap grecaptcha.enterprise.execute instead and use the reCAPTCHA v3 Enterprise task type.

Will this create a task for every execute call?

Yes. If the page calls execute often, reuse a pending token request for a few seconds or switch to request rewriting.

Can I run several pages at the same time?

Yes. There is no limit on concurrent tasks; keep total API calls under 600 per minute per key.

Keep reading