reCAPTCHA v3
Invisible reCAPTCHA v3 with risk analysis
Overview
reCAPTCHA v3 runs in the background without user interaction. It returns a score (0.0 to 1.0) indicating the likelihood that the user is human. This score-based approach allows you to take variable action based on the risk level.
Request Parameters
Parameter | Type | Required | Description |
---|---|---|---|
type | string | Yes | Must be "recaptcha_v3" |
websiteKey | string | Yes | The site key for v3 |
websiteUrl | string | Yes | Full URL of the page |
action | string | Yes | The action name (e.g., "login", "submit") |
minScore | number | No | Minimum score required (0.1-0.9) |
proxy | object | No | Proxy configuration if required |
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_v3",
"websiteKey": "6LdyC2cUAAAAACGuDKpXeDorzUDWXmdqeg-xy696",
"websiteUrl": "https://example.com",
"action": "verify",
"minScore": 0.7
}'
# Response
{
"success": true,
"taskId": "xyz789abc123"
}
# Get result
curl -X GET https://api.ai4cap.com/api/captcha/result/xyz789abc123 \
-H "X-API-Key: YOUR_API_KEY"
# Response when solved
{
"success": true,
"status": "solved",
"solution": {
"gRecaptchaResponse": "03AGdBq25SxXT2p...",
"score": 0.9
},
"cost": 0.02,
"solveTime": 7500
}
import requests
import time
API_KEY = "YOUR_API_KEY"
API_URL = "https://api.ai4cap.com/api"
def solve_recaptcha_v3(site_key, page_url, action, min_score=0.7):
# Submit task
response = requests.post(
f"{API_URL}/captcha/solve",
headers={"X-API-Key": API_KEY},
json={
"type": "recaptcha_v3",
"websiteKey": site_key,
"websiteUrl": page_url,
"action": action,
"minScore": min_score
}
)
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 {
"token": data["solution"]["gRecaptchaResponse"],
"score": data["solution"]["score"]
}
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_v3(
"6LdyC2cUAAAAACGuDKpXeDorzUDWXmdqeg-xy696",
"https://example.com",
"verify",
min_score=0.7
)
print(f"Token: {solution['token']}")
print(f"Score: {solution['score']}")
const axios = require('axios');
const API_KEY = 'YOUR_API_KEY';
const API_URL = 'https://api.ai4cap.com/api';
async function solveReCaptchaV3(siteKey, pageUrl, action, minScore = 0.7) {
try {
// Submit task
const submitResponse = await axios.post(
`${API_URL}/captcha/solve`,
{
type: 'recaptcha_v3',
websiteKey: siteKey,
websiteUrl: pageUrl,
action: action,
minScore: minScore
},
{
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 {
token: data.solution.gRecaptchaResponse,
score: data.solution.score
};
} else if (data.status === 'failed') {
throw new Error(`Task failed: ${data.error || 'Unknown error'}`);
}
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 solveReCaptchaV3(
'6LdyC2cUAAAAACGuDKpXeDorzUDWXmdqeg-xy696',
'https://example.com',
'verify',
0.7
);
console.log('Token:', solution.token);
console.log('Score:', solution.score);
} catch (error) {
console.error('Failed:', error.message);
}
})();
<?php
$API_KEY = 'YOUR_API_KEY';
$API_URL = 'https://api.ai4cap.com/api';
function solveReCaptchaV3($siteKey, $pageUrl, $action, $minScore = 0.7) {
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_v3',
'websiteKey' => $siteKey,
'websiteUrl' => $pageUrl,
'action' => $action,
'minScore' => $minScore
]));
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 [
'token' => $result['solution']['gRecaptchaResponse'],
'score' => $result['solution']['score']
];
} 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 = solveReCaptchaV3(
'6LdyC2cUAAAAACGuDKpXeDorzUDWXmdqeg-xy696',
'https://example.com',
[
'pageAction' => 'verify',
'minScore' => 0.7
]
);
echo "Token: " . $solution . "\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>
Response Format
{
"success": true,
"status": "solved",
"solution": {
"gRecaptchaResponse": "03AGdBq25SxXT2p...", // The token to submit
"score": 0.9 // The score received from Google
},
"cost": 0.02,
"solveTime": 7500 // Time in milliseconds
}
Understanding pageAction Parameter
The pageAction
parameter is crucial for reCAPTCHA v3. It must match exactly what's used in the website's JavaScript code.
How to find the correct pageAction:
1. Open the website's source code or DevTools
2. Search for grecaptcha.execute
calls
3. Look for the action parameter, for example:
grecaptcha.execute('6LdyC2cUAAAAA...', {action: 'login'})
// In this case, pageAction = "login"
Common pageAction values:
• login
- User login forms
• submit
- General form submissions
• homepage
- Homepage interactions
• checkout
- E-commerce checkout
• register
- User registration
• contact
- Contact forms
• verify
- Verification processes
Important Notes
• The minScore
parameter helps ensure you get a token with sufficient score
• The isSession
parameter returns a sessionToken for advanced use cases
• Scores closer to 1.0 indicate more likely human interaction
• Scores closer to 0.0 indicate more likely bot interaction
• v3 tokens expire faster than v2 tokens (typically 1 minute)
• If pageAction is incorrect, the token will be invalid
Score Interpretation
Score Range | Interpretation | Recommended Action |
---|---|---|
0.7 - 1.0 | Very likely human | Allow action |
0.3 - 0.7 | Uncertain | Additional verification |
0.0 - 0.3 | Very likely bot | Block or challenge |