UNLOCK API
Image grid

Image grid

How to send a Image grid task to UNLOCK API with createTask or in.php: task type names, every parameter, the solution object, proxy fields and code samples in 7 languages.
Price
$0.36 $0.00036 per task
You send
The grid image as base64 and the instruction, for example the object to select
You get
The numbers of the cells to click

Overview and price

Task type names

This type has one name.
GridTask

Also accepted: GridTaskProxyless

Task object

type
StringRequired
Task type name. Matched in any letter case. GridTask
body
StringRequired
The image as base64 (JPG, PNG or GIF), up to about 100 KB. A data: prefix is allowed.
comment
StringOptional
Instruction for the solver, for example the question shown above the image.
rows
IntegerOptional
Number of rows in the grid.
columns
IntegerOptional
Number of columns in the grid.
imgType
StringOptional
Type of picture, if you know it.
previousId
StringOptional
id of the earlier task when the grid changes after the first answer.
canSkip
BooleanOptional
true if the answer may be that no tile matches.

Fields not listed here are passed to the solver as sent.

Request

POST /createTask
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "GridTask",
    "body": "/9j/4AAQSkZJRgABAQ...",
    "comment": "Select all squares with traffic lights",
    "rows": 3,
    "columns": 3
  }
}

Solution object

Returned in solution when status is ready.
click
Array
Numbers of the tiles to click, counted from 1, left to right and top to bottom.
POST /getTaskResult
{
  "errorId": 0,
  "taskId": 1001,
  "status": "ready",
  "solution": {
    "click": [
      1,
      4,
      9
    ]
  },
  "cost": "0.00036",
  "createTime": 1791640000,
  "endTime": 1791640014,
  "solveCount": 1
}

Code samples

import time, requests

API = "https://unlock-api.com"
KEY = "YOUR_API_KEY"

task = requests.post(f"{API}/createTask", json={
    "clientKey": KEY,
    "task": {
      "type": "GridTask",
      "body": "/9j/4AAQSkZJRgABAQ...",
      "comment": "Select all squares with traffic lights",
      "rows": 3,
      "columns": 3
    }
}).json()
if task["errorId"]:
    raise SystemExit(task["errorCode"])

for _ in range(60):   # 60 x 5 s = the 5 minute task limit
    time.sleep(5)
    r = requests.post(f"{API}/getTaskResult", json={"clientKey": KEY, "taskId": task["taskId"]}).json()
    if r["errorId"]:
        raise SystemExit(f"{r['errorCode']}: {r.get('errorDescription', '')}")   # failed tasks are refunded
    if r["status"] == "ready":
        print(r["solution"])
        break
else:
    raise SystemExit("timed out")

in.php form method

The same task with the classic form request. res.php returns the answer as text.
in.php, res.php
curl -s "https://unlock-api.com/in.php" -d "key=YOUR_API_KEY&method=base64&recaptcha=1&textinstructions=Select+all+traffic+lights&body=BASE64_IMAGE&json=1"
# {"status":1,"request":"1001"}

curl -s "https://unlock-api.com/res.php?key=YOUR_API_KEY&action=get&id=1001&json=1"
# {"status":0,"request":"CAPCHA_NOT_READY"}  then  {"status":1,"request":"ANSWER"}

Form API: in.php and res.php