OCR API
20 languages
PDF, DOCX, images
Self-hosted

Documents in. Agent-ready text out.

Parse PDFs, DOCX, and images into markdown, plain text, and tables. Scans OCR automatically. Nothing leaves Datpaq infrastructure.

10 MB · file cap10 pages · scan OCRTables · preservedSSRF · URL fetch

OCR a sample image.

This posts a tiny canned PNG (a few hundred bytes) to POST /parse. Click to run; OCR can take a few seconds. Huge markdown is truncated in the preview.

Request builder
Fixed demo image. No arbitrary uploads or URLs.
POST /parse
ocr-demo.png

A 220x37 pixel bitmap that reads DATPAQ OCR DEMO. The proxy injects the base64 so the browser never uploads a freeform file.

Output preview
Live response from the API, plus the exact request to reproduce it.
format: n/aocr: n/a
Run the request to OCR a tiny canned PNG (DATPAQ OCR DEMO).

Why OCR API

Parse on-box, keep the tables.

Automatic scan OCR

Born-digital PDFs use the text layer. Empty layers rasterize and OCR the first 10 pages.

DOCX to GFM markdown

Headings and tables survive conversion so RAG pipelines get structured markdown, not a blob.

Images with confidence

PNG, JPEG, WebP, BMP, and GIF run through tesseract.js with a mean confidence score.

Tables as arrays

PDF tables are best-effort; DOCX tables are exact row/cell arrays.

20 OCR languages

Pass language as an ISO 639-2/T code. Default is eng.

Self-hosted bytes

Documents are not stored or forwarded. URL fetches are SSRF-guarded and capped at 10 MB.

/api/v1/ocr

Endpoints, at a glance.

One POST parse route for base64 or URL input. Markdown, text, and tables come back in a single JSON shape.
POST/api/v1/ocr/parse

Parse document

Exactly one of fileBase64 or url. Returns markdown, text, tables, and parse metadata.

PRIMARY
ParameterTypeRequiredDescription
fileBase64stringone ofBase64-encoded document, max 10 MB decoded.
urlstringone ofhttp(s) URL, SSRF-guarded, 10 MB and 15 second fetch cap.
filenamestringnoHint for logs. Detection uses magic bytes, not the name.
ocrbooleannoForce OCR on PDFs that already have a text layer. Default false.
languagestringnoOCR language ISO 639-2/T from the supported set. Default eng.

Error reference

Failures you can plan for.

Format dispatch trusts magic bytes only. Failures include a machine-readable reason such as unsupported-format.
400Validation Error

Missing or both inputs, invalid base64 or URL, unsupported format, or SSRF-blocked URL.

401Authentication Error

Missing or invalid gateway API key. Send x-api-key or api_key with every request.

413Payload Too Large

Decoded document over 10 MB, or JSON envelope over 15 MB.

422Unprocessable Document

Allowlisted document could not be parsed, or OCR timed out.

429Rate Limit Error

More than 120 requests in a 15-minute window.

502Upstream Error

Document URL fetch failed, timed out, or returned an error status.

Example error response

{
  "success": false,
  "error": { "code": "VALIDATION_ERROR", "message": "Invalid input parameters" },
  "reason": "unsupported-format",
  "correlationId": "req_abc123"
}

FAQ

API questions developers ask first.

What file types can I send?

PDF, DOCX, PNG, JPEG, WebP, BMP, and GIF. Format is detected from magic bytes, not the filename. TIFF and XLSX are out of scope for v1.

When does OCR actually run?

Images always OCR. PDFs OCR when there is no usable text layer, or when you set ocr=true to force it. Scanned PDFs are capped at the first 10 pages.

Do documents leave Datpaq?

No. Parsing is self-hosted. Bytes and extracted text are not logged, stored, or sent to a third-party OCR vendor.

Can I pass a URL instead of base64?

Yes. Send url for an SSRF-guarded fetch with a 10 MB and 15 second cap. Exactly one of fileBase64 or url is required.

How do I authenticate requests?

Send your Datpaq API key as an x-api-key header or an api_key query parameter. Keys are created in the Datpaq dashboard and a free tier is included.

Turn documents into text your agents can use.

Self-hosted PDF, DOCX, and image parsing with tables preserved and OCR that stays on Datpaq infrastructure.