Migrating from 2captcha
The short version: if you use 2captcha's own PHP client, you change one line. If you use Anti-Captcha's Python client, you cannot change any line, because it has no setting to change. The detail matters, so it is all here.
The legacy surface
Legibl serves /in.php and /res.php as well as the
modern task API. This is not a courtesy. 2captcha's official PHP and
Python clients have no createTask code path at all — they
post form data to in.php and poll res.php, and
nothing else. A gateway offering only the task API would not be a drop-in
replacement however faithfully it implemented it, because the code doing the
calling never makes those calls.
POST /in.php
Form-encoded, exactly as the original. method selects the
captcha type.
key=your-key&method=userrecaptcha&googlekey=6Lc-...&pageurl=https://shop.example.com/checkout
key=your-key&method=userrecaptcha&googlekey=6Lc-...&pageurl=...&invisible=1
key=your-key&method=turnstile&sitekey=0x4...&pageurl=...&action=login&data=cdata
key=your-key&method=base64&body=<base64 image>
Answers OK|<id>, or an ERROR_ string. Add
json=1 for {"status":1,"request":"<id>"}.
Images may also be uploaded as multipart under method=post with
a file part, which is what solver->normal($path)
does. Both forms are accepted; supporting only base64 would support only half
the clients.
GET /res.php
?key=your-key&action=get&id=<id>
?key=your-key&action=getbalance
?key=your-key&action=reportgood&id=<id>
?key=your-key&action=reportbad&id=<id>
A solve in progress answers CAPCHA_NOT_READY — the original's
spelling, misprint included, because every client string-matches it.
getbalance answers a bare number, with no
OK| prefix, unlike every other action. That is not a
simplification we chose: the official client calls float() on
the whole response body, so a prefix raises inside the library rather than
returning a balance. Our own tests asserted the prefix and were wrong until a
real client proved otherwise.
Everything answers HTTP 200
Including errors. The clients never inspect the status line, and a 4xx surfaces as a network exception — the category most retry logic treats as "try again shortly". A rejected key that reads as a network blip is retried forever. Being more correct than the original here would break the caller.
What each client library actually requires
| Client | Speaks | Can be pointed at us? |
|---|---|---|
2captcha/2captcha-php |
in.php / res.php |
Yes — set server to a full URL including the scheme. One line. |
2captcha-python |
in.php / res.php |
Yes — set server to a hostname. The scheme is hardcoded to
https, so the endpoint must be TLS. |
anticaptchaofficial |
task API | No. The URL is hardcoded with no setting to override. See below. |
All three are exercised against a running Legibl on every build, unmodified, including the PHP client on PHP 7.4.33.
If you use Anti-Captcha's Python client
anticaptchaofficial builds every request against
https://api.anti-captcha.com/ written directly into its request
method. There is no host, base-URL or endpoint setting. Nothing to change.
Your options, in the order we would suggest them:
- Use the Legibl SDK. The only one of these that is neither a fork nor a DNS trick, and you get outcome reporting with it.
- Point DNS at us. An internal resolver or hosts entry
mapping
api.anti-captcha.comto Legibl, with a certificate we supply. Works today, and is what our compatibility suite does. It also means the name in your code no longer describes where the traffic goes, which someone will find confusing later. - Fork the client. Two lines, and yours to maintain.
We would rather say this before a cutover than have you discover it during one.
Where we deliberately differ
- Balances are ours, not a vendor's.
getbalancereports your Legibl credit. - Reporting matters more here.
reportgoodandreportbadfeed routing directly. See the API reference. - Both surfaces are one system. A task created on
in.phpcan be polled throughgetTaskResultand the reverse, because the legacy endpoints are a translation over the same code rather than a second implementation. Two implementations of one protocol drift, and the drift is always found by a customer on whichever has fewer tests.