API Documentation
Complete reference for the AI4CAP API
Base URL:
https://api.ai4cap.com
API Endpoints
Supported CAPTCHA Types
Type ID | Name | Description | Price | Examples |
---|---|---|---|---|
recaptcha_v2 | reCAPTCHA v2 | Standard reCAPTCHA v2 with "I'm not a robot" checkbox | $0.01 | View Examples → |
recaptcha_v3 | reCAPTCHA v3 | Invisible reCAPTCHA v3 with risk analysis | $0.02 | View Examples → |
recaptcha_enterprise | reCAPTCHA Enterprise | Enterprise-grade reCAPTCHA with advanced security | $0.02 | View Examples → |
recaptcha_mobile | reCAPTCHA Mobile | Mobile application reCAPTCHA integration | $0.016 | View Examples → |
Authentication
API Key Authentication
For CAPTCHA solving endpoints, use your API key in the header:
X-API-Key: your_api_key_here
Bearer Token Authentication
For user-specific endpoints, use your JWT token:
Authorization: Bearer your_jwt_token_here
Keep your API keys secure and never expose them in client-side code.
Code Examples
import requests
import time
# Configuration
API_KEY = "your_api_key_here"
BASE_URL = "https://api.ai4cap.com"
# Submit CAPTCHA task
def solve_captcha(captcha_type, website_key, website_url, additional_data=None):
headers = {"X-API-Key": API_KEY}
data = {
"type": captcha_type,
"websiteKey": website_key,
"websiteUrl": website_url
}
if additional_data:
data["additionalData"] = additional_data
response = requests.post(f"{BASE_URL}/api/captcha/solve",
json=data, headers=headers)
if response.json()["success"]:
task_id = response.json()["taskId"]
return wait_for_result(task_id)
else:
raise Exception("Failed to create task")
# Wait for solution
def wait_for_result(task_id, max_attempts=30):
headers = {"X-API-Key": API_KEY}
for _ in range(max_attempts):
response = requests.get(f"{BASE_URL}/api/captcha/result/{task_id}",
headers=headers)
data = response.json()
if data.get("errorId", 0) != 0:
raise Exception(f"Task failed: {data.get('errorDescription', 'Unknown error')}")
if data["status"] == "ready":
return data["solution"]["gRecaptchaResponse"]
elif data["status"] == "processing":
pass # Continue waiting
time.sleep(2)
raise Exception("Timeout waiting for solution")
# Example usage
solution = solve_captcha("recaptcha_v2", "site_key_here", "https://example.com")
print(f"Solution: {solution}")
# With additional data for enterprise
solution = solve_captcha(
"recaptcha_enterprise",
"site_key_here",
"https://example.com",
{"pageAction": "login", "isInvisible": True}
)
Error Codes
Code | Description | Action |
---|---|---|
400 | Bad Request | Check your request parameters |
401 | Unauthorized | Check your API key or token |
402 | Insufficient Credits | Add credits to your account |
404 | Not Found | Check the endpoint URL |
429 | Too Many Requests | Reduce request frequency |
500 | Internal Server Error | Contact support if persists |
Rate Limits
API rate limits are applied per API key to ensure fair usage:
Endpoint | Limit | Window |
---|---|---|
/api/captcha/solve | 100 requests | 1 minute |
/api/captcha/result/* | 300 requests | 1 minute |
Other endpoints | 60 requests | 1 minute |
Rate limit headers are included in all responses:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200