Ana içeriğe geç
Bu sayfa henüz Türkçeye çevrilmedi; İngilizce sürümü gösteriliyor.
Versiyon: 0.1

HTTP API

Start the API with pidief serve (this is the Docker image's default command). The OpenAPI 3.1 document is served at GET /openapi.json and a reference page at GET /docs.

Every endpoint matches a CLI command with the same parameters.

Endpoints​

EndpointOperationResult
POST /v1/htmlHTML to PDFPDF
POST /v1/templatetemplate + data to PDFPDF
POST /v1/template/previewtemplate + data to HTMLHTML
POST /v1/imagesimages to PDFPDF
POST /v1/mergemergePDF
POST /v1/splitsplitZIP
POST /v1/pages/select · /delete · /rotatepage operationsPDF
POST /v1/watermark · /v1/stampwatermark, stampPDF
POST /v1/compresscompressPDF
POST /v1/pdfaPDF/A-2bPDF
POST /v1/encrypt · /v1/decryptpasswordsPDF
POST /v1/metadatadocument informationPDF
POST /v1/info · /v1/textinfo, textJSON
POST /v1/renderpages to imagesimage or ZIP
GET /v1/jobs/{id} · /result, DELETE /v1/jobs/{id}background jobsJSON / result
GET /health/live · /health/ready · /metricshealth, Prometheus

Authentication​

Send an API key in the X-Api-Key header. Keys are set with PIDIEF_API_KEYS; an empty value disables authentication and is meant for development only. See Configuration.

Request bodies​

Every endpoint accepts three body types:

  • multipart/form-data: files as parts with a filename (relative paths are kept, for example img/logo.png); parameters as separate fields or as one options JSON field.
  • application/json: {"files":[{"name":"a.pdf","content":"<base64>"}], ...parameters}. html, template and data (an object) can be given directly.
  • A raw document (application/pdf, image/*, text/html) with parameters in the query string.

Examples​

curl -H "X-Api-Key: $KEY" -F files=@report.html -F "files=@img/logo.png;filename=img/logo.png" \
-F pageNumbers=true http://localhost:3000/v1/html -o report.pdf

curl -H "X-Api-Key: $KEY" -H 'Content-Type: application/json' http://localhost:3000/v1/template \
-d '{"template":"<h1>{{customer.name}}</h1><p>{{currency total \"EUR\"}}</p>","data":{"customer":{"name":"Example Ltd"},"total":1234.56}}' -o receipt.pdf

curl -H "X-Api-Key: $KEY" -H 'Content-Type: application/pdf' --data-binary @report.pdf \
'http://localhost:3000/v1/render?pages=1&format=webp&maxWidth=300' -o thumb.webp

Background jobs​

For long work, add ?async=true. The API returns 202 with {"id":...}. Poll GET /v1/jobs/{id} for the state and fetch the output from GET /v1/jobs/{id}/result.

curl -H "X-Api-Key: $KEY" -F files=@big.html 'http://localhost:3000/v1/html?async=true'

Async results are kept in memory for PIDIEF_JOB_TTL. With several replicas, async jobs need sticky routing.

Errors​

Errors are RFC 9457 application/problem+json responses with detail and requestId:

StatusMeaning
400invalid input
401API key missing or wrong
413request too large
429queue full (with Retry-After)
503no free slot in time
504timeout

Statelessness​

The service is stateless: inputs and results stay in memory and documents are never written to disk.