Text CAPTCHA API

Solve image-based text CAPTCHAs with high accuracy

Overview

The Text CAPTCHA API allows you to submit image-based CAPTCHAs for our AI to solve. Our advanced OCR algorithms can handle various distortion techniques, fonts, and backgrounds to provide fast and accurate results.

Endpoint

POST
/api/captcha

Request

Headers

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

Body Parameters

Parameter Type Required Description
image string Yes Base64 encoded image (JPG/PNG) of the CAPTCHA
bankCode string No Code of the service provider to use a specific recognition model. See Service Providers for available options.

Example Request

{
  "image": "iVBORw0KGgoAAAANSUhEUgAAAGQAAA...",
  "bankCode": "XYZ"
}

Response

Success Response (200 OK)

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

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 CAPTCHA solution (use this for reporting incorrect predictions)
data.prediction string The solved text from the CAPTCHA image

Error Response

{
  "isSuccess": false,
  "statusCode": 400,
  "errorMessage": "Invalid image format. Please provide a valid Base64 encoded image.",
  "data": null
}

Error Codes

Status Code Message Description
400 Invalid image format The provided image is not a valid Base64 encoded image
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 on our end

Tips for Best Results

  • Image Quality: Provide the clearest possible image of the CAPTCHA for best accuracy.
  • Cropping: Crop the image to include only the CAPTCHA text, removing any surrounding elements.
  • Provider Code: When possible, specify the provider code to use models optimized for specific CAPTCHA types.
  • Reporting: Report any incorrect predictions to help improve our system over time.

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 TextCaptchaExample
{
    private static readonly HttpClient client = new HttpClient();
    private const string ApiUrl = "/api/captcha";
    private const string ApiKey = "YOUR_API_KEY";

    public static async Task SolveCaptcha(string base64Image, string providerCode = null)
    {
        // Prepare request
        client.DefaultRequestHeaders.Add("x-api-key", ApiKey);

        var payload = new
        {
            image = base64Image,
            providerCode = providerCode
        };

        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
import base64

API_URL = "/api/captcha"
API_KEY = "YOUR_API_KEY"

def solve_captcha(image_path, provider_code=None):
    # Read image and convert to base64
    with open(image_path, "rb") as image_file:
        encoded_image = base64.b64encode(image_file.read()).decode('utf-8')

    # Prepare headers and payload
    headers = {
        "Content-Type": "application/json",
        "x-api-key": API_KEY
    }

    payload = {
        "image": encoded_image
    }

    if provider_code:
        payload["providerCode"] = provider_code

    # 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:
    captcha_text = solve_captcha("captcha.png", "XYZ")
    print(f"CAPTCHA solved: {captcha_text}")
except Exception as e:
    print(str(e))
// CAPTCHA Solving Example

async function solveCaptcha(base64Image, providerCode = null) {
  const API_URL = "/api/captcha";
  const API_KEY = "YOUR_API_KEY";

  // Prepare request
  const payload = {
    image: base64Image
  };

  if (providerCode) {
    payload.providerCode = providerCode;
  }

  // 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 usage
async function handleCaptcha() {
  try {
    // Get base64 image from your application
    const base64Image = 'iVBORw0KGgoAAAANSUhEUgAAAGQAAA...';

    const captchaText = await solveCaptcha(base64Image, 'XYZ');
    console.log(`CAPTCHA solved: ${captchaText}`);

    // Use the solved CAPTCHA in your form
    document.getElementById('captcha-input').value = captchaText;
  } catch (error) {
    console.error(error.message);
  }
}