Plain-text PDF extraction

PDF to Text API

Set outputFormat to text to turn digital or scanned PDFs into plain text. Each request may include up to 10 public file URLs.

Use plain text when document layout is not required

PDF-to-text extraction is a good fit for full-text search, document classification, summaries, and analysis where the words matter more than the original visual layout. Both digital PDFs and scanned PDFs can use the same request shape.

The plain-text response is simpler to store and process than a PDF binary. If headings, lists, and table-like structure are important for an LLM or documentation workflow, use the PDF-to-Markdown output instead.

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/research-paper.pdf"
  ],
  "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/research-paper.pdf"
  ],
  "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/research-paper.pdf"
    ],
    "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/research-paper.pdf"
  ],
  "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/research-paper.pdf",
      "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