Normal CAPTCHA
Normal CAPTCHA is an image that contains distored but human-readable text. To solve the captcha user have to type the text from the image.
Task type: ImageToTextTask
The method is used to get the text from distorted captcha images. Images should be encoded to Base64 format.
Supported image formats: JPEG, PNG, GIF
Max file size: 100 kB
Max image size: 1000px on any side
ImageToTextTask task type specification
Property | Type | Required | Default | Description |
---|---|---|---|---|
type | String | Yes | ImageToTextTask | Task type |
body | String | Yes | Image encoded into Base64 format. Data-URI format (containing data:content/type prefix) is also supported |
|
phrase | Boolean | No | false | false - no preference true - the answer should contain at least two words separated by space. |
case | Boolean | No | false | false - no preference true - the result is case-sensitive |
numeric | Integer | No | 0 | 0 - no preference 1 - answer should contain only numbers 2 - answer should contain only letters 3 - answer should contain only numbers OR only letters 4 - answer MUST contain both numbers AND letters |
math | Boolean | No | false | false - no preference true - captcha requires calculation |
minLength | Integer | No | 0 | 0 - no preference >=1 - defines minimal answer length |
maxLength | Integer | No | 0 | 0 - no preference >=1 - defines maximal answer length |
comment | String | No | A comment will be shown to workers to help them to solve the captcha properly | |
imgInstructions | String | No | An optional image with instruction that will be shown to workers. Image should be encoded into Base64 format. |
Request example
Method: createTask
API endpoint: https://api.2captcha.com/createTask
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "ImageToTextTask",
"body": "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",
"phrase": false,
"case": true,
"numeric": 0,
"math": false,
"minLength": 1,
"maxLength": 5,
"comment": "enter the text you see on the image"
},
"languagePool": "en"
}
Response example
Method: getTaskResult
API endpoint: https://api.2captcha.com/getTaskResult
{
"errorId": 0,
"status": "ready",
"solution": {
"text": "hello world"
},
"cost": "0.00025",
"ip": "1.2.3.4",
"createTime": 1692808229,
"endTime": 1692808326,
"solveCount": 1
}
Code examples
// https://github.com/2captcha/2captcha-php
require(__DIR__ . '/../src/autoloader.php');
$solver = new \TwoCaptcha\TwoCaptcha('YOUR_API_KEY');
try {
$result = $solver->normal('path/to/captcha.jpg');
} catch (\Exception $e) {
die($e->getMessage());
}
die('Captcha solved: ' . $result->code);
# https://github.com/2captcha/2captcha-python
import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
from twocaptcha import TwoCaptcha
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
solver = TwoCaptcha(api_key)
try:
result = solver.normal('path/to/captcha.jpg')
except Exception as e:
sys.exit(e)
else:
sys.exit('solved: ' + str(result))
// https://github.com/2captcha/2captcha-csharp
using System;
using System.Linq;
using TwoCaptcha.Captcha;
namespace TwoCaptcha.Examples
{
public class NormalExample
{
public static void Main()
{
var solver = new TwoCaptcha("YOUR_API_KEY");
Normal captcha = new Normal("path/to/captcha.jpg");
try
{
solver.Solve(captcha).Wait();
Console.WriteLine("Captcha solved: " + captcha.Code);
}
catch (AggregateException e)
{
Console.WriteLine("Error occurred: " + e.InnerExceptions.First().Message);
}
}
}
}
// https://github.com/2captcha/2captcha-java
package examples;
import com.twocaptcha.TwoCaptcha;
import com.twocaptcha.captcha.Normal;
public class NormalExample {
public static void main(String[] args) {
TwoCaptcha solver = new TwoCaptcha("YOUR_API_KEY");
Normal captcha = new Normal("path/to/captcha.jpg");
try {
solver.solve(captcha);
System.out.println("Captcha solved: " + captcha.getCode());
} catch (Exception e) {
System.out.println("Error occurred: " + e.getMessage());
}
}
}
// https://github.com/2captcha/2captcha-go
package main
import (
"fmt"
"log"
"github.com/2captcha/2captcha-go"
)
func main() {
client := api2captcha.NewClient("API_KEY")
captcha := api2captcha.Normal{
File: "/path/to/captcha.jpg",
}
code, err := client.Solve(captcha.ToRequest())
if err != nil {
log.Fatal(err);
}
fmt.Println("code "+code)
}
require 'api_2captcha'
client = Api2Captcha.new("YOUR_API_KEY")
result = client.normal({ image: 'path/to/captcha.jpg'})
# OR
result = client.normal({
image: 'https://site-with-captcha.com/path/to/captcha.jpg'
})