Skip to content
CaptchaSonic Docs

Popular Captcha

This is a helper code, you can just copy and paste and run.

import requests

def fetch_recaptchaV2_result():
    url = "https://api.example.com/ocr"  # Replace with the actual API endpoint
    headers = {"Content-Type": "application/json"}

    data = {
      "apiKey": "sonic_xxxxxxxxxxxxxxxxxxxxxxxxxxx",
      "task": {
      "type": "PopularClassification",
      "queries": [
        "image1_base64",
        "image2_base64"
      ],
      "question": "Please click, hold, and drag all the missing pieces to complete the image.",
      "questionType": "objectClick",
      "examples": [
        "example1_base64",
        "example2_base64"
      ],
      "websiteURL": "https://your-website.com",
      "websiteKEY": "website-key",
      "choices": []
      }
    }

    try:
        response = requests.post(url, json=data, headers=headers)
        response.raise_for_status()  # Raise an error for HTTP error responses 
        (4xx, 5xx)
        return response.json()  # Return JSON response
    except requests.exceptions.RequestException as e:
        print(f"Error fetching OCR result: {e}")
        return None

  # Example usage:
  result = fetch_recaptchaV2_result()
  if result:
      print("Response:", result)