← nocaptchaai.comDocs
    DocsChangelog

    Get Started

    Start Here
    QuickstartAuthenticationError Codes
    Browser Extension

    Captcha Types

    Token Tasks
    Cloudflare Turnstile Task
    Image Tasks
    ReCaptcha v2GeeTest V4ImageToTextBLS CaptchaBinanceAWS WAFTikTokDB-betMTCaptchaTencentProSOPO

    API Reference

    Overview
    Solver
    Create async captcha solving taskPoll task result (GET)Poll task resultSolve captchaGet response statusCollect endpoint (reserved)Report accuracy feedbackGet accuracy report
    Balance
    Check balance & plan infoLegacy balance formatList all error codes
    System
    Health check

    SDKs

    OverviewPythonJavaScript / Node.jsGo

    Agents

    OverviewModel Context Protocol (MCP)Claude CodeOpenAI CodexCursorClineOpenClaw

    Guides

    Browser ExtensionError HandlingChoosing a Task Type
    ← nocaptchaai.com
    Get API key
    Sign inGet API key

    Python

    Solve captchas from Python.

    Loading…

    PreviousSDKs & Code SamplesNextJavaScript / Node.js
    [ ] Docs[ ] Extension[ ] Pricing[ ] Changelog[ ] Partners[ ] Terms[ ] Privacy[ ] Cookies[ ] Refunds[ ] Contact

    Spicrawl

    Free web scraping API for AI agents.

    spicrawl.com

    Spicrawl

    © 2026 NoCaptchaAI

    The helper below uses the requests library. It submits a task with POST /createTask, polls POST /getTaskResult on a fixed interval until the status is ready, and raises a RuntimeError if the API reports an error or the timeout is exceeded. The example solves a Cloudflare Turnstile challenge.

    Keep your key out of source control

    Read the API key from an environment variable rather than hardcoding it. Set it once with export NOCAPTCHAAI_KEY="your-key" (get one at nocaptchaai.com/app/api-keys).

    python
    import os
    import time
    
    import requests
    
    BASE_URL = "https://api.nocaptchaai.com"
    API_KEY = os.environ["NOCAPTCHAAI_KEY"]
    
    
    def solve(task: dict, *, poll_interval: float = 3.0, timeout: float = 120.0) -> dict:
        """Create a task, poll until it is ready, and return the solution.
    
        Raises RuntimeError on an API error or if the timeout is reached.
        """
        created = requests.post(
            f"{BASE_URL}/createTask",
            json={"clientKey": API_KEY, "task": task},
            timeout=30,
        ).json()
    
        if created.get("errorId"):
            raise RuntimeError(f"createTask failed: {created}")
    
        task_id = created["taskId"]
        deadline = time.monotonic() + timeout
    
        while True:
            result = requests.post(
                f"{BASE_URL}/getTaskResult",
                json={"clientKey": API_KEY, "taskId": task_id},
                timeout=30,
            ).json()
    
            status = result.get("status")
            if status == "ready":
                return result["solution"]
            if status == "failed" or result.get("errorId"):
                raise RuntimeError(f"task failed: {result}")
    
            if time.monotonic() >= deadline:
                raise RuntimeError(f"timed out after {timeout}s waiting for task {task_id}")
    
            time.sleep(poll_interval)
    
    
    if __name__ == "__main__":
        solution = solve(
            {
                "type": "AntiTurnstileTask",
                "websiteURL": "https://example.com",
                "websiteKey": "0x4AAAAAAA...",
            }
        )
        print(solution)
    

    Call solve() with any task object — swap the type, websiteURL, and websiteKey for the captcha you need to solve. The returned solution dict contains the token (and any other fields) you submit back to the target site.