Image to Text
Image to Text is the most common recognition task. Send a base64-encoded image of a CAPTCHA and receive the text content. This task type processes images directly on the provider side — no proxy variants are needed.
Recognition tasks typically return results synchronously with the createTask response. If the result is not immediately available, poll with getTaskResult as usual.
Task Type
Section titled “Task Type”| Type | Description |
|---|---|
ImageToTextTask | Recognize text from a CAPTCHA image |
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | ImageToTextTask |
body | string | Yes | Base64-encoded image (PNG, JPG, GIF) |
case | boolean | No | true if the answer is case-sensitive |
numeric | integer | No | 1 = digits only, 2 = letters only, 0 = any |
minLength | integer | No | Minimum answer length |
maxLength | integer | No | Maximum answer length |
phrase | boolean | No | true if the answer contains a space |
math | boolean | No | true if the answer is a math result |
comment | string | No | Instructions for the solver |
Create Task
Section titled “Create Task”Request
Section titled “Request”{ "clientKey": "YOUR_API_KEY", "task": { "type": "ImageToTextTask", "body": "iVBORw0KGgoAAAANSUhEUg...", "numeric": 1, "minLength": 4, "maxLength": 6 }}Response
Section titled “Response”{ "errorId": 0, "status": "ready", "solution": { "text": "abc123" }}Solution Object
Section titled “Solution Object”{ "text": "abc123"}| Field | Type | Description |
|---|---|---|
text | string | The recognized text from the CAPTCHA image |
Code Examples
Section titled “Code Examples”Python
Section titled “Python”import requestsimport base64
API_KEY = "YOUR_API_KEY"
# Encode the CAPTCHA image to base64with open("captcha.png", "rb") as f: image_data = base64.b64encode(f.read()).decode()
# Create taskresponse = requests.post("https://api.ucaptcha.net/createTask", json={ "clientKey": API_KEY, "task": { "type": "ImageToTextTask", "body": image_data, "numeric": 0, "minLength": 4, "maxLength": 8 }}).json()
if response.get("status") == "ready": print("Solution:", response["solution"]["text"])else: # Poll if not immediately ready import time task_id = response["taskId"] while True: result = requests.post("https://api.ucaptcha.net/getTaskResult", json={ "clientKey": API_KEY, "taskId": task_id }).json()
if result["status"] == "ready": print("Solution:", result["solution"]["text"]) break elif result["status"] == "failed": print("Error:", result.get("errorDescription")) break
time.sleep(5)JavaScript
Section titled “JavaScript”import { readFileSync } from "fs";
const API_KEY = "YOUR_API_KEY";
// Encode the CAPTCHA image to base64const imageData = readFileSync("captcha.png").toString("base64");
// Create taskconst response = await fetch("https://api.ucaptcha.net/createTask", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ clientKey: API_KEY, task: { type: "ImageToTextTask", body: imageData, numeric: 0, minLength: 4, maxLength: 8 } })}).then(r => r.json());
if (response.status === "ready") { console.log("Solution:", response.solution.text);} else { // Poll if not immediately ready const taskId = response.taskId; while (true) { const result = await fetch("https://api.ucaptcha.net/getTaskResult", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ clientKey: API_KEY, taskId }) }).then(r => r.json());
if (result.status === "ready") { console.log("Solution:", result.solution.text); break; } else if (result.status === "failed") { console.error("Error:", result.errorDescription); break; }
await new Promise(r => setTimeout(r, 5000)); }}# Encode image to base64IMAGE_BASE64=$(base64 -w 0 captcha.png)
# Create taskcurl -X POST https://api.ucaptcha.net/createTask \ -H "Content-Type: application/json" \ -d "{ \"clientKey\": \"YOUR_API_KEY\", \"task\": { \"type\": \"ImageToTextTask\", \"body\": \"$IMAGE_BASE64\", \"numeric\": 0, \"minLength\": 4, \"maxLength\": 8 } }"
# Poll for result if not immediately ready (replace TASK_ID)curl -X POST https://api.ucaptcha.net/getTaskResult \ -H "Content-Type: application/json" \ -d '{ "clientKey": "YOUR_API_KEY", "taskId": "TASK_ID" }'Provider Coverage
Section titled “Provider Coverage”- 2Captcha
- CapSolver
- Anti-Captcha
- CapMonster
- DeathByCaptcha
- 2Crawler
- Multibot