ImageToText
Recognize text inside an image (OCR) with the NoCaptchaAI API.
Loading…
Recognize text inside an image (OCR) with the NoCaptchaAI API.
Loading…
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
}
}'
| 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). |
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.




























Returns a taskId:
{
"errorId": 0,
"status": "idle",
"taskId": "abc123"
}
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.text contains the recognized text or mathematical result.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)