reCAPTCHA v2

The object contains data for Google reCAPTCHA v2 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 UserAgent 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-recaptcha-response value we send to you is valid for the next 60 seconds after we solves your ReCaptcha2.
By default, CapMonster Cloud uses built-in proxies suitable for most websites.
However, if the token is not accepted by the target site, try again with your own proxies (RecaptchaV2Task with proxy). Make sure to use the same proxies when solving the captcha and submitting the token to the site.
-
If IP-based authorization is used, add 65.21.190.34 to the whitelist.
-
If the reCAPTCHA v2 token is still not accepted — contact technical support.
Request parameters
type<string>requiredRecaptchaV2Task
websiteURL<string>requiredAddress of a webpage with captcha.
websiteKey<string>requiredRecaptcha website key.<div class="g-recaptcha" data-sitekey="THIS_ONE"></div>
recaptchaDataSValue<string>optionalSome 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>optionalBrowser'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>optionalAdditional cookies which we must use during interaction with target page or Google.
Format: cookiename1=cookievalue1; cookiename2=cookievalue2
isInvisible<bool>optionaltrue 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>optionalhttp - 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>optionalIPv4/IPv6 proxy IP address. Not allowed:
- using transparent proxies (where you can see the client's IP);
- using proxies on local machines.
proxyPort<integer>optionalProxy port.
proxyLogin<string>optionalProxy-server login.
proxyPassword<string>optionalProxy-server password.
Create task method
- RecaptchaV2Task (without proxy)
- RecaptchaV2Task (with proxy)
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
}
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",
"proxyType":"http",
"proxyAddress":"8.8.8.8",
"proxyPort":8080,
"proxyLogin":"proxyLoginHere",
"proxyPassword":"proxyPasswordHere",
"userAgent":"userAgentPlaceholder"
}
}
Response
{
"errorId":0,
"taskId":407533072
}
Get task result method
On some websites, it is important that the UserAgent matches the one used when solving the captcha. Therefore, if CapMonster Cloud returns a UserAgent along with the token, always apply it when submitting the form or confirming the solution on the target page.
Use the getTaskResult method to request answer for ReCaptcha2. You will get response within 100 ms depending on service workload.
https://api.capmonster.cloud/getTaskResult
Request
{
"clientKey":"API_KEY",
"taskId": 407533072
}
Response
{
"errorId":0,
"status":"ready",
"solution": {
"gRecaptchaResponse":"3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3"
}
}
For some websites, the response may look like the following. When submitting the solution, make sure to use the UserAgent provided in the response, even if it differs from the one currently used by your browser or script.
{
"errorId": 0,
"status": "ready",
"solution": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36",
"gRecaptchaResponse": "0cAFcWeA5Y3...hF8UWA",
"cookies": {
"nocookies": "true"
}
}
}
| Property | Type | Description |
|---|---|---|
| gRecaptchaResponse | String | Hash 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
- Open your website where the captcha appears in the browser.
- 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:

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):

recaptchaDataSValue (if used)
If the page contains a data-s attribute, find it in the HTML:
isInvisible
Network tab: if the captcha is invisible, the element will contain the attribute size="invisible", for example:

