Skip to content
CaptchaSonic Docs

AWS Waf

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

import requests


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

    data = {
        "apiKey": "sonic_xxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "task": {
        "type": "AwsWafImage",
        "websiteURL": "https://your-website.com",
        "queries": [
        "iVBORw0KGgoAAAANSUhEUgAAASwAAADICAIAAADdvUsCAAAgAElEQVR4AezBCZRd9X0n...."
        ],
        "question": "aws:grid:chair"
    }

    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_awswaf_result()
  if result:
      print("Response:", result)