UNLOCK API
Bild zu Text

Bild zu Text

So senden Sie eine Bild zu Text-Aufgabe mit createTask oder in.php an UNLOCK API: Namen der Aufgabentypen, alle Parameter, das solution-Objekt, Proxy-Felder und Codebeispiele in 7 Sprachen.
Preis
$0.25 $0.00025 pro Aufgabe
Sie senden
Das Bild als base64, bis 100 KB
Sie erhalten
Der Text im Bild

Überblick und Preis

Namen der Aufgabentypen

Dieser Typ hat nur einen Namen.
ImageToTextTask

Aufgabenobjekt

type
StringPflicht
Name des Aufgabentyps. Groß- und Kleinschreibung spielt keine Rolle. ImageToTextTask
body
StringPflicht
Das Bild als base64 (JPG, PNG oder GIF), bis etwa 100 KB. Ein Präfix data: ist erlaubt.
phrase
BooleanOptional
true, wenn die Antwort aus zwei oder mehr Wörtern besteht.
case
BooleanOptional
true, wenn Groß- und Kleinschreibung zählt.
numeric
IntegerOptional
0 beliebige Zeichen, 1 nur Ziffern, 2 nur Buchstaben, 3 Ziffern oder Buchstaben, 4 Ziffern und Buchstaben.
math
BooleanOptional
true, wenn das Bild eine zu berechnende Rechnung zeigt.
minLength
IntegerOptional
Kürzestmögliche Antwort. 0 bedeutet keine Begrenzung.
maxLength
IntegerOptional
Längstmögliche Antwort. 0 bedeutet keine Begrenzung.
comment
StringOptional
Anweisung für den Solver, zum Beispiel die Frage über dem Bild.
languagePool
StringOptional
Sprache der Antwort, zum Beispiel en oder ru.

Hier nicht aufgeführte Felder werden unverändert an den Solver weitergegeben.

Anfrage

POST /createTask
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "ImageToTextTask",
    "body": "/9j/4AAQSkZJRgABAQ...",
    "case": true
  }
}

solution-Objekt

Wird in solution zurückgegeben, wenn status ready ist.
text
String
Die Antwort als Text.
POST /getTaskResult
{
  "errorId": 0,
  "taskId": 1001,
  "status": "ready",
  "solution": {
    "text": "w93bx"
  },
  "cost": "0.00025",
  "createTime": 1791640000,
  "endTime": 1791640014,
  "solveCount": 1
}

Codebeispiele

import time, requests

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

task = requests.post(f"{API}/createTask", json={
    "clientKey": KEY,
    "task": {
      "type": "ImageToTextTask",
      "body": "/9j/4AAQSkZJRgABAQ...",
      "case": true
    }
}).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"]["text"])
        break
else:
    raise SystemExit("timed out")

in.php-Formularmethode

Dieselbe Aufgabe mit der klassischen Formularanfrage. res.php gibt die Antwort als Text zurück.
in.php, res.php
curl -s "https://unlock-api.com/in.php" -d "key=YOUR_API_KEY&method=base64&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"}

Formular-API: in.php und res.php