reCAPTCHAv2 Image API

Solve Google reCAPTCHAv2 image challenges with advanced image processing

Overview

The reCAPTCHAv2 Image API enables you to solve Google reCAPTCHA v2 image challenges by sending the images url based on specific categories. Using advanced image processing technology, it can accurately detect and classify objects, allowing you to automate solutions for visual reCAPTCHAv2 challenges, improving accessibility and streamlining workflows.

Endpoint

POST
/api/recaptcha/image

Request

Headers

Name Required Description
Content-Type Yes application/json
x-api-key Yes Your API key

Body Parameters

Parameter Type Required Description
imageUrl string Yes URL of the reCAPTCHA image file (jpg, jpeg, png)
captchaText string Yes The target of detect (eg: bicycles, motorcycles)
gridSize string Yes Grid Size of the challange (1x1, 3x3 or 4x4)

Example Request

{
  "imageUrl": "https://www.google.com/recaptcha/api2/payload?p=...",
  "captchaText":"cars",
  "gridSize": "4x4"
}

Response

Success Response (200 OK)

{
  "isSuccess": true,
  "statusCode": 200,
  "errorMessage": null,
  "data": {
    "captchaGUID": "7587c9c6-cf5f-4dc9-a382-a808a2d90dc8",
    "prediction": "false,false,false,false,false,false,true,false,true,true,true,false,true,true,true,false"
  }
}

Response Fields

Field Type Description
isSuccess boolean Indicates if the request was successful
statusCode number HTTP status code
errorMessage string Error message (null if successful)
data.captchaGUID string Unique identifier for this solution (use this for reporting incorrect predictions)
data.prediction string The output of the image prediction (true or false for image tiles)

Error Response

{
  "isSuccess": false,
  "statusCode": 400,
  "errorMessage": "Invalid grid size format: '4'. Only expected format for '1x1', '3x3', '4x4'.",
  "data": null
}

Error Codes

Status Code Message Description
400 Invalid image URL The provided URL is not valid or accessible
401 Unauthorized Invalid API key or not provided
403 Insufficient balance Your account has insufficient balance to process this request
500 Internal server error Something went wrong with our image processing service

Tips for Best Results

  • Image URL: Extract the direct URL to the image file from the reCAPTCHAv2 iframe.
  • URL Expiration: Note that reCAPTCHAv2 image URLs typically expire quickly, so process them immediately after extraction.
  • Reporting: Report any incorrect transcriptions to help improve our system.

How to Get reCAPTCHAv2 Image URL

To use this API, you need to extract the image URL from a Google reCAPTCHAv2 challenge. Here's how to do it:

  1. Access the reCAPTCHAv2 challange: Click on the chechbox to start reCAPTCHAv2 challenge.
  2. Extract the image URL: Using browser developer tools, inspect the image element and find the source URL, which typically looks like:
    https://www.google.com/recaptcha/api2/payload?p=...
  3. Send the URL to our API: Use the extracted URL in your API request to get the prediction.
The image URL contains an authentication token and expires quickly, usually within minutes. Make sure to process it immediately after extraction.

Code Examples

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

public class RecaptchaAudioExample
{
    private static readonly HttpClient client = new HttpClient();
    private const string ApiUrl = "/api/recaptcha/image";
    private const string ApiKey = "YOUR_API_KEY";

    public static async Task SolveRecaptchaImage(string imageUrl, string captchaText, string gridSize)
    {
        // Prepare request
        client.DefaultRequestHeaders.Add("x-api-key", ApiKey);

        var payload = new
        {
            imageUrl = imageUrl,
            captchaText = captchaText,
            gridSize = gridSize
        };

        var content = new StringContent(
            JsonConvert.SerializeObject(payload),
            Encoding.UTF8,
            "application/json"
        );

        // Send request
        var response = await client.PostAsync(ApiUrl, content);
        var responseString = await response.Content.ReadAsStringAsync();

        // Parse response
        dynamic result = JsonConvert.DeserializeObject(responseString);

        if (result.isSuccess)
        {
            return result.data.prediction;
        }
        else
        {
            throw new Exception($"Error: {result.errorMessage}");
        }
    }
}
import requests
import json

API_URL = "/api/recaptcha/image"
API_KEY = "YOUR_API_KEY"

def solve_recaptcha_image(image_url, captcha_text, grid_size):
    # Prepare headers and payload
    headers = {
        "Content-Type": "application/json",
        "x-api-key": API_KEY
    }

    payload = {
        "imageUrl": image_url,
        "captchaText": captcha_text,
        "gridSize": grid_size
    }

    # Make request
    response = requests.post(API_URL, headers=headers, json=payload)
    result = response.json()

    if result["isSuccess"]:
        return result["data"]["prediction"]
    else:
        raise Exception(f"Error: {result['errorMessage']}")

# Example usage
try:
    audio_url = "https://www.google.com/recaptcha/api2/payload?p=..."
    captcha_text = "bicycles"
    grid_size = 4x4
    image_prediction = solve_recaptcha_image(image_url, captcha_text, grid_size)
    print(f"reCAPTCHA solved: {image_prediction}")
except Exception as e:
    print(str(e))
// reCAPTCHA Audio Solving Example

async function solveRecaptchaImage(imageUrl, captchaText, gridSize) {
  const API_URL = "/api/recaptcha/image";
  const API_KEY = "YOUR_API_KEY";

  // Prepare request
  const payload = {
    imageUrl: imageUrl,
    captchaText: captchaText,
    gridSize: gridSize
  };

  // Send request
  const response = await fetch(API_URL, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'x-api-key': API_KEY
    },
    body: JSON.stringify(payload)
  });

  const result = await response.json();

  if (result.isSuccess) {
    return result.data.prediction;
  } else {
    throw new Error(`Error: ${result.errorMessage}`);
  }
}

// Example of extracting image URL from reCAPTCHA
function extractRecaptchaImageUrl() {
  const imageElement = document.querySelector('img[src*="recaptcha/api2/payload"]');
  if (imageElement && imageElement.src) {
    return imageElement.src;
  }
  throw new Error('No reCAPTCHA image found');
}

// Example usage
async function handleRecaptchaImage() {
  try {
    const imageUrl = extractRecaptchaImageUrl();
    const captchaText = "bicycles"; 
    const gridSize = "4x4"; 

    const captchaPrediction = await solveRecaptchaImage(imageUrl, captchaText, gridSize);
    console.log(`reCAPTCHA solved: ${captchaPrediction}`);

    document.getElementById('g-recaptcha-response').value = captchaPrediction;
  } catch (error) {
    console.error(error.message);
  }
}
}