UNLOCK API
Drag and drop

Drag and drop

How to send a Drag and drop 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.60 $0.0006 per task
You send
The images and where pieces must go
You get
Moves to perform (from and to points)

Overview and price

Task type names

This type has one name.
DragAndDropTask

Task object

type
StringRequired
Task type name. Matched in any letter case. DragAndDropTask
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.

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

Request

POST /createTask
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "DragAndDropTask",
    "body": "/9j/4AAQSkZJRgABAQ...",
    "comment": "Move each piece to its matching place"
  }
}

Solution object

Returned in solution when status is ready.
answer
Array
The answer to submit.
POST /getTaskResult
{
  "errorId": 0,
  "taskId": 1001,
  "status": "ready",
  "solution": {
    "answer": [
      {
        "from": {
          "x": 20,
          "y": 40
        },
        "to": {
          "x": 210,
          "y": 44
        }
      }
    ]
  },
  "cost": "0.0006",
  "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": "DragAndDropTask",
      "body": "/9j/4AAQSkZJRgABAQ...",
      "comment": "Move each piece to its matching place"
    }
}).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

This type is available with the JSON methods only.