Captcha solver SDK: why two HTTP calls are enough

A captcha solver SDK is a library that wraps the calls of a solver API in a few functions. ilovecaptcha publishes no such package: its API takes two HTTPS calls with a JSON body, createTask then getTaskResult, and each language page of this site gives the complete client in one file. This page shows what that file does and how to use it in place of an SDK.

Updated on · Written and maintained by the ilovecaptcha team

Preview: the API described here is in public beta. Endpoint names, fields and codes can still change until the end of the beta, and no API key is distributed yet.

Is there an ilovecaptcha SDK to install?

No. There is no package on pip, npm or any other registry. The client is short enough to live in your project: one file per language, from 36 lines in Ruby to 188 in C, written wherever possible with what the language already provides for HTTP and JSON. You copy it, set the key and the address of the API, and call its solve function.

What would an SDK do that the examples do not?

Nothing in the calls themselves. An SDK for this kind of API does four jobs, and each example already does them in a few lines.

What an SDK does, and where the example does it
Job of an SDK In the example
Add the key to each request The request helper adds clientKey to the body
Wait between two polls The loop waits 1.5 seconds
Stop after a deadline The loop gives up after 120 seconds
Report the errors of the API An error is raised when errorId is not 0

What are the two calls of the API?

Both are POST requests with a JSON body that carries the key under clientKey. A reply whose errorId is not 0 is an error, described by errorCode and errorDescription.

  1. createTask receives task, an object with the type of the captcha and its fields, such as image in base64. The reply holds taskId, or the solution at once when status is ready.
  2. getTaskResult receives taskId. Call it again after a short wait until status is ready, then read solution.

Which language example should you start from?

The one your project is written in: thirteen languages have their page, each with the complete file. If yours is missing, any of them can be ported, since the logic is one helper and one loop.

The client file of each language
Language File and length
Python solve.py (44 lines)
JavaScript solve.mjs (43 lines)
Node.js solve.js (40 lines)
PHP solve.php (58 lines)
Go solve.go (98 lines)
Java Solve.java (75 lines)
C solve.c (188 lines)
C++ solve.cpp (99 lines)
C# Program.cs (45 lines)
Visual Basic Program.vb (51 lines)
Ruby solve.rb (36 lines)
Perl solve.pl (50 lines)
AutoIt solve.au3 (80 lines)

Captcha solver SDK: frequently asked questions

Do I need an SDK to use the ilovecaptcha API?

No. The API is plain HTTPS with a JSON body: two routes, createTask and getTaskResult, and a key sent in the body. Any language that can send a POST request and parse JSON can call it. The language pages of this site give that code in full, as one file to copy, so there is no dependency to add, no version to follow and nothing hidden between your program and the API.

How do I turn an example into a reusable module?

Keep the request helper and the solve function, and remove the last lines, which read captcha.png and print the solution. Read the key and the address of the API from the environment instead of the two constants, then import the file from the rest of your code. In Python, for instance, the module then exposes solve, which takes the task as a dictionary and returns the solution.

Which settings should a client expose?

Three are enough: the wait between two polls, the deadline and the timeout of each HTTP request. The examples wait 1.5 seconds between two polls and stop after 120 seconds; the Python client gives each request 30 seconds. A shorter wait only adds requests, since a task is not ready sooner because it is polled more often.

Is there an SDK for Selenium, Puppeteer or Playwright?

No package either, and for the same reason: the pages for these three tools give complete scripts. Each one captures the challenge element with a screenshot, calls the same two routes, then clicks the returned points or drags a slider with the mouse API of the tool. The solver part is the same helper and the same loop as in the plain language examples.

Sources

The facts and figures quoted on this page come from these sources.