PDFHQ-Logo

Dokumente

DokumentationErste Schritte

API-Schnelleinstieg

Deine erste PDFHQ-Verarbeitungsaufgabe mit signiertem Upload, verifizierter Datei und asynchronem Task.

Server-seitige API-Schlüssel Signierte Speicher-Uploads

Erste erfolgreiche Anfrage#

Generiere einen HQTools-Projekt-API-Schlüssel auf dem Server. Starte eine Aufgabe, lade ein echtes PDF mit korrekter Bytegröße und SHA-256 hoch, schließe den Upload ab, hänge seine ID an und reihe die Operation ein.

Programming language: cURL

Wähle eine Sprache · scrolle horizontal für alle 10 SDK-Sprachen

API example · cURL
# Server-side API calls. Save the returned task_id.
curl -fsS -X POST 'https://api.pdfhq.io/v1/tasks' \
  -H 'x-api-key: YOUR_API_KEY' -H 'Content-Type: application/json' \
  -d '{"tool":"compress"}'

# Upload and verify 1 PDF(s), then obtain and approve a credit quote:
curl -fsS 'https://api.pdfhq.io/v1/tasks/TASK_ID/quote' -H 'x-api-key: YOUR_API_KEY'

# ONLY after explicit customer approval:
test "$PDFHQ_APPROVE_QUOTE" = yes || { echo "Approval required" >&2; exit 1; }
curl -fsS -X POST 'https://api.pdfhq.io/v1/tasks/TASK_ID/process' \
  -H 'x-api-key: YOUR_API_KEY' -H 'Content-Type: application/json' \
  -d '{"options":{"compression_level":"recommended"}}'

curl -fsS 'https://api.pdfhq.io/v1/tasks/TASK_ID' -H 'x-api-key: YOUR_API_KEY'

After starting a task, upload and verify PDFs, review the credit quote, and get explicit approval before processing. API keys belong on your server, never on signed storage uploads.

All 10 SDKs ↓Vollständige Python-Anleitung ↓ Vollständige Bash/cURL-Anleitung ↓ Alle Endpoints → Direkte Uploads → Fehlerbehandlung →

Generierte herunterladbare Pakete decken nur den Task-Workflow ab. Vollständige SDKs erfordern eine verifizierte OpenAPI-Spezifikation; die Python-, JavaScript- und TypeScript-Task-SDKs streamen Datei-Uploads; die anderen Sprachen erfordern signierte Multipart-Uploads, die vom Aufrufer implementiert werden.

Sichere Wiederholungen und idempotente Task-Erstellung →

Vollständige, downloadbereite Beispiele: Python-CLI Und Bash/cURL . Sie stoppen nach dem Zitieren, es sei denn, du genehmigst die Verarbeitung explizit, und unterstützen das Fortsetzen einer bestehenden Aufgabe nach einer unsicheren Antwort.

Vollständige Signed-Upload-cURL-Sequenz
# 1. Start a task. Save the task_id from its JSON response.
curl -X POST https://api.pdfhq.io/v1/tasks \
  -H 'x-api-key: YOUR_API_KEY' -H 'Content-Type: application/json' \
  -d '{"tool":"compress"}'

# 2. Start a task-scoped upload. Use real file size and SHA-256 values.
curl -X POST https://api.pdfhq.io/v1/tasks/TASK_ID/uploads \
  -H 'x-api-key: YOUR_API_KEY' -H 'Content-Type: application/json' \
  -d '{"filename":"report.pdf","size_bytes":12345,"sha256":"ACTUAL_64_CHAR_DIGEST","content_type":"application/pdf"}'

# 3. POST signed "fields" plus binary file directly to returned S3 "url".
#    Then complete it; PDFHQ automatically attaches the verified file.
curl -X POST https://api.pdfhq.io/v1/tasks/TASK_ID/uploads/UPLOAD_ID/complete -H 'x-api-key: YOUR_API_KEY'

# 4. Queue work (safe to retry with IDENTICAL options), then poll until succeeded.
curl -X POST https://api.pdfhq.io/v1/tasks/TASK_ID/process \
  -H 'x-api-key: YOUR_API_KEY' -H 'Content-Type: application/json' \
  -d '{"options":{"compression_level":"recommended"}}'
curl https://api.pdfhq.io/v1/tasks/TASK_ID -H 'x-api-key: YOUR_API_KEY'

# 5. Once succeeded, get a short-lived signed URL.
curl https://api.pdfhq.io/v1/tasks/TASK_ID/download-url -H 'x-api-key: YOUR_API_KEY'

Erfolgreiches Ergebnis#

201 Aufgabenstart-Antwort (illustrative IDs)
{
  "task_id": "uuid",
  "tool": "compress",
  "status": "waiting",
  "upload_ids": [],
  "job_id": null,
  "progress": 0,
  "output_ready": false,
  "links": {
    "self": "/v1/tasks/uuid",
    "files": "/v1/tasks/uuid/files",
    "process": "/v1/tasks/uuid/process"
  }
}

Die Task wechselt von waiting zu queued/running/succeeded oder failed. Lese ihren Status, bevor du eine Download-URL anforderst.

PDFHQ-Logo

PDF-Werkzeuge und Dokumentenanalyse. Dokumente vorbereiten, verstehen und bearbeiten.

© 2026 PDFHQ. Alle Rechte vorbehalten.