Developers / SDKs

Python SDK.

Python 3.8+, no dependencies. One file. Give it a page address, get the token.

1. Add the client

Save the client as captora.py next to your script, then set CAPTORA_API_KEY and run it.

captora.py
"""captora.py: zero-dependency Captora client for Python 3.8+ (standard library only)."""import jsonimport timeimport urllib.errorimport urllib.requestBASE_URL = "https://api.captora.me"class CaptoraError(Exception):    passclass Captora:    def __init__(self, api_key, base_url=BASE_URL, poll_seconds=3, timeout_seconds=180):        self.api_key = api_key        self.base_url = base_url        self.poll_seconds = poll_seconds        self.timeout_seconds = timeout_seconds    def _request(self, method, path, body=None):        data = json.dumps(body).encode() if body is not None else None        req = urllib.request.Request(            self.base_url + path,            data=data,            method=method,            headers={                "Authorization": f"Bearer {self.api_key}",                "Content-Type": "application/json",                "User-Agent": "captora-python/1.0",            },        )        try:            with urllib.request.urlopen(req, timeout=60) as res:                return json.load(res)        except urllib.error.HTTPError as e:            try:                detail = json.load(e).get("error")            except Exception:                detail = None            raise CaptoraError(f"Captora error {e.code}: {detail or 'unknown'}") from None    def balance(self):        """Returns {'balance_paise': ...} (100 paise = ₹1)."""        return self._request("GET", "/v1/balance")    def solve_url(self, website_url, **extra):        """The simple way: give the address of a page with a captcha. Captora recognises the captcha, solves it,        and returns its result (usually {'token': ...}). Pass html=<page source> for pages that add the captcha        with JavaScript or need a login. Raises CaptoraError if it can't be solved (you are not charged)."""        return self._wait(self._request("POST", "/v1/solve", {"websiteURL": website_url, **extra}))    def solve(self, captcha_type, **params):        """Advanced: you already know the captcha type. Waits for the task and returns its `result` dict."""        return self._wait(self._request("POST", "/v1/tasks", {"type": captcha_type, **params}))    def _wait(self, task):        deadline = time.time() + self.timeout_seconds        while task["status"] == "processing" and time.time() < deadline:            time.sleep(self.poll_seconds)            task = self._request("GET", f"/v1/tasks/{task['taskId']}")        if task["status"] == "completed":            return task["result"]        raise CaptoraError("Could not be solved (refunded)" if task["status"] == "failed" else "Timed out")

2. Solve a captcha with one call

Put your API key in the CAPTORA_API_KEY environment variable (create one in your dashboard).

example.py
import osfrom captora import Captoracaptora = Captora(os.environ["CAPTORA_API_KEY"])# Give it the page with the captcha. Captora finds the captcha and solves it.result = captora.solve_url("https://example.com/login")print(result["token"])  # submit this token with your form# Know the type already? captora.solve("recaptcha_v2", websiteURL=..., websiteKey=...)

3. That's it. No captcha type to pick

Captora recognises the captcha on the page. For pages that add it with JavaScript or sit behind a login, pass the page's HTML as well (see the docs). If you already know the type, the client has a second method for that. Every captcha we support, and its price, is on the captchas page.

Keep in mind

  • Keep your API key on your server. Never ship it in a browser or mobile app.
  • Solving can take from a few seconds to a minute or more, so run it in the background of your app.
  • Unsolved tasks raise an error and are refunded automatically.

Build once.
Connect with flexibility.