Captcha solving API: token flow or in-page injection?
51 minute ago
Author: admin

Captcha solving API: token flow or in-page injection?

Most services offer two integration patterns, and each one fits a different kind of pipeline. This guide shows how a captcha solving API works and how to choose between the two patterns.

What a captcha solving API does

A captcha solving API takes the data that identifies a challenge and returns a result that the target site will accept. For token-based challenges, such as reCAPTCHA or Cloudflare Turnstile, the result is a token string. Your code submits that token with the form or request that the captcha was protecting.

Challenge types differ a lot. A directory like solvcaptcha.com groups 36 challenge types under six vendor groups: Google, Cloudflare, Arkose Labs, hCaptcha, Geetest and AWS. Before you pick a service, list the challenge types your targets use. A service that is strong on one type may not support another.

Pattern 1: the two-step token API

This is the most common pattern. Your code follows four steps:

  1. Read the sitekey and the page URL from the target page.
  2. Send them to the solver with a createTask request.
  3. Poll getTaskResult until the task is ready.
  4. Submit the token with your own request.

A minimal Python sketch looks like this. The endpoint and field names are placeholders, so check your provider's documentation for the real ones.

import time
import requests

API = "https://solver.example/api"  # placeholder endpoint

def solve(sitekey, page_url, api_key):
    task = requests.post(f"{API}/createTask", json={
        "clientKey": api_key,
        "task": {"type": "TurnstileTask", "websiteKey": sitekey, "websiteURL": page_url},
    }, timeout=30).json()
    for _ in range(30):
        time.sleep(5)
        res = requests.post(f"{API}/getTaskResult", json={
            "clientKey": api_key, "taskId": task["taskId"],
        }, timeout=30).json()
        if res.get("status") == "ready":
            return res["solution"]["token"]
    raise TimeoutError("captcha not solved in time")

It works well with plain HTTP clients. You do not need a browser, so it is cheap to run at scale. The catch is that you must extract the right parameters for each challenge, and that code can break when the target site changes.

Pattern 2: in-page or proxy-style injection

In the second pattern, the solver sits closer to the browser. It can act as a forward proxy or as a browser extension. It spots the challenge in the page and solves it in place, so your script does not handle tokens at all.

It is easier to add to an existing browser automation script, but it needs more infrastructure. You need a browser or a proxy layer in the path, and you have less control over timing and retries.

How to choose

QuestionToken APIIn-page injection
Do you already run a headless browser?Not requiredUsually yes
How much parsing code do you write?MoreLess
How much control over retries?HighLower
Infrastructure overheadLowHigher

If your pipeline uses plain HTTP requests, start with the token API. If you already drive a browser and want fewer code changes, injection may save time.

Pricing models to compare

Services bill in two common ways: pay as you go, or a monthly plan. Pay as you go suits irregular workloads. A monthly plan suits steady, high volume. Compare the cost for your own mix of challenge types, because one price list rarely covers all of them. Comparison sites can help you shortlist, but note that their rankings are editorial catalogs and not live speed tests. Some listings may include affiliate links. Test any shortlisted service with your own targets before you commit.

Test with a real source

Start with open pages when you test the integration. Public websites with open content, such as Indexoid, are a fair example of sources you can use to practice data extraction before you move to protected targets. Check the terms of any site before you collect data from it.

Practical checklist

  • List the challenge types on your targets.
  • Pick the pattern that matches your stack.
  • Set a timeout and a retry limit for polling.
  • Log every failed solve with the task type, so you can see patterns.
  • Never hard-code API keys. Use environment variables.

Discussion

To add a comment, please log in