Automatically
To automate parameter extraction, you can retrieve them via a browser (regular or headless, e.g., using Playwright) or directly from HTTP requests. Since dynamic parameter values are short-lived, it is recommended to use them immediately after retrieval.
The provided code snippets are basic examples for learning how to extract the required parameters. The exact implementation will depend on your captcha page, its structure, and the HTML elements and selectors used.
- JavaScript
- Python
- C#
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();
})();
Show code
import asyncio
from urllib.parse import urlparse, parse_qs
from playwright.async_api import async_playwright
def parse_recaptcha_url(url):
parsed_url = urlparse(url)
params = parse_qs(parsed_url.query)
sitekey = params.get('k', [None])[0]
size = params.get('size', [None])[0]
return sitekey, size == 'invisible'
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
await page.goto("https://example.com", timeout=60000)
captcha_url = await page.locator('iframe[
src^="https://www.google.com/recaptcha/api2/anchor?"]').get_attribute('src')
if captcha_url:
sitekey, is_invisible = parse_recaptcha_url(captcha_url)
print({"sitekey": sitekey, "isInvisible": is_invisible})
await browser.close()
asyncio.run(main())
Show code
using Microsoft.Playwright;
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
class Program
{
static (string sitekey, bool isInvisible) ParseRecaptchaUrl(string url)
{
var uri = new Uri(url);
var queryParams = HttpUtility.ParseQueryString(uri.Query);
return (queryParams["k"], queryParams["size"] == "invisible");
}
static async Task Main(string[] args)
{
var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.LaunchAsync(
new BrowserTypeLaunchOptions { Headless = true });
var page = await browser.NewPageAsync();
await page.GotoAsync("https://example.com", new PageGotoOptions { Timeout = 60000 });
var captchaUrl = await page.Locator(
"iframe[src^='https://www.google.com/recaptcha/api2/anchor?']").GetAttributeAsync("src");
if (captchaUrl != null)
{
var (sitekey, isInvisible) = ParseRecaptchaUrl(captchaUrl);
Console.WriteLine($"{{\"sitekey\": \"{sitekey}\", \"isInvisible\": {isInvisible}}}");
}
await browser.CloseAsync();
}
}
Use the SDK library
- JavaScript
- Python
- C#
Show code (for browser)
// https://github.com/ZennoLab/capmonstercloud-client-js
import { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2Request }
from '@zennolab_com/capmonstercloud-client';
document.addEventListener('DOMContentLoaded', async () => {
const API_KEY = "YOUR_API_KEY"; // Specify your CapMonster Cloud API key
const cmcClient = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);
// Optionally, you can check the balance
const balance = await cmcClient.getBalance();
console.log("Balance:", balance);
// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
let recaptchaV2Request = new RecaptchaV2Request({
websiteURL: "https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd"
});
// Example of using your own proxy
// Uncomment this block if you want to use your own proxy
/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password"
};
recaptchaV2Request = new RecaptchaV2Request({
websiteURL: "https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
proxy,
userAgent: "userAgentPlaceholder"
});
*/
const result = await cmcClient.Solve(recaptchaV2Request);
console.log("Solution:", result);
});
Show code (Node.js)
// https://github.com/ZennoLab/capmonstercloud-client-js
import { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2Request } from '@zennolab_com/capmonstercloud-client';
const API_KEY = "YOUR_API_KEY"; // Specify your CapMonster Cloud API key
async function solveRecaptchaV2() {
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);
// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
let recaptcha2Request = new RecaptchaV2Request({
websiteURL: "https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd"
});
// Example of using your own proxy
// Uncomment this block if you want to use your own proxy
/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password"
};
recaptcha2Request = new RecaptchaV2Request({
websiteURL: "https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
websiteKey: "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
proxy,
userAgent: "userAgentPlaceholder"
});
*/
// Optionally, you can check the balance
const balance = await client.getBalance();
console.log("Balance:", balance);
const result = await client.Solve(recaptcha2Request);
console.log("Solution:", result);
}
solveRecaptchaV2().catch(console.error);
Show code
# https://github.com/ZennoLab/capmonstercloud-client-python
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import RecaptchaV2Request
# from capmonstercloudclient.requests.baseRequestWithProxy import ProxyInfo # Uncomment if you plan to use a proxy
API_KEY = "YOUR_API_KEY" # Specify your CapMonster Cloud API key
async def solve_recaptcha_v2():
client_options = ClientOptions(api_key=API_KEY)
cap_monster_client = CapMonsterClient(options=client_options)
# Basic example without proxy
# CapMonster Cloud automatically uses its own proxies
recaptcha2_request = RecaptchaV2Request(
websiteUrl="https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
websiteKey="6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd"
)
# Example of using your own proxy
# Uncomment this block if you want to use your own proxy
# proxy = ProxyInfo(
# proxyType="http",
# proxyAddress="123.45.67.89",
# proxyPort=8080,
# proxyLogin="username",
# proxyPassword="password"
# )
# recaptcha2_request = RecaptchaV2Request(
# websiteUrl="https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
# websiteKey="6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
# proxy=proxy,
# userAgent="userAgentPlaceholder"
# )
# Optionally, you can check the balance
balance = await cap_monster_client.get_balance()
print("Balance:", balance)
result = await cap_monster_client.solve_captcha(recaptcha2_request)
print("Solution:", result)
asyncio.run(solve_recaptcha_v2())
Show code
// https://github.com/ZennoLab/capmonstercloud-client-dotnet
using System;
using System.Threading.Tasks;
using Zennolab.CapMonsterCloud;
using Zennolab.CapMonsterCloud.Requests;
class Program
{
static async Task Main(string[] args)
{
// Your CapMonster Cloud API key
var clientOptions = new ClientOptions
{
ClientKey = "YOUR_API_KEY"
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
// Basic example without proxy
// CapMonster Cloud automatically uses its own proxies
var recaptchaV2Request = new RecaptchaV2Request
{
WebsiteUrl = "https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high", // URL of the page with the captcha
WebsiteKey = "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd" // Replace with the correct value
};
// Example of using your own proxy
// Uncomment this block if you want to use your own proxy
/*
var recaptchaV2Request = new RecaptchaV2Request
{
WebsiteUrl = "https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
WebsiteKey = "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
Proxy = new ProxyContainer(
"123.45.67.89",
8080,
ProxyType.Http,
"username",
"password"
)
};
*/
// Optionally, you can check the balance
var balance = await cmCloudClient.GetBalanceAsync();
Console.WriteLine("Balance: " + balance);
var recaptchaV2Result = await cmCloudClient.SolveAsync(recaptchaV2Request);
Console.WriteLine("Solution: " + recaptchaV2Result.Solution.Value);
}
}
