Skip to content

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.

TypeDescription
DrawAroundTaskTrace the outline of an object in an image
ParameterTypeRequiredDescription
typestringYesDrawAroundTask
bodystringYesBase64-encoded image
commentstringNoInstructions (e.g., “Trace around the cat”)
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "DrawAroundTask",
"body": "iVBORw0KGgoAAAANSUhEUg...",
"comment": "Trace around the cat"
}
}
{
"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 }
]
}
}
{
"points": [
{ "x": 10, "y": 20 },
{ "x": 30, "y": 15 },
{ "x": 50, "y": 25 },
{ "x": 45, "y": 50 },
{ "x": 15, "y": 45 }
]
}
FieldTypeDescription
pointsarrayOrdered array of {x, y} coordinate points forming the outline

Each point object contains:

FieldTypeDescription
xintegerHorizontal pixel position from the left edge
yintegerVertical 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.

import requests
import 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)
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));
}
}
Terminal window
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"
}'
  • 2Captcha