This example sends a Turnstile task and reads the solved token from the response.
Get an API key
Create or copy a key from the uncaptcha.io dashboard. Keep it on your server and load it through an environment variable.
Collect the challenge data
Find the target page URL and Turnstile sitekey. If the widget supplies an
action or cData, send those values too.
Execute the task
Send the task to POST /v1/task/execute.
curl --request POST \
--url https://api.uncaptcha.io/v1/task/execute \
--header "Content-Type: application/json" \
--header "X-Api-Key: $UNCAPTCHA_API_KEY" \
--data '{
"task_type": "turnstile",
"task_data": {
"url": "https://example.com/",
"sitekey": "0x4AAAAAABs37s-ih7Jepz0J",
"proxy": "http://user:[email protected]:8080"
}
}'import os
import requests
response = requests.post(
"https://api.uncaptcha.io/v1/task/execute",
headers={"X-Api-Key": os.environ["UNCAPTCHA_API_KEY"]},
json={
"task_type": "turnstile",
"task_data": {
"url": "https://example.com/",
"sitekey": "0x4AAAAAABs37s-ih7Jepz0J",
"proxy": "http://user:[email protected]:8080",
},
},
timeout=35,
)
response.raise_for_status()
token = response.json()["data"]["solution"]["token"]const response = await fetch(
"https://api.uncaptcha.io/v1/task/execute",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Api-Key": process.env.UNCAPTCHA_API_KEY,
},
body: JSON.stringify({
task_type: "turnstile",
task_data: {
url: "https://example.com/",
sitekey: "0x4AAAAAABs37s-ih7Jepz0J",
proxy: "http://user:[email protected]:8080",
},
}),
signal: AbortSignal.timeout(35_000),
},
);
if (!response.ok) throw new Error(await response.text());
const token = (await response.json()).data.solution.token;payload := strings.NewReader(`{
"task_type": "turnstile",
"task_data": {
"url": "https://example.com/",
"sitekey": "0x4AAAAAABs37s-ih7Jepz0J",
"proxy": "http://user:[email protected]:8080"
}
}`)
req, err := http.NewRequest(
http.MethodPost,
"https://api.uncaptcha.io/v1/task/execute",
payload,
)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Api-Key", os.Getenv("UNCAPTCHA_API_KEY"))
client := &http.Client{Timeout: 35 * time.Second}
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()Successful response
{
"success": true,
"data": {
"solution": {
"token": "0.AuR5g8kP..."
}
}
}Use data.solution.token wherever the target flow expects the Turnstile
response.