
Ethan Collins
Pattern Recognition Specialist

Cloudflare Turnstile offers a free solution for replacing traditional CAPTCHAs, providing a hassle-free web experience through a simple code snippet. It ensures that visitors are genuine and prevents abuse without the data privacy issues or poor user experience associated with conventional CAPTCHAs.
Non-Interactive Challenge: The process runs without user interaction. Example: Non-Interactive Test

Minimal Interactive Challenge: This may involve simple actions like clicking a button if the system suspects the visitor might be a bot. Example: Managed Test

Invisible Challenge: The challenge operates unseen, loading discreetly within the HTML of the webpage. Example: Invisible Test

Execute the following commands to install the required packages:
npm i axios
Here's a Python sample script to accomplish the task:
const axios = require('axios');
const CAPSOLVER_API_KEY = "your api key";
const PAGE_URL = "site ";
const WEBSITE_KEY = "site key";
function solvecf(metadata_action = null, metadata_cdata = null) {
const url = "https://api.capsolver.com/createTask";
const task = {
type: "AntiTurnstileTaskProxyLess",
websiteURL: PAGE_URL,
websiteKey: WEBSITE_KEY,
};
if (metadata_action || metadata_cdata) {
task.metadata = {};
if (metadata_action) {
task.metadata.action = metadata_action;
}
if (metadata_cdata) {
task.metadata.cdata = metadata_cdata;
}
}
const data = {
clientKey: CAPSOLVER_API_KEY,
task: task
};
return axios.post(url, data)
.then(response => {
console.log(response.data);
return response.data.taskId;
});
}
function solutionGet(taskId) {
const url = "https://api.capsolver.com/getTaskResult";
let status = "";
const checkStatus = () => {
const data = { clientKey: CAPSOLVER_API_KEY, taskId: taskId };
return axios.post(url, data)
.then(response => {
console.log(response.data);
status = response.data.status || "";
console.log(status);
if (status === "ready") {
return response.data.solution;
}
return new Promise(resolve => setTimeout(resolve, 2000)).then(checkStatus);
});
};
return checkStatus();
}
async function main() {
try {
const taskId = await solvecf();
const solution = await solutionGet(taskId);
if (solution) {
const user_agent = solution.userAgent;
const token = solution.token;
console.log("User_Agent:", user_agent);
console.log("Solved Turnstile Captcha, token:", token);
}
} catch (error) {
console.error("Error in CAPSOLVER API interaction:", error);
}
}
main();

Meanwhile, if you'd like to test your scripts for bot characteristics, BrowserScan's Bot Detection tool can help you identify and refine bot-like behavior in your scripts.
Cloudflare Turnstile offers a lightweight, privacy-friendly alternative to traditional CAPTCHAs, improving user experience while effectively filtering out automated traffic. With tools like Capsolver, developers can programmatically bypass Turnstile challenges for testing, scraping, or automation scenarios. By following the steps above and configuring API parameters correctly, you can quickly integrate Turnstile solving into your workflow and streamline automated requests with ease.
Turnstile focuses on invisible and frictionless verification without requiring user interaction, offering better UX and improved privacy compared to classic image-based CAPTCHAs.
No. The example uses AntiTurnstileTaskProxyLess, meaning proxy isn't required. However, proxies may still help in high-security or high-volume tasks.
websiteKey for a Turnstile CAPTCHA?Open the webpage in the browser β Inspect β search for turnstile snippet β the data-sitekey value is your website key.
Yes, but ensure your usage complies with the websiteβs terms of service. For large volumes, handling delays, rotating user-agents, and using proper request patterns is recommended.
Learn how to fix the "failed to verify cloudflare turnstile token" error. This guide covers causes, troubleshooting steps, and how to defeat cloudflare turnstile with CapSolver.

Discover the best cloudflare challenge solver tools, compare API vs. manual automation, and find optimal solutions for your web scraping and automation needs. Learn why CapSolver is a top choice.
