Cookie usage notification

This site uses cookies. Cookies remember you, so we can provide you with personalized services. Read our privacy policy.

Logo of «GitHub»
  • We support API for «PHP» language
  • We support API for «Python» language
  • We support API for «Go» language
  • We support API for «Ruby» language
  • We support API for «C#» language
  • We support API for «Java» language
  • We support API for «JavaScript» language

hCaptcha

hCaptcha widget

Token-based method to bypass hCaptcha. The method is quite similar to reCAPTCHA V2. The token can be used on the target website inside h-captcha-response form field or passed to a callback function. It's recommended to use the userAgent value together with the token.

Task types

  • HCaptchaTaskProxyless - we use our own pool of proxies
  • HCaptchaTask - we use your proxies

HCaptchaTaskProxyless task type specification

Property Type Required Description
type String Yes Task type:
HCaptchaTaskProxyless
HCaptchaTask
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 hCaptcha sitekey. Can be found inside data-sitekey property of the hCaptcha div element or inside sitekey parameter of the requests to hCaptcha API
isInvisible Boolean No Pass true for Invisible version of hCaptcha - a case when you don't see the checkbox, but the challenge appears. Mostly used with a callback function
enterprisePayload Object No An object containing additional parameters like: rqdata, sentry, apiEndpoint, endpoint, reportapi, assethost, imghost
Usage example: "enterprisePayload":{"rqdata":"test_string"}

HCaptchaTask task type specification

HCaptchaTask extends HCaptchaTaskProxyless 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

HCaptchaTaskProxyless request example

{
    "clientKey":"YOUR_API_KEY",
    "task": {
        "type":"HCaptchaTaskProxyless",
        "websiteURL":"https://2captcha.com/demo/hcaptcha",
        "websiteKey":"f7de0da3-3303-44e8-ab48-fa32ff8ccc7b"
    }
}

HCaptchaTask request example

{
    "clientKey":"YOUR_API_KEY",
    "task": {
        "type":"HCaptchaTask",
        "websiteURL":"https://2captcha.com/demo/hcaptcha",
        "websiteKey":"f7de0da3-3303-44e8-ab48-fa32ff8ccc7b",
        "isInvisible": false,
        "enterprisePayload" : {
            "rqdata" :"rqDataValue"
        }, 
        "proxyType":"http",
        "proxyAddress":"1.2.3.4",
        "proxyPort":"8080",
        "proxyLogin":"user23",
        "proxyPassword":"p4$w0rd"
    }
}

Response example

{
    "errorId": 0,
    "status": "ready",
    "solution": {
        "token": "P1_eyJ0eXAiOiJKV...1LDq89KyJ5A",
        "respKey": "E0_eyJ0eXAiOiJK...y2w5_YbP8PGuJBBo",
        "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.5614.0 Safari/537.36",
        "gRecaptchaResponse": "P1_eyJ0eXAiOiJKV...1LDq89KyJ5A"
    },
    "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->hcaptcha([
        'sitekey' => 'f7de0da3-3303-44e8-ab48-fa32ff8ccc7b',
        'url'     => 'https://2captcha.com/demo/hcaptcha',
    ]);
} 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.hcaptcha(
        sitekey='f7de0da3-3303-44e8-ab48-fa32ff8ccc7b',
        url='https://2captcha.com/demo/hcaptcha',
    )

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 HCaptchaExample
    {
        public void Main()
        {
            TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
            HCaptcha captcha = new HCaptcha();
            captcha.SetSiteKey("f7de0da3-3303-44e8-ab48-fa32ff8ccc7b");
            captcha.SetUrl("https://2captcha.com/demo/hcaptcha");
            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.HCaptcha;

public class HCaptchaExample {
    public static void main(String[] args) {
        TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
        HCaptcha captcha = new HCaptcha();
        captcha.setSiteKey("f7de0da3-3303-44e8-ab48-fa32ff8ccc7b");
        captcha.setUrl("https://2captcha.com/demo/hcaptcha");
        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")
    cap := api2captcha.HCaptcha{
        SiteKey: "f7de0da3-3303-44e8-ab48-fa32ff8ccc7b",
        Url: "https://2captcha.com/demo/hcaptcha",   
    }
    code, err := client.Solve(cap.ToRequest())
    if err != nil {
        log.Fatal(err);
    }
    fmt.Println("code "+code)
}
require 'api_2captcha'

client =  Api2Captcha.new("YOUR_API_KEY")

result = client.hcaptcha({
sitekey: 'f7de0da3-3303-44e8-ab48-fa32ff8ccc7b',
pageurl: 'https://2captcha.com/demo/hcaptcha'
})