hCaptcha Solver API: Automate hCaptcha in Python & Node.js

Complete guide to solving hCaptcha automatically using an API. Includes code examples for Selenium, Playwright, and raw HTTP.

March 16, 2026 · 5 min read

hCaptcha is used by Cloudflare, Discord, Twitter, and thousands of other sites. It presents image selection challenges and is significantly harder to automate than reCAPTCHA v2. This guide covers how to solve it programmatically using the Ocilar API.

What is hCaptcha?

hCaptcha is a CAPTCHA provider that shows users a grid of images and asks them to select specific objects (cars, traffic lights, bicycles). It's privacy-focused and monetizes by using human solves for AI training data.

For automation, you need:

Finding the hCaptcha sitekey

In your browser, right-click the CAPTCHA element → Inspect. Look for:

<div class="h-captcha" data-sitekey="a5f74b19-9e45-40e0-b45d-47ff91b7a6c2"></div>

Solving hCaptcha with Ocilar

cURL

curl -X POST https://api.ocilar.com/api/v1/solve/hcaptcha \
  -H "X-API-Key: sk-your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "sitekey": "a5f74b19-9e45-40e0-b45d-47ff91b7a6c2",
    "url": "https://example.com/register"
  }'

# Response
{"token":"P1_eyJ0...","latency_ms":4100,"credits_used":1}

Python

from ocilar import OcilarClient

client = OcilarClient(api_key="sk-your_key")

result = client.solve_hcaptcha(
    sitekey="a5f74b19-9e45-40e0-b45d-47ff91b7a6c2",
    url="https://example.com/register"
)

print(result.token)  # "P1_eyJ0..."

Node.js

import { OcilarClient } from '@ocilar/sdk'

const client = new OcilarClient({ apiKey: 'sk-your_key' })

const { token } = await client.solveHcaptcha({
  sitekey: 'a5f74b19-9e45-40e0-b45d-47ff91b7a6c2',
  url: 'https://example.com/register'
})

console.log(token) // "P1_eyJ0..."

Submitting the token with Playwright

import asyncio
from playwright.async_api import async_playwright
from ocilar import OcilarClient

async def main():
    client = OcilarClient(api_key="sk-your_key")

    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto("https://example.com/register")

        result = client.solve_hcaptcha(
            sitekey="a5f74b19-...",
            url=page.url
        )

        await page.evaluate(f'''
            document.querySelector('[name="h-captcha-response"]').value = "{result.token}";
            document.querySelector('[name="g-recaptcha-response"]').value = "{result.token}";
        ''')

        await page.click('#submit')
        await browser.close()

asyncio.run(main())

Submitting the token with Selenium

from selenium import webdriver
from selenium.webdriver.common.by import By
from ocilar import OcilarClient

driver = webdriver.Chrome()
client = OcilarClient(api_key="sk-your_key")

driver.get("https://example.com/register")

result = client.solve_hcaptcha(
    sitekey="a5f74b19-...",
    url=driver.current_url
)

driver.execute_script(
    f'document.querySelector("[name=\'h-captcha-response\']").value="{result.token}";'
)
driver.find_element(By.ID, "submit").click()

Pricing

hCaptcha costs $0.16 per 1,000 solves on PAYG — 3× cheaper than most competitors.

ServicehCaptcha / 1KMethod
2Captcha$2.00Human+AI
Anti-Captcha$0.70Human+ML
CapSolver$0.50AI
Ocilar$0.16100% AI

FAQ

How long does hCaptcha take to solve?

Average latency is 3–6 seconds. Tokens are valid for 120 seconds.

Does this work for the hCaptcha Enterprise version?

Yes. Ocilar handles both standard and Enterprise hCaptcha.

Can I use this with Scrapy?

Yes. Call the Ocilar API directly within your Scrapy spider's request handling, inject the token into the form data, and submit. See the full API docs for examples.

Try Ocilar free

1,000 free solves. No credit card required.

Get API Key