$0.01 per solve
reCAPTCHA v2
Standard reCAPTCHA v2 with "I'm not a robot" checkbox
Average solve time: 10-15 seconds | Success rate: 99.8%
Overview
reCAPTCHA v2 is Google's most common CAPTCHA type, featuring the familiar "I'm not a robot" checkbox. When clicked, it may present additional challenges like image selection tasks.
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
type | string | Yes | Must be "recaptcha_v2" |
websiteKey | string | Yes | The site key (data-sitekey parameter) |
websiteUrl | string | Yes | Full URL of the page with CAPTCHA |
proxy | object | No | Proxy configuration if required |
userAgent | string | No | Browser user agent string |
Code Examples
# Submit CAPTCHA task
curl -X POST https://api.ai4cap.com/api/captcha/solve \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "recaptcha_v2",
"websiteKey": "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
"websiteUrl": "https://example.com/page-with-captcha"
}'
# Response
{
"success": true,
"taskId": "abc123def456"
}
# Get result
curl -X GET https://api.ai4cap.com/api/captcha/result/abc123def456 \
-H "X-API-Key: YOUR_API_KEY"
# Response when solved
{
"success": true,
"status": "solved",
"solution": {
"gRecaptchaResponse": "03AGdBq24PBCbwiDRaS_MJ7..."
},
"cost": 0.01,
"solveTime": 12500
}
import requests
import time
API_KEY = "YOUR_API_KEY"
API_URL = "https://api.ai4cap.com/api"
def solve_recaptcha_v2(site_key, page_url):
# Submit task
response = requests.post(
f"{API_URL}/captcha/solve",
headers={"X-API-Key": API_KEY},
json={
"type": "recaptcha_v2",
"websiteKey": site_key,
"websiteUrl": page_url
}
)
task_id = response.json()["taskId"]
# Poll for result
for _ in range(30): # Max 60 seconds
result = requests.get(
f"{API_URL}/captcha/result/{task_id}",
headers={"X-API-Key": API_KEY}
)
data = result.json()
if data["status"] == "solved":
return data["solution"]["gRecaptchaResponse"]
elif data["status"] == "failed":
raise Exception(f"Task failed: {data.get('error')}")
time.sleep(2)
raise Exception("Timeout waiting for solution")
# Example usage
solution = solve_recaptcha_v2(
"6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-",
"https://example.com/page-with-captcha"
)
print(f"Solution: {solution}")
const axios = require('axios');
const API_KEY = 'YOUR_API_KEY';
const API_URL = 'https://api.ai4cap.com/api';
async function solveReCaptchaV2(siteKey, pageUrl) {
try {
// Submit task
const submitResponse = await axios.post(
`${API_URL}/captcha/solve`,
{
type: 'recaptcha_v2',
websiteKey: siteKey,
websiteUrl: pageUrl
},
{
headers: { 'X-API-Key': API_KEY }
}
);
const taskId = submitResponse.data.taskId;
// Poll for result
for (let i = 0; i < 30; i++) {
const resultResponse = await axios.get(
`${API_URL}/captcha/result/${taskId}`,
{
headers: { 'X-API-Key': API_KEY }
}
);
const data = resultResponse.data;
if (data.status === 'solved') {
return data.solution.gRecaptchaResponse;
} else if (data.status === 'failed') {
throw new Error(`Task failed: ${data.error || 'Unknown error'}`);
}
// Wait 2 seconds before next check
await new Promise(resolve => setTimeout(resolve, 2000));
}
throw new Error('Timeout waiting for solution');
} catch (error) {
console.error('Error solving CAPTCHA:', error.message);
throw error;
}
}
// Example usage
(async () => {
try {
const solution = await solveReCaptchaV2(
'6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
'https://example.com/page-with-captcha'
);
console.log('Solution:', solution);
} catch (error) {
console.error('Failed:', error.message);
}
})();
<?php
$API_KEY = 'YOUR_API_KEY';
$API_URL = 'https://api.ai4cap.com/api';
function solveReCaptchaV2($siteKey, $pageUrl) {
global $API_KEY, $API_URL;
// Submit task
$ch = curl_init($API_URL . '/captcha/solve');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
'type' => 'recaptcha_v2',
'websiteKey' => $siteKey,
'websiteUrl' => $pageUrl
]));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $API_KEY,
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!$response['success']) {
throw new Exception('Failed to submit task');
}
$taskId = $response['taskId'];
// Poll for result
for ($i = 0; $i < 30; $i++) {
$ch = curl_init($API_URL . '/captcha/result/' . $taskId);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['X-API-Key: ' . $API_KEY]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if ($result['status'] === 'solved') {
return $result['solution']['gRecaptchaResponse'];
} elseif ($result['status'] === 'failed') {
throw new Exception('Task failed: ' . ($result['error'] ?? 'Unknown error'));
}
sleep(2);
}
throw new Exception('Timeout waiting for solution');
}
// Example usage
try {
$solution = solveReCaptchaV2(
'6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
'https://example.com/page-with-captcha'
);
echo "Solution: $solution\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>
Response Format
{
"success": true,
"status": "solved",
"solution": {
"gRecaptchaResponse": "03AGdBq24PBCbwiDRaS_MJ7..." // The token to submit
},
"cost": 0.01,
"solveTime": 12500 // Time in milliseconds
}
Integration Tips
• The gRecaptchaResponse
token should be submitted in your form as g-recaptcha-response
• Tokens are valid for 2 minutes after generation
• Always implement retry logic in case of temporary failures
• Consider using proxy if the target site has geographic restrictions