Cloudflare Turnstile Token Solving
Solve Cloudflare Turnstile captcha challenges. Turnstile is Cloudflare's invisible bot detection system, designed as a privacy-friendly alternative to traditional captchas.
Cloudflare Turnstile is a modern captcha system designed to be invisible to humans while blocking bots. Unlike traditional captchas, Turnstile works in the background and doesn't require user interaction in most cases. It analyzes user behavior and provides a token that websites can use to verify legitimate traffic.
Captcha Type
"type": "CLOUDFLARE_TURNSTILE_TOKEN"
Request Format
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
captcha.type |
string | required | Must be "CLOUDFLARE_TURNSTILE_TOKEN" |
captcha.metadata.siteUrl |
string | required | URL where Turnstile appears |
captcha.metadata.siteKey |
string | required | Turnstile site key (data-sitekey) |
captcha.payload.proxy |
object | optional | Proxy configuration object |
captcha.payload.proxy.protocol |
string | required* | Proxy protocol: "http", "https", "socks4", "socks5" |
captcha.payload.proxy.host |
string | required* | Proxy IP address |
captcha.payload.proxy.port |
number | required* | Proxy port number |
captcha.payload.proxy.username |
string | optional | Proxy authentication username |
captcha.payload.proxy.password |
string | optional | Proxy authentication password |
* Required only if proxy object is provided
Example Request
const response = await fetch('https://solver-api.mydisct.com/createTask', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apikey': 'YOUR_API_KEY'
},
body: JSON.stringify({
auth: { token: 'YOUR_API_KEY' },
context: { source: 'api', version: '1.0.0' },
captcha: {
type: 'CLOUDFLARE_TURNSTILE_TOKEN',
metadata: {
siteUrl: 'https://example.com',
siteKey: '0x4AAAAAAADnPIDROrmt1Wwj'
},
payload: {
proxy: {
protocol: 'http',
host: '1.2.3.4',
port: 8080,
username: 'proxyuser',
password: 'proxypass'
}
}
}
})
});
const data = await response.json();
console.log('Task ID:', data.task.id);
Response Format
Create Task Response
{
"success": true,
"service": "MyDisct Solver",
"message": "Captcha is being processed",
"task": {
"id": "MyDisctSolver_abc123",
"status": "processing"
}
}
Fetch Result Response (Processing)
{
"success": true,
"service": "MyDisct Solver",
"message": "Captcha is being processed",
"task": {
"id": "MyDisctSolver_abc123",
"status": "processing"
}
}
Fetch Result Response (Completed)
{
"success": true,
"service": "MyDisct Solver",
"message": "Captcha solved successfully",
"task": {
"id": "MyDisctSolver_abc123",
"status": "completed",
"result": {
"token": "0.Bw4AAAAAADnPIDROrmt1Wwj...",
"timestamp": "2025-11-05T12:34:56.789Z"
}
}
}
Submit the token in the cf-turnstile-response form field.
Implementation Example
async function solveTurnstile(siteUrl, siteKey, apiKey) {
const createResponse = await fetch('https://solver-api.mydisct.com/createTask', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apikey': apiKey
},
body: JSON.stringify({
auth: { token: apiKey },
context: { source: 'api', version: '1.0.0' },
captcha: {
type: 'CLOUDFLARE_TURNSTILE_TOKEN',
metadata: { siteUrl, siteKey },
payload: {}
}
})
});
const createData = await createResponse.json();
if (!createData.success) throw new Error(createData.error.message);
const taskId = createData.task.id;
while (true) {
await new Promise(resolve => setTimeout(resolve, 5000));
const resultResponse = await fetch('https://solver-api.mydisct.com/fetchResult', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'apikey': apiKey
},
body: JSON.stringify({ taskId })
});
const resultData = await resultResponse.json();
if (resultData.task.status === 'completed') {
return resultData.task.result.token;
} else if (resultData.task.status === 'failed') {
throw new Error('Token solving failed');
}
}
}
const token = await solveTurnstile(
'https://example.com',
'0x4AAAAAAADnPIDROrmt1Wwj',
'YOUR_API_KEY'
);
const formData = new FormData();
formData.append('cf-turnstile-response', token);
await fetch('https://example.com/submit', {
method: 'POST',
body: formData
});
Python Example
import requests
import time
def solve_turnstile(site_url, site_key, api_key):
create_response = requests.post(
'https://solver-api.mydisct.com/createTask',
headers={'Content-Type': 'application/json', 'apikey': api_key},
json={
'auth': {'token': api_key},
'context': {'source': 'api', 'version': '1.0.0'},
'captcha': {
'type': 'CLOUDFLARE_TURNSTILE_TOKEN',
'metadata': {
'siteUrl': site_url,
'siteKey': site_key
},
'payload': {}
}
}
)
create_data = create_response.json()
if not create_data['success']:
raise Exception(create_data['error']['message'])
task_id = create_data['task']['id']
while True:
time.sleep(5)
result_response = requests.post(
'https://solver-api.mydisct.com/fetchResult',
headers={'Content-Type': 'application/json', 'apikey': api_key},
json={'taskId': task_id}
)
result_data = result_response.json()
if result_data['task']['status'] == 'completed':
return result_data['task']['result']['token']
elif result_data['task']['status'] == 'failed':
raise Exception('Token solving failed')
# Usage
token = solve_turnstile(
site_url='https://example.com',
site_key='0x4AAAAAAADnPIDROrmt1Wwj',
api_key='YOUR_API_KEY'
)
response = requests.post(
'https://example.com/submit',
data={'cf-turnstile-response': token}
)
print(f'Status: {response.status_code}')
Finding Site Key
The Turnstile site key can be found in the HTML:
<div class="cf-turnstile" data-sitekey="0x4AAAAAAADnPIDROrmt1Wwj"></div>
Or in JavaScript:
const siteKey = document.querySelector('[data-sitekey]')?.getAttribute('data-sitekey');
console.log('Site Key:', siteKey);
Best Practices
- Turnstile tokens typically solve in 5-10 seconds
- Tokens expire after 5 minutes
- Use exact page URL where Turnstile widget appears
- Site key starts with "0x4" for most implementations
- Turnstile is invisible - no user interaction required
Common Issues
Solution: Ensure you are using the correct site key and site URL. The site URL must be the exact page where the widget is loaded.
Solution: Cloudflare is sensitive to IP reputation. Use high-quality residential proxies if you are encountering issues with token acceptance.