reCAPTCHA V2
Token-based method for automated solving of reCAPTCHA V2.
The token recived then can be sent to the target website inside g-recaptcha-response
form field or passed to a callback function.
Task types
- RecaptchaV2TaskProxyless - suitable for most cases. We use our own pool of proxies to solve the captchas
- RecaptchaV2Task - used for cases when IP matching is requied on Google service like Google Search, YouTube, etc. Bad proxies will drastically decrease the success rate and increase the solving time.
RecaptchaV2TaskProxyless task type specification
Property | Type | Required | Description |
---|---|---|---|
type | String | Yes | Task type: RecaptchaV2TaskProxyless RecaptchaV2Task |
websiteURL | String | Yes | The full URL of target web page where the captcha is loaded. We do not open the page, not a problem if it is available only for authenticated users |
websiteKey | String | Yes | reCAPTCHA sitekey. Can be found inside data-sitekey property of the reCAPTCHA div element or inside k parameter of the requests to reCAPTHCHA API. You can also use the script to find the value |
recaptchaDataSValue | String | No | The value of data-s parameter. Can be required to bypass the captcha on Google services |
isInvisible | Boolean | No | Pass true for Invisible version of reCAPTCHA - a case when you don't see the checkbox, but the challenge appears. Mostly used with a callback function |
userAgent | String | No | User-Agent of your browser will be used to load the captcha. Use only modern browser's User-Agents |
cookies | String | No | Your cookies will be set in a browser of our worker. Suitable for captcha on Google services. The format is: key1=val1; key2=val2 |
apiDomain | String | No | Domain used to load the captcha: google.com or recaptcha.net . Default value: google.com |
RecaptchaV2Task task type specification
RecaptchaV2Task
extends RecaptchaV2TaskProxyless
adding a set of proxy-related parameters listed below
Property | Type | Required | Description |
---|---|---|---|
proxyType | String | Yes | Proxy type: http socks4 socks5 |
proxyAddress | String | Yes | Proxy IP address or hostname |
proxyPort | Integer | Yes | Proxy port |
proxyLogin | String | No | Login for basic authentication on the proxy |
proxyPassword | String | No | Password for basic authentication on the proxy |
Request examples
Method: createTask
API endpoint: https://api.2captcha.com/createTask
RecaptchaV2TaskProxyless
{
"clientKey":"YOUR_API_KEY",
"task": {
"type":"RecaptchaV2TaskProxyless",
"websiteURL":"https://2captcha.com/demo/recaptcha-v2",
"websiteKey":"6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u",
"isInvisible":false
}
}
RecaptchaV2Task
{
"clientKey":"YOUR_API_KEY",
"task": {
"type":"RecaptchaV2Task",
"websiteURL":"https://2captcha.com/demo/recaptcha-v2",
"websiteKey":"6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u",
"isInvisible":false,
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36",
"cookies":"foo=bar; baz=1",
"proxyType":"http",
"proxyAddress":"1.2.3.4",
"proxyPort":"8080",
"proxyLogin":"user23",
"proxyPassword":"p4$w0rd"
}
}
Response example
Method: getTaskResult
API endpoint: https://api.2captcha.com/getTaskResult
{
"errorId": 0,
"status": "ready",
"solution": {
"gRecaptchaResponse": "03ADUVZw...UWxTAe6ncIa",
"token": "03ADUVZw...UWxTAe6ncIa"
},
"cost": "0.00299",
"ip": "1.2.3.4",
"createTime": 1692863536,
"endTime": 1692863556,
"solveCount": 1
}
Code examples
// https://github.com/2captcha/2captcha-php
require(__DIR__ . '/../src/autoloader.php');
$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');
try {
$result = $solver->recaptcha([
'sitekey' => '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u',
'url' => 'https://2captcha.com/demo/recaptcha-v2',
]);
} catch (\Exception $e) {
die($e->getMessage());
}
die('Captcha solved: ' . $result->code);
# https://github.com/2captcha/2captcha-python
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
from twocaptcha import TwoCaptcha
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
solver = TwoCaptcha(api_key)
try:
result = solver.recaptcha(
sitekey='6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u',
url='https://2captcha.com/demo/recaptcha-v2')
except Exception as e:
sys.exit(e)
else:
sys.exit('solved: ' + str(result))
// https://github.com/2captcha/2captcha-csharp
using System;
using System.Linq;
using TwoCaptcha.Captcha;
namespace TwoCaptcha.Examples
{
public class reCAPTCHAV2Example
{
public void Main()
{
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
ReCaptcha captcha = new ReCaptcha();
captcha.SetSiteKey("6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u");
captcha.SetUrl("https://2captcha.com/demo/recaptcha-v2");
try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
// https://github.com/2captcha/2captcha-java
package examples;
import com.twocaptcha.TwoCaptcha;
import com.twocaptcha.captcha.reCAPTCHA;
public class reCAPTCHAV2Example {
public static void main(String[] args) {
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
ReCaptcha captcha = new ReCaptcha();
captcha.setSiteKey("6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u");
captcha.setUrl("https://2captcha.com/demo/recaptcha-v2");
try {
solver.solve(captcha);
System.out.println("Captcha solved: " + captcha.getCode());
} catch (Exception e) {
System.out.println("Error occurred: " + e.getMessage());
}
}
}
// https://github.com/2captcha/2captcha-go
package main
import (
"fmt"
"log"
"github.com/2captcha/2captcha-go"
)
func main() {
client := api2captcha.NewClient("API_KEY")
captcha := api2captcha.ReCaptcha{
SiteKey: "6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u",
Url: "https://2captcha.com/demo/recaptcha-v2",
}
code, err := client.Solve(captcha.ToRequest())
if err != nil {
log.Fatal(err);
}
fmt.Println("code "+code)
}
# https://github.com/2captcha/2captcha-ruby
require 'api_2captcha'
client = Api2Captcha.new("YOUR_API_KEY")
result = client.recaptcha_v2({
googlekey: '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u',
pageurl: 'https://2captcha.com/demo/recaptcha-v2'
})