Image Tasks

ImageToText
Recognize text inside an image (OCR) with the NoCaptchaAI API.
Create a task
POST https://api.nocaptchaai.com/createTask
curl -X POST https://api.nocaptchaai.com/createTask \
-H "Content-Type: application/json" \
-d '{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "ImageToTextTask",
"body": "/9j/4AAQSkZJRgABAQ....",
"module": "module_nocap_201",
"case": false,
"numeric": 0,
"math": false,
"minLength": 0,
"maxLength": 0
}
}'{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "ImageToTextTask",
"body": "/9j/4AAQSkZJRgABAQ....",
"module": "module_nocap_201",
"case": false,
"numeric": 0,
"math": false,
"minLength": 0,
"maxLength": 0
}
}Task parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Task type, must be "ImageToTextTask". |
body | string | Yes | Base64-encoded image string. |
module | string | No | OCR model identifier, for example module_nocap_201 or module_nocap_202. Defaults to common. Match your image against the samples below. |
case | boolean | No | Case sensitivity: true for case-sensitive, false otherwise. Default is false. |
numeric | integer | No | Character filter: 0 for any, 1 for numbers only, 2 for letters only. Default is 0. |
math | boolean | No | Whether the image contains a mathematical equation to solve. Default is false. |
minLength | integer | No | Minimum length of recognized text. Default is 0 (no minimum). |
maxLength | integer | No | Maximum length of recognized text. Default is 0 (no maximum). |
Supported models
Compare your captcha image with the samples below and pass the matching module value in your task. common is the universal fallback model: use it when none of the specialized samples match your captcha, or omit module to use it by default.
common1 sample
module_nocap_20113 samples
module_nocap_2029 samples
module_nocap_2031 sample
MCA India Portal
module_nocap_2046 samples
module_nocap_2058 samples
mod-ocr7035 samples
probot1 sample
Returns a taskId:
{
"errorId": 0,
"status": "idle",
"taskId": "abc123"
}Get the result
Poll POST https://api.nocaptchaai.com/getTaskResult until status is ready:
{
"clientKey": "YOUR_API_KEY",
"taskId": "abc123"
}{
"errorId": 0,
"status": "ready",
"solution": {
"text": "aB3xQ"
}
}solution.textcontains the recognized text or mathematical result.
Code example
import time
import requests
API_KEY = "YOUR_API_KEY"
BASE = "https://api.nocaptchaai.com"
# 1. Create the task
task = requests.post(
f"{BASE}/createTask",
json={
"clientKey": API_KEY,
"task": {
"type": "ImageToTextTask",
"body": "/9j/4AAQSkZJRgABAQ....",
"module": "module_nocap_201",
"case": False,
"numeric": 0,
"math": False,
"minLength": 0,
"maxLength": 0,
},
},
).json()
task_id = task["taskId"]
# 2. Poll for the result
while True:
time.sleep(2)
res = requests.post(
f"{BASE}/getTaskResult",
json={"clientKey": API_KEY, "taskId": task_id},
).json()
if res.get("status") == "ready":
print(res["solution"]["text"])
break
if res.get("status") == "failed" or res.get("errorId"):
raise SystemExit(res)const API_KEY = "YOUR_API_KEY";
const BASE = "https://api.nocaptchaai.com";
// 1. Create the task
const create = await fetch(`${BASE}/createTask`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
clientKey: API_KEY,
task: {
type: "ImageToTextTask",
body: "/9j/4AAQSkZJRgABAQ....",
module: "module_nocap_201",
case: false,
numeric: 0,
math: false,
minLength: 0,
maxLength: 0,
},
}),
}).then((r) => r.json());
// 2. Poll for the result
let solution;
while (true) {
await new Promise((r) => setTimeout(r, 2000));
const res = await fetch(`${BASE}/getTaskResult`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
clientKey: API_KEY,
taskId: create.taskId,
}),
}).then((r) => r.json());
if (res.status === "ready") {
solution = res.solution.text;
break;
}
if (res.status === "failed" || res.errorId) {
throw new Error(JSON.stringify(res));
}
}
console.log(solution);# 1. Create the task
curl -X POST https://api.nocaptchaai.com/createTask \
-H "Content-Type: application/json" \
-d '{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "ImageToTextTask",
"body": "/9j/4AAQSkZJRgABAQ....",
"module": "module_nocap_201",
"case": false,
"numeric": 0,
"math": false,
"minLength": 0,
"maxLength": 0
}
}'
# 2. Get the result
curl -X POST https://api.nocaptchaai.com/getTaskResult \
-H "Content-Type: application/json" \
-d '{
"clientKey": "YOUR_API_KEY",
"taskId": "abc123"
}'