UNLOCK API

API para sa pag-solve ng Bounding box

Magpadala ng Bounding box task sa API at matatanggap mo ang sagot na isusumite ng code mo sa page. Ang image bilang base64 at kung ano ang ia-outline. Matatanggap mo: Mga rectangle sa paligid ng mga bagay.

Sa madaling salita

Presyo bawat 1,000
$0.60 ($0.0006 bawat task)
createTask type
BoundingBoxTask
in.php method
bounding_box
Ipapadala mo
Ang image bilang base64 at kung ano ang ia-outline
Matatanggap mo
Mga rectangle sa paligid ng mga bagay

Saan makikita ang mga value

Ipadala ang image at ang instruction bilang comment.

createTask at getTaskResult

Gawin ang task, maghintay ng mga 5 segundo, saka i-check ang resulta bawat 5 segundo hanggang ready na ang status. Kung mag-fail ang task, magbabalik ang API ng error at babalik ang singil sa balance mo.

import time, requests

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

task = requests.post(f"{API}/createTask", json={
    "clientKey": KEY,
    "task": {
      "type": "BoundingBoxTask",
      "body": "/9j/4AAQSkZJRgABAQ...",
      "comment": "Draw a box around each car"
    }
}).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 at res.php

Parehong task gamit ang classic na form API. Idagdag ang json=1 para sa JSON na sagot; kung wala ito, plain text ang sagot gaya ng OK|1001.

curl -s "https://unlock-api.com/in.php" -d "key=YOUR_API_KEY&method=bounding_box&textinstructions=Draw+a+box+around+each+car&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"}

Kumpletong API reference: bawat parameter at ang solution object