Images and scanned documents

OCR API

Use the same extraction endpoint for OCR. Supply a public image or scanned PDF URL and receive the recognized text in the synchronous JSON response.

Turn scans and images into searchable text

OCR is needed when a PDF page or image contains pixels rather than selectable text. This guide fits scanned archives, photographed paperwork, screenshots, and image-based PDFs that must become searchable or available to downstream software.

gettxt.ai returns the recognized content as text or Markdown. It is intended for content extraction; it does not return invoice fields, bounding boxes, or a document-specific JSON schema.

Request

Send a POST request to https://gettxt.ai/api/extract/. Authenticate with the x-api-key header. documentUris is required and accepts 1–10 directly accessible URLs.

{
  "documentUris": [
    "https://example.com/scanned-invoice.png"
  ],
  "outputFormat": "text"
}
documentUris (required)
One to ten public URLs. Supported file types can be mixed in one request.
outputFormat (optional)
Use text or markdown. Plain text is the default.
summarize and translate (optional)
Set summarize to true and/or provide a language code such as de or es for translate.

Examples

cURL

curl -X POST "https://gettxt.ai/api/extract/" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
  "documentUris": [
    "https://example.com/scanned-invoice.png"
  ],
  "outputFormat": "text"
}'

Python

import requests

response = requests.post(
    "https://gettxt.ai/api/extract/",
    headers={"x-api-key": "YOUR_API_KEY"},
    json={
    "documentUris": [
        "https://example.com/scanned-invoice.png"
    ],
    "outputFormat": "text"
}
)
response.raise_for_status()
print(response.json()["documents"][0]["extractedText"])

Node.js

const response = await fetch("https://gettxt.ai/api/extract/", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "x-api-key": "YOUR_API_KEY"
  },
  body: JSON.stringify({
  "documentUris": [
    "https://example.com/scanned-invoice.png"
  ],
  "outputFormat": "text"
})
});

if (!response.ok) throw new Error(`Extraction failed: ${response.status}`);
const result = await response.json();
console.log(result.documents[0].extractedText);

Synchronous response

Processing completes within the HTTP request. A successful JSON response includes combined content, credit totals, word counts, and a result for each submitted URL.

{
  "creditsUsed": 1,
  "creditsRemaining": 99,
  "totalWordCount": 500,
  "all_text": "Extracted content from all documents...",
  "documents": [
    {
      "documentUri": "https://example.com/scanned-invoice.png",
      "status": "succeeded",
      "wordCount": 500,
      "extractedText": "Extracted text content..."
    }
  ]
}

Errors

  • 400: Invalid, empty, inaccessible, oversized, or unsupported input.
  • 401: Missing or invalid API key.
  • 403: Insufficient credits or access denied.
  • 413: File exceeds the service limit.
  • 429: Too many requests; retry later.
  • 500/503/504: Processing, service, or timeout failure.

See the API documentation for the full request and error reference.

Supported formats

Documents

PDF, DOCX, XLSX, PPTX, HTML, EPUB

Images

JPG, JPEG, PNG, BMP, TIFF, HEIF

Audio

MP3, MPGA, M4A, WAV

Video

MP4, AVI, MKV, MOV, FLV, WMV, MPEG, 3GP, WEBM, MTS, M2TS, TS