Skip to main content
Are you experiencing issues obtaining the token?
Contact support

RecaptchaV2Task

The object contains data for Google ReCaptcha2 solving task. To ensure the universality of the solution to this type of captcha, you need to use all the data used when automating the filling of the form on the target site, including proxies, browser user-agent and cookies. This will help to avoid any problems when Google changes the code of its captcha.

This type of captcha might be solved a bit longer than usual image captcha, but this issue is compensated by the fact that g-captcha-response value we send to you is valid for the next 60 seconds after we solves your ReCaptcha2.

More on the topic in our blog
Attention!

If the proxy is authorized by IP, then be sure to add 116.203.55.208 to the white list.

Request parameters

type<string>required

RecaptchaV2Task


websiteURL<string>required

Address of a webpage with captcha.


websiteKey<string>required

Recaptcha website key.
<div class="g-recaptcha" data-sitekey="THIS_ONE"></div>


recaptchaDataSValue<string>optional

Some custom implementations may contain additional "data-s" parameter in ReCaptcha2 div, which is in fact a one-time token and must be grabbed every time you want to solve a ReCaptcha2.
<div class="g-recaptcha" data-sitekey="some sitekey" data-s="THIS_ONE"></div>


userAgent<string>optional

Browser's User-Agent which is used in emulation. It is required that you use a signature of a modern browser, otherwise Google will ask you to "update your browser".


cookies<string>optional

Additional cookies which we must use during interaction with target page or Google.

Format: cookiename1=cookievalue1; cookiename2=cookievalue2


isInvisible<bool>optional

true if the captcha is invisible, i.e. has a hidden field for confirmation, no checkbox. If a bot is suspected, an additional check is called.


proxyType<string>optional

http - regular http/https proxy;
https - try this option only if "http" doesn't work (required for some custom proxies);
socks4 - socks4 proxy;
socks5 - socks5 proxy.


proxyAddress<string>optional

IPv4/IPv6 proxy IP address. Not allowed:

  • using of hostnames;
  • using transparent proxies (where you can see the client's IP);
  • using proxies on local machines.


proxyPort<integer>optional

Proxy port.


proxyLogin<string>optional

Proxy-server login.


proxyPassword<string>optional

Proxy-server password.

Create task method

POST
https://api.capmonster.cloud/createTask

Request

{
"clientKey":"API_KEY",
"task": {
"type":"RecaptchaV2Task",
"websiteURL":"https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
"websiteKey":"6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd"
}
}

Response

{
"errorId":0,
"taskId":407533072
}

Get task result method

Use the getTaskResult method to request answer for ReCaptcha2. You will get response within 100 ms depending on service workload.

POST
https://api.capmonster.cloud/getTaskResult

Request

{
"clientKey":"API_KEY",
"taskId": 407533072
}

Response

{
"errorId":0,
"status":"ready",
"solution": {
"gRecaptchaResponse":"3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3"
}
}

PropertyTypeDescription
gRecaptchaResponseStringHash which should be inserted into Recaptcha2 submit form in <textarea id="g-recaptcha-response" ..></textarea> . It has a length of 500 to 2190 bytes.

How to Find All Required Parameters for Task Creation

Manually

  1. Open your website where the captcha appears in the browser.
  2. Right-click on the captcha element and select Inspect.

websiteKey (data-sitekey)

Elements tab: look for a <div class="g-recaptcha"> element on the page. Copy the value of the data-sitekey attribute, for example:

sitekey

Network tab:

Open the Network tab and reload the page with the captcha. Look for a request like the one below (the k value is the data-sitekey):

sitekey1

recaptchaDataSValue (if used)

If the page contains a data-s attribute, find it in the HTML:

datas

isInvisible

Network tab: if the captcha is invisible, the element will contain the attribute size="invisible", for example:

isinvisible

Automatically

A convenient way to automate the search for all necessary parameters. Some parameters are regenerated every time the page loads, so you'll need to extract them through a browser — either regular or headless (e.g., using Playwright). Since the values of dynamic parameters are short-lived, the captcha must be solved immediately after retrieving them.

Important!

The code snippets provided are basic examples for familiarization with extracting the required parameters. The exact implementation will depend on your captcha page, its structure, and the HTML elements/selectors it uses.

Show Code (for browser)
(() => {
const iframeEl = document.querySelector('iframe[src^="https://www.google.com/recaptcha/api2/anchor?"]');
const captchaUrl = iframeEl?.getAttribute('src');

if (captchaUrl) {
const urlParams = new URLSearchParams(captchaUrl.split('?')[1]);

const sitekey = urlParams.get('k');
const size = urlParams.get('size');

const isInvisible = size === 'invisible';

const sitekeyEl = document.querySelector('[data-sitekey]');
const datasEl = document.querySelector('[data-s]');
const datas = datasEl?.getAttribute('data-s');

console.log({
sitekey: sitekey || sitekeyEl?.getAttribute('data-sitekey'),
datas,
isInvisible
});
}
})();
Show Code (Node.js)
import { chromium } from "playwright";

(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();

await page.goto("https://example.com");

await page.waitForSelector('iframe[src^="https://www.google.com/recaptcha/api2/anchor?"]');

const captchaData = await page.evaluate(() => {
const iframeEl = document.querySelector('iframe[src^=
"https://www.google.com/recaptcha/api2/anchor?"]');
const captchaUrl = iframeEl?.getAttribute("src");

if (captchaUrl) {
const urlParams = new URLSearchParams(captchaUrl.split("?")[1]);
const sitekey = urlParams.get("k");
const size = urlParams.get("size");
const isInvisible = size === "invisible";

const sitekeyEl = document.querySelector("[data-sitekey]");
const datasEl = document.querySelector("[data-s]");
const datas = datasEl?.getAttribute("data-s");

return {
sitekey: sitekey || sitekeyEl?.getAttribute("data-sitekey"),
datas,
isInvisible,
};
}
return null;
});

console.log(captchaData);
await browser.close();
})();

Use SDK Library

// https://github.com/ZennoLab/capmonstercloud-client-js

import { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2Request, /*RecaptchaV2Request*/ } from '@zennolab_com/capmonstercloud-client';

document.addEventListener('DOMContentLoaded', async () => {
const cmcClient = CapMonsterCloudClientFactory.Create(new ClientOptions({ clientKey: '<your capmonster.cloud API key>' }));
console.log(await cmcClient.getBalance());

const recaptchaV2Request = new RecaptchaV2Request({
websiteURL: 'https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high',
websiteKey: '6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd',
});

// const recaptchaV2Request = new RecaptchaV2Request({
// websiteURL: 'https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high',
// websiteKey: '6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd',
// proxyType: 'http',
// proxyAddress: '8.8.8.8',
// proxyPort: 8080,
// proxyLogin: 'proxyLoginHere',
// proxyPassword: 'proxyPasswordHere',
// userAgent: 'userAgentPlaceholder',
// });

console.log(await cmcClient.Solve(recaptchaV2Request));
});
More on the topic in our blog