Developer GuideAnti-Bot Evasion

How to Bypass & Solve DataDome Captcha in Python

DataDome is one of the strictest cybersecurity solutions guarding luxury retail, ticketing portals, and travel aggregators. This engineering tutorial explains DataDome device verification mechanics and demonstrates how to resolve interstitial puzzle challenges using Python, Playwright, and the 2Captcha API.

1. How DataDome Bot Detection Operates

DataDome combines client-side JavaScript fingerprinting with server-side behavioral heuristics. When a browser initiates a connection, DataDome analyzes TCP/IP window sizes, TLS Client Hellos, Canvas/WebGL rendering hashes, and mouse motion paths.

If abnormal automation velocity or datacenter IP addresses are detected, DataDome serves an HTTP 403 Forbidden response with an embedded interstitial iframe hosted at geo.captcha-delivery.com. The user must solve an interactive jigsaw slider to receive an authenticated datadome cookie.

2. Critical Rule: Matching Residential Proxy Binding

Important Architecture Requirement:

DataDome strictly hashes the client IP address into the challenge token. You must pass the exact same residential proxy to the 2Captcha solving API that your Playwright script used to navigate the target website. Solving through a different IP address will result in an immediate token rejection.

3. Installing Required Dependencies

Install the official 2captcha-python library and playwright:

pip install 2captcha-python playwright
playwright install chromium

4. Basic DataDome Task Dispatch in Python

The TwoCaptcha SDK provides a dedicated datadome() method that accepts the captcha iframe URL, target page URL, User-Agent, and your residential proxy credentials:

import os
from twocaptcha import TwoCaptcha

api_key = os.getenv("TWOCAPTCHA_API_KEY")
solver = TwoCaptcha(api_key)

try:
    print("Dispatching DataDome slider challenge to 2Captcha...")
    # Note: DataDome strictly requires solving through the exact same proxy IP
    result = solver.datadome(
        captcha_url="https://geo.captcha-delivery.com/captcha/?initialCid=...",
        pageurl="https://target-portal.com/protected-page",
        useragent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
        proxy={
            "type": "HTTPS",
            "uri": "username:[email protected]:4328"
        }
    )
    # Returns the valid 'datadome' cookie value
    datadome_cookie = result["code"]
    print("DataDome solved successfully!")
    print(f"DataDome Cookie: {datadome_cookie[:40]}...")
except Exception as e:
    print(f"DataDome solver error: {e}")

5. Complete Playwright Pipeline with Cookie Injection

In automated scraping pipelines, your script detects when DataDome triggers an interstitial challenge, captures the challenge URL, dispatches the task to 2Captcha, and injects the resulting cookie back into the Playwright browser context:

import asyncio
import os
from playwright.async_api import async_playwright
from twocaptcha import TwoCaptcha

API_KEY = os.getenv("TWOCAPTCHA_API_KEY")
solver = TwoCaptcha(API_KEY)

TARGET_URL = "https://example-datadome-protected.com/catalog"
PROXY_URI = "username:[email protected]:4328"
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"

async def main():
    proxy_parts = PROXY_URI.split("@")
    credentials, server = proxy_parts[0], proxy_parts[1]
    username, password = credentials.split(":")

    async with async_playwright() as p:
        browser = await p.chromium.launch(
            headless=True,
            proxy={
                "server": "http://" + server,
                "username": username,
                "password": password
            }
        )
        context = await browser.new_context(user_agent=USER_AGENT)
        page = await context.new_page()

        print("Navigating to DataDome protected endpoint...")
        response = await page.goto(TARGET_URL)

        # Check if DataDome blocked the request (HTTP 403 or captcha-delivery iframe)
        content = await page.content()
        if response.status == 403 or "captcha-delivery.com" in content:
            print("DataDome challenge detected! Extracting challenge URL...")
            
            # Find the DataDome iframe src URL
            iframe_el = await page.query_selector("iframe[src*='captcha-delivery.com']")
            captcha_url = await iframe_el.get_attribute("src") if iframe_el else page.url
            print("Challenge URL: " + captcha_url[:60] + "...")

            print("Dispatching task to 2Captcha API...")
            result = solver.datadome(
                captcha_url=captcha_url,
                pageurl=TARGET_URL,
                useragent=USER_AGENT,
                proxy={
                    "type": "HTTP",
                    "uri": PROXY_URI
                }
            )
            token = result["code"]
            print("Solution received! Injecting datadome cookie into session...")

            # Inject the solved DataDome cookie into the Playwright context
            await context.add_cookies([{
                "name": "datadome",
                "value": token,
                "domain": "example-datadome-protected.com",
                "path": "/"
            }])

            print("Reloading page with validated session token...")
            response = await page.goto(TARGET_URL, wait_until="networkidle")
            print("Bypass successful! Status: " + str(response.status))

        title = await page.title()
        print("Page Title: " + title)
        await browser.close()

if __name__ == "__main__":
    asyncio.run(main())

6. Why 2Captcha is Rated #1 for DataDome Resolution

2Captcha DataDome Telemetry

Rank #1 DataDome Solver
  • Average Solving Speed: 6.8 seconds (automated puzzle slider positioning)
  • First-Attempt Pass Rate: 99.2% on live DataDome endpoints
  • Proxy Support: Full HTTP, HTTPS, and SOCKS5 proxy tunneling
  • Transparent Pricing: $1.50 per 1,000 solves, strictly pay-as-you-go
Get 2Captcha API Key ($1.50/1k) →

Need Clean Residential Proxies for DataDome?

DataDome binds challenge cookies to client IP reputation. Explore verified residential proxy benchmarks and ASN pricing on 2-Proxy.com.