API reference
PDF to Text API
PDF to text page by page with metadata; AI OCR for scanned pages and clean Markdown with tables.
- Host
pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com- Base path
/v1/pdf- Auth
X-RapidAPI-Key,X-RapidAPI-Host- For agents
openapi.json·pdf.md
Overview and pricing · Tutorial: PDF to Text API · RapidAPI playground (opens in a new tab) ↗ · Apify actor (opens in a new tab) ↗
PDF Extraction
PDF to text and Markdown, page by page.
Extract PDF from URL
POST /v1/pdf/extract
Extract the text of a PDF from its URL. Text of every page (or of the pages you choose), the document metadata, and Markdown with headings and tables for pages read by the AI. Scanned pages are read by OCR in 'auto' mode. Credits: 1 per started 20 text-layer pages, 20 per page read by the AI.
| Parameter | In | Type | Description |
|---|---|---|---|
url required |
body | string |
Direct link to a PDF, up to 50 MB. |
mode |
body | "auto" | "text" | "ai" |
'text': the PDF's own text layer, no AI (fast, cheapest). 'auto': text layer, and AI OCR for scanned pages only. 'ai': AI on every page, for clean Markdown with headings and tables. Default auto. |
pages |
body | string |
Pages to extract, e.g. '1-5,8,10-12'. All pages when empty. |
password |
body | string |
Password of an encrypted PDF. |
curl -X POST "https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com" \
-H "Content-Type: application/json" \
-d '{
"url": "https://arxiv.org/pdf/1706.03762",
"mode": "ai",
"pages": "1-3"
}'
import requests
url = "https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract"
payload = {
"url": "https://arxiv.org/pdf/1706.03762",
"mode": "ai",
"pages": "1-3"
}
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com",
}
r = requests.post(url, json=payload, headers=headers)
print(r.json())
const res = await fetch("https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract", {
method: "POST",
headers: {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com",
"Content-Type": "application/json",
},
body: JSON.stringify({
"url": "https://arxiv.org/pdf/1706.03762",
"mode": "ai",
"pages": "1-3"
}),
});
console.log(await res.json());
Extract Uploaded PDF
POST /v1/pdf/extract/upload
Extract the text of an uploaded PDF. Same as /extract, for a file sent as multipart/form-data (field `file`).
| Parameter | In | Type | Description |
|---|---|---|---|
file required |
form | file |
PDF, up to 30 MB. |
mode |
form | "auto" | "text" | "ai" |
'text': the PDF's own text layer, no AI (fast, cheapest). 'auto': text layer, and AI OCR for scanned pages only. 'ai': AI on every page, for clean Markdown with headings and tables. Default auto. |
pages |
form | string |
Pages to extract, e.g. '1-5,8,10-12'. All pages when empty. |
password |
form | string |
Password of an encrypted PDF. |
curl -X POST "https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract/upload" \
-H "X-RapidAPI-Key: YOUR_API_KEY" \
-H "X-RapidAPI-Host: pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com" \
-F "file=@./my-file"
import requests
url = "https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract/upload"
headers = {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com",
}
with open("my-file", "rb") as f:
r = requests.post(url, headers=headers, files={"file": f})
print(r.json())
import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("file", new Blob([await readFile("my-file")]), "my-file");
const res = await fetch("https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract/upload", {
method: "POST",
headers: {
"X-RapidAPI-Key": "YOUR_API_KEY",
"X-RapidAPI-Host": "pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com",
},
body: form,
});
console.log(await res.json());
Response
{
"source": "https://arxiv.org/pdf/1706.03762",
"page_count": 15,
"pages_extracted": 3,
"text_pages": 0,
"ai_pages": 3,
"metadata": {
"creator": "LaTeX with hyperref",
"producer": "pdfTeX-1.40.25",
"created": "2024-04-10T21:11:43+00:00"
},
"text": "Attention Is All You Need\nAshish Vaswani ...",
"markdown": "Attention Is All You Need\n...\n## Abstract\n\nThe dominant sequence transduction models ...\n\n---\n\n...",
"pages": [
{ "page": 1, "method": "ai", "text": "Attention Is All You Need ...", "markdown": "Attention Is All You Need ..." },
{ "page": 3, "method": "ai", "text": "...", "markdown": "...\n[Figure: Output Probabilities, Softmax, Linear, Add & Norm, ...]\n..." }
]
}
A real response, shortened. Pages taken from the text layer have "method": "text" and no markdown.
How it works
- Open the PDF (decrypted with
passwordwhen needed) and read each page's own text layer. - Choose by mode:
textkeeps the text layer;autosends pages without one (scans) to the AI;aisends every page. - Read AI pages in parallel batches: scans at high resolution, digital pages at medium resolution with their native text.
Privacy
PDFs are downloaded, read and discarded: neither the file nor its text is stored by the API. Passwords are used in memory only and never logged. The AI sub-processor may keep requests temporarily for abuse monitoring.
Errors
{ "error": { "status": 400, "code": "pdf_encrypted", "message": "The PDF is password-protected: send its password." } }
| Status | code |
Meaning |
|---|---|---|
| 400 | invalid_url, invalid_request, invalid_pages |
Fix the input. |
| 400 | site_unreachable, site_blocked, file_too_large |
The PDF could not be downloaded (down, protected, over 50 MB). |
| 400 | unsupported_file, pdf_encrypted, too_many_pages |
Not a PDF or damaged, password missing, or too many pages for one call. |
| 400 | plan_limit |
Free BASIC plan: up to 20 pages, 1 of them read by the AI, per call (use pages). Paid plans go up to 500 and 100. Not billed. |
| 429 | daily_limit_reached |
Daily safety limit of your plan; resets at 00:00 UTC. |
| 503 | ai_error, capacity_exhausted |
Temporary failure. Retry. Not billed. |
Use it from an AI agent
Add this MCP server and the PDF to Text Extractor - Scanned PDF OCR actor becomes a tool your agent can call. Works in Claude, Cursor, VS Code and any MCP client; billed per event through Apify.
https://mcp.apify.com?tools=helenisapi/pdf-to-text-extractor-scanned-pdf-ocr
Prefer plain HTTP? Give your agent the OpenAPI document or the Markdown reference.