CAPSOLVER
Blog
How to solve Cloudflare Turnstile Captcha with NodeJS

How to solve Cloudflare Turnstile Captcha with NodeJS

Logo of CapSolver

Ethan Collins

Pattern Recognition Specialist

13-May-2024

Cloudflare Turnstile Overview

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.

Identifying Cloudflare Turnstile 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
    Cloudflare Turnstile Captcha

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

🛠️ Solving cloudflare turnstile captcha

⚙️ Prerequisites

  • NodeJs installed
  • Capsolver API key

🤖 Step 1: Install Necessary Packages

Execute the following commands to install the required packages:

python Copy
npm i axios

👨‍💻 Step 2: NodeJS Code for solve Cloudflare Turnstile Captcha

Here's a Python sample script to accomplish the task:

js Copy
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();

⚠️ Change these variables

  • CAPSOLVER_API_KEY: Obtain your API key from the Capsolver Dashboard.
  • PAGE_URL: Replace with the URL of the website for which you wish to solve the CloudFlare Turnstile Captcha.
  • WEBSITE_KEY: Replace with the site key of the website

What the CloudFlare Turnstile Captcha Looks Like

Cloudflare Turnstile Captcha

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.


🔚 Conclusion

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.


âť“ FAQs

1. What makes Cloudflare Turnstile different from traditional CAPTCHAs?

Turnstile focuses on invisible and frictionless verification without requiring user interaction, offering better UX and improved privacy compared to classic image-based CAPTCHAs.

2. Do I need a proxy to solve Cloudflare Turnstile using Capsolver?

No. The example uses AntiTurnstileTaskProxyLess, meaning proxy isn't required. However, proxies may still help in high-security or high-volume tasks.

3. How do I find the websiteKey for a Turnstile CAPTCHA?

Open the webpage in the browser → Inspect → search for turnstile snippet → the data-sitekey value is your website key.

4. Can this method be used for large-scale scraping or automation?

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.

Compliance Disclaimer: The information provided on this blog is for informational purposes only. CapSolver is committed to compliance with all applicable laws and regulations. The use of the CapSolver network for illegal, fraudulent, or abusive activities is strictly prohibited and will be investigated. Our captcha-solving solutions enhance user experience while ensuring 100% compliance in helping solve captcha difficulties during public data crawling. We encourage responsible use of our services. For more information, please visit our Terms of Service and Privacy Policy.

More

How to Pass Cloudflare Verifying You Are Human Without Getting Stuck
How to Pass Cloudflare Verifying You Are Human Without Getting Stuck

Stuck on "verifying you are human" or "Cloudflare Challenge"? Learn the common causes and discover the technical solutions for automated systems to pass the verification every time.

Cloudflare
Logo of CapSolver

Ethan Collins

19-Jan-2026

How to Solve Cloudflare in 2026: Solve Cloudflare Turnstile and Challenge By Using CapSolver
How to Solve Cloudflare in 2026: Solve Cloudflare Turnstile and Challenge By Using CapSolver

Explore Cloudflare's Challenge and Turnstile CAPTCHA and learn how to bypass them using CapSolver, automated browsers, and high-quality proxies. Includes practical Python and Node.js examples for seamless CAPTCHA solving in automation tasks.

Cloudflare
Logo of CapSolver

Ethan Collins

12-Jan-2026

How to Solve Cloudflare by Using Python and Go in 2026
How to Solve Cloudflare by Using Python and Go in 2026

Will share insights on what Cloudflare Turnstile is, using Python and Go for these tasks, whether Turnstile can detect Python scrapers, and how to effectively it using solutions like CapSolver.

Cloudflare
Logo of CapSolver

Lucas Mitchell

09-Jan-2026

How to Solve Turnstile Captcha: Tools and Techniques in 2026
How to Solve Turnstile Captcha: Tools and Techniques in 2026

Provide you with practical tips and some ways to uncover the secrets of solving turnstile CAPTCHAs efficiently.

Cloudflare
Logo of CapSolver

Sora Fujimoto

09-Jan-2026

How to Bypass Cloudflare Challenge While Web Scraping in 2026
How to Bypass Cloudflare Challenge While Web Scraping in 2026

Learn how to bypass Cloudflare Challenge and Turnstile in 2026 for seamless web scraping. Discover Capsolver integration, TLS fingerprinting tips, and fixes for common errors to avoid CAPTCHA hell. Save time and scale your data extraction.

Cloudflare
Logo of CapSolver

AloĂ­sio VĂ­tor

07-Jan-2026

Cloudflare Challenge vs Turnstile by CapSolver
Cloudflare Challenge vs Turnstile: Key Differences and How to Identify Them

nderstand the key differences between Cloudflare Challenge vs Turnstile and learn how to identify them for successful web automation. Get expert tips and a recommended solver.

Cloudflare
Logo of CapSolver

Lucas Mitchell

10-Dec-2025