Support for reCAPTCHA by
Token API (recaptcha v2 & v3)!NEW
Support for legacy/outdated reCAPTCHA solving via Coordinates or Image Group
ImagesToText also supports DeCaptcher API (both socket and HTTP), Antigate (Anti-Captcha) and 2captcha API!
ImagesToText API
Latest version: 4.6
- .NET (C#, Visual Basic)
- AutoIt3
- iMacros
- C (client and libs' source code)
- Java
- Perl 5+
- PHP v5+
- Python v2.5+ and v3.0+
- Node.js v8.12.0+
- Command-line tool for Windows, Linux (i386 and x86-64) (see usage note below)
How to use our API clients
Download the latest client, add it to your application and write something along the lines below, f.i in PHP:
require_once 'imagestotext.php';
// Put your ITT credentials here.
// Use ImagesToText_HttpClient class if you want to use HTTP API.
$client = new ImagesToText_SocketClient(USERNAME, PASSWORD);
// Put the CAPTCHA file name or handler, and desired timeout (in seconds) here:
if ($captcha = $client->decode(CAPTCHA_FILE_NAME, TIMEOUT)) {
echo $captcha['text'] . "\n";
// Report the CAPTCHA if solved incorrectly.
// Make sure the CAPTCHA was in fact incorrectly solved!
if ( ... ) {
$client->report($captcha['captcha']);
}
}
// Repeat for other CAPTCHAs
…or in C#:
// Do not forget to reference ImagesToText.dll in your project!
using ImagesToText;
// Put your ITT credentials here.
// Use HttpClient class if you want to use HTTP API.
Client client = (Client) new SocketClient(USERNAME, PASSWORD);
// Put your CAPTCHA file name, stream, or vector of bytes,
// and desired timeout (in seconds) here:
Captcha captcha = client.Decode(CAPTCHA_FILE_NAME, TIMEOUT);
if (captcha.Solved && captcha.Correct) {
Console.WriteLine("CAPTCHA {0}: {1}", captcha.Id, captcha.Text);
// Report the CAPTCHA if solved incorrectly.
// Make sure the CAPTCHA was in fact incorrectly solved!
if ( ... ) {
client.Report(captcha);
}
}
// Repeat for other CAPTCHAs
When using socket API clients, make sure you don't have outgoing TCP connections to ports 8123–8130 firewalled. Use HTTP API clients if socket API clients do not work for you. The 8123–8130 ports range is for socket API only, do not try to use it with HTTP API!
Note that a call to the decode function/method can return a null value if timeout is reached before the CAPTCHA is solved. If this happens often, increase the timeout used.
For more details see examples included in each API client package and check the clients' source code.
How to use our command-line tool
- To check your balance, run:
ittclient.exe -l USERNAME -p PASSWORD -b
Your balance will be saved inbalance.txtfile and printed out on the standard output. - To upload a CAPTCHA, run:
ittclient.exe -l USERNAME -p PASSWORD -c CAPTCHA_FILE_NAME [-t TIMEOUT]
Default CAPTCHA solving timeout is 60 seconds.
If solved, the CAPTCHA ID will be saved inid.txt, the CAPTCHA text will be saved inanswer.txt, and both ID and text will be printed out on the standard output separated by a space. - To report an incorrectly solved CAPTCHA, run:
ittclient.exe -l USERNAME -p PASSWORD -n CAPTCHA_ID
HTTP API technical details
Before implementing your own ImagesToText HTTP API client, please seriously consider using socket API with one of our official clients listed above.
Through our API, it is possible to:
- Upload a CAPTCHA
- Poll for an uploaded CAPTCHA
- Report incorrectly solved CAPTCHA
- Check credit balance
- Check server status
The API url is http://api.imagestotext.com/api/. The
URL path changes depending on the action desired. All responses from requests made to the API have two
common fields:
status— request status. 0 if there were no errors during internal request processing, 255 otherwise.error— short explanation of the occurred error. Only returned when status is 255.
For details about correct URL path and other returned fields for a specific action, refer to its section below.
All API responses are returned
URL-encoded by default. If
JSON encoding is desired, include application/json
in the
Accept
header of your request. Note that boolean true will be returned as 1 in URL-encoded responses
and as true in JSON-encoded responses.
Boolean false will be returned as 0 in URL-encoded responses and as false in JSON-encoded
responses.
1. Uploading a CAPTCHA
To upload a CAPTCHA, issue a multipart/form-data POST request to
http://api.imagestotext.com/api/captcha. The request must contain the following fields:
username— your ImagesToText username.password— your ImagesToText password.captchafile— the CAPTCHA image.
captchafile should be either raw CAPTCHA image file, or base64-encoded CAPTCHA
image prepended with base64: prefix.
Image file size is limited to less than 180 KB. When the image will be encoded in base64, the size
should be lower than 120 KB.
The supported image formats are JPG, PNG, GIF and BMP.
Here is the HTML form that does the trick:
<form action="http://api.imagestotext.com/api/captcha"
method="post"
enctype="multipart/form-data">
<input type="text" name="username" value="">
<input type="password" name="password" value="">
<input type="file" name="captchafile">
</form>
Here is cURL command equivalent:
curl --header 'Expect: ' -F username=YOUR_USERNAME \
-F password=YOUR_PASSWORD \
-F captchafile=@YOUR_CAPTCHA_FILENAME \
http://api.imagestotext.com/api/captcha
base64-encoded captchafile field should look like this:
base64:R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAICTAEAOw==
You'll get one of the following HTTP responses:
-
303 See Otherif your CAPTCHA was successfully uploaded,LocationHTTP header will point you to the uploaded CAPTCHA status page, you may follow theLocationto get the uploaded CAPTCHA status. Also, the following fields will be returned:
captcha— id of the uploaded captcha.is_correct— 1 if an answer has been identified for this captcha or it is still being processed, 0 if processing finished and no answer could be found.text— captcha answer. An empty string means that the captcha is not solved yet.
status=0&captcha=123&is_correct=1&text=
JSON encoded example:{ "status": 0, "captcha": 123, "is_correct": 1, "text": "" } -
403 Forbiddenif your ImagesToText credentials were rejected, or you don't have enough credits. -
400 Bad Requestif your request did not follow the specification above, or the CAPTCHA was rejected for not being a valid image. -
500 Internal Server Errorif something happened on our side preventing you from uploading the CAPTCHA; if you are sure you are sending properly structured requests with valid CAPTCHA images but the problem persists, please contact our live support and tell them in details how to reproduce the issue. -
503 Service Temporarily Unavailablewhen our service is overloaded, try again later.
At this point the CAPTCHA you've just uploaded may not be solved yet! If you did not receive the answer in the text key of the server response, you have to poll for it. Refer to Polling for uploaded CAPTCHA status for more details.
2. Polling for uploaded CAPTCHA status
To get an uploaded CAPTCHA's status, issue a GET request to
http://api.imagestotext.com/api/captcha/%CAPTCHA_ID%,
where %CAPTCHA_ID% is your uploaded CAPTCHA's ID acquired while uploading the CAPTCHA.
You don't have to supply your ImagesToText credentials this time. The response will be a
HTTP 200 OK
response with the same fields described for the 303 See Other response of the Uploading a CAPTCHA section.
If the captcha is not solved yet, the text key will come empty. You will have to keep on polling
for this answer. Example responses:
-
URL-encoded response of a correctly solved CAPTCHA
status=0&captcha=1234&is_correct=1&text=tyrone+slothrop
-
JSON-encoded response of a correctly solved CAPTCHA
{ "captcha": 1234, "is_correct": true, "status": 0, "text": "tyrone slothrop" } -
JSON-encoded response of an incorrectly solved CAPTCHA
{ "captcha": 1234, "is_correct": false, "status": 0, "text": "?" } -
JSON-encoded response of an inexistent captcha
{ "captcha": 0, "status": 0 }If you get this response, confirm that the CAPTCHA id you are using to poll for the answer is the same one returned when it was uploaded. If the problem persists, feel free to contact us.
Please don't poll for a CAPTCHA status more than once in a couple of
seconds.
This is considered abusive and might get you banned.
Conserve your and our
bandwidth.
3. Reporting incorrectly solved CAPTCHAs
If you think your CAPTCHA was solved incorrectly, report it to ImagesToText to get your money back. To
do so, issue a POST request to http://api.imagestotext.com/api/captcha/%CAPTCHA_ID%/report
with the following fields:
username— your ImagesToText username;password— your ImagesToText password.
The response will be:
200 OKif report was completed. In this case, your credits will be refunded. The response body will be the same as for a poll (or upload) but theis_correctfield will be 0. Example:{ "captcha": 1234, "is_correct": false, "status": 0, "text": "tyrone slothrop" }503 Service Unavailableif report could not be completed. This might be because: 1) captcha corresponding to the provided id was not uploaded by the user reporting it; 2) your user is banned; 3) report was made more than an hour after if was uploaded. In this case, you won't be refunded.
Abusing this feature will get you banned!
4. Checking credit balance
To check your credit balance, issue a GET or POST request to http://api.imagestotext.com/api/user with
the following fields:
username— your ImagesToText username;password— your ImagesToText password.
On successful authentication, you'll get 200 OK response with your ImagesToText account
details, either URL- or JSON-encoded, with the following fields:
user— your ImagesToText account ID;rate— how much we charge you for one correctly solved CAPTCHA, in US¢;balance— your current credit balance, in US¢.is_banned— 1 if user is banned, 0 if not.
Example JSON-encoded response:
{ "is_banned": false, "status": 0, "rate": 0.139,
"balance": 455.23, "user": 43122 }
5. Checking server status
In order to receive current server status, issue a GET request to
http://api.imagestotext.com/api/status. Response will have the following fields:
todays_accuracy— number representing accuracy in percentage (e.g., 99.6 represents 99.6%)solved_in— average solving time in secondsis_service_overloaded— 1 if service is overloaded, 0 otherwise
Example JSON-encoded response:
{ "status": 0, "todays_accuracy": 99.9, "solved_in": 5.3,
"is_service_overloaded": false }