Structured text output

PDF to Markdown API

Set outputFormat to markdown to request Markdown from a public PDF URL. The response uses the same document result fields as plain-text extraction.

Preserve useful structure for RAG and LLM workflows

Markdown is useful when downstream code or an AI model benefits from readable headings, lists, and table structure. It provides a lightweight intermediate format for retrieval pipelines, documentation migrations, and prompt context without sending the original PDF binary.

Request Markdown from the same extraction endpoint, inspect the result, and then apply your own chunking or indexing rules. gettxt.ai performs extraction; your application remains responsible for retrieval, embeddings, and agent orchestration.

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/product-guide.pdf"
  ],
  "outputFormat": "markdown"
}
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/product-guide.pdf"
  ],
  "outputFormat": "markdown"
}'

Python

import requests

response = requests.post(
    "https://gettxt.ai/api/extract/",
    headers={"x-api-key": "YOUR_API_KEY"},
    json={
    "documentUris": [
        "https://example.com/product-guide.pdf"
    ],
    "outputFormat": "markdown"
}
)
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/product-guide.pdf"
  ],
  "outputFormat": "markdown"
})
});

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/product-guide.pdf",
      "status": "succeeded",
      "wordCount": 500,
      "extractedText": "Extracted markdown 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