Draw Around
Draw Around tasks trace the outline of a specific object in an image. The solution returns an ordered array of coordinate points that form the outline path. This is used for CAPTCHAs that ask users to draw a shape around a target object.
Task Type
Section titled “Task Type”| Type | Description |
|---|---|
DrawAroundTask | Trace the outline of an object in an image |
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | Yes | DrawAroundTask |
body | string | Yes | Base64-encoded image |
comment | string | No | Instructions (e.g., “Trace around the cat”) |
Create Task
Section titled “Create Task”Request
Section titled “Request”{ "clientKey": "YOUR_API_KEY", "task": { "type": "DrawAroundTask", "body": "iVBORw0KGgoAAAANSUhEUg...", "comment": "Trace around the cat" }}Response
Section titled “Response”{ "errorId": 0, "status": "ready", "solution": { "points": [ { "x": 10, "y": 20 }, { "x": 30, "y": 15 }, { "x": 50, "y": 25 }, { "x": 45, "y": 50 }, { "x": 15, "y": 45 } ] }}Solution Object
Section titled “Solution Object”{ "points": [ { "x": 10, "y": 20 }, { "x": 30, "y": 15 }, { "x": 50, "y": 25 }, { "x": 45, "y": 50 }, { "x": 15, "y": 45 } ]}| Field | Type | Description |
|---|---|---|
points | array | Ordered array of {x, y} coordinate points forming the outline |
Each point object contains:
| Field | Type | Description |
|---|---|---|
x | integer | Horizontal pixel position from the left edge |
y | integer | Vertical pixel position from the top edge |
The points are ordered sequentially to form a closed path. Connect them in order (and close the path from the last point back to the first) to reproduce the outline.
Code Examples
Section titled “Code Examples”Python
Section titled “Python”import requestsimport base64
API_KEY = "YOUR_API_KEY"
with open("captcha.png", "rb") as f: image_data = base64.b64encode(f.read()).decode()
response = requests.post("https://api.ucaptcha.net/createTask", json={ "clientKey": API_KEY, "task": { "type": "DrawAroundTask", "body": image_data, "comment": "Trace around the cat" }}).json()
if response.get("status") == "ready": points = response["solution"]["points"] print(f"Outline has {len(points)} points:") for point in points: print(f" ({point['x']}, {point['y']})")else: 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": points = result["solution"]["points"] print(f"Outline has {len(points)} points:") for point in points: print(f" ({point['x']}, {point['y']})") 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";
const imageData = readFileSync("captcha.png").toString("base64");
const response = await fetch("https://api.ucaptcha.net/createTask", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ clientKey: API_KEY, task: { type: "DrawAroundTask", body: imageData, comment: "Trace around the cat" } })}).then(r => r.json());
if (response.status === "ready") { const points = response.solution.points; console.log(`Outline has ${points.length} points:`); for (const point of points) { console.log(` (${point.x}, ${point.y})`); }} else { 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") { const points = result.solution.points; console.log(`Outline has ${points.length} points:`); for (const point of points) { console.log(` (${point.x}, ${point.y})`); } break; } else if (result.status === "failed") { console.error("Error:", result.errorDescription); break; }
await new Promise(r => setTimeout(r, 5000)); }}IMAGE_BASE64=$(base64 -w 0 captcha.png)
curl -X POST https://api.ucaptcha.net/createTask \ -H "Content-Type: application/json" \ -d "{ \"clientKey\": \"YOUR_API_KEY\", \"task\": { \"type\": \"DrawAroundTask\", \"body\": \"$IMAGE_BASE64\", \"comment\": \"Trace around the cat\" } }"
# 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