PDF to text API in Python
Extract the text of a PDF at a URL from Python with one GET request: no PDF library to install, the answer is JSON with one entry per page.
PDF to text API: monthly plans and one-off packs, one API key.
Python example
import os, requests
API = "https://agent-data-tools.revmesh2074.workers.dev/pdf/text"
HEADERS = {"Authorization": f"Bearer {os.environ['API_KEY']}"}
def pdf_text(url, first_page=1, pages=20):
r = requests.get(API, params={"url": url, "firstPage": first_page, "pages": pages}, headers=HEADERS, timeout=60)
r.raise_for_status()
return r.json()
doc = pdf_text("https://bitcoin.org/bitcoin.pdf")
print(doc["totalPages"], "pages")
for page in doc["pages"]:
print(page["page"], page["text"][:200])Set API_KEY to a key from /credits.
When an agent wants this
- Read a PDF in a script or notebook without pdfminer or PyPDF
- Loop over a long report 20 pages at a time
- Hand page text to an LLM or an embedding step
PDF to text, PDF text extraction: extract the text of a PDF document from a URL, page by page $0.005
Extract the text of a public PDF (up to 10 MB) from its URL, page by page, with title, author and page count. Choose the first page, how many pages (up to 200) and maxChars. arXiv abstract links work. If a site blocks our fetch, the Internet Archive's dated copy is read and the answer says so. Scanned, encrypted and non-PDF files fail uncharged. Use to read papers, invoices, reports and manuals into an agent.
Inputs: url (required): Absolute public http(s) URL of the PDF; firstPage: First page to read (default 1); pages: How many pages to read (1-200, default 20); maxChars: Maximum characters of text returned across all pages (1000-200000, default 50000).
Not in the free calls over HTTP; pay from the first call.
With prepaid credits this tool costs $0.002 a call: $1 by card pays for 500 calls, with no account and no subscription.
With a card key from /credits, in a header or, when your client can only fetch a URL, in the URL:
curl -H "Authorization: Bearer adt_…" "https://agent-data-tools.revmesh2074.workers.dev/pdf/text?url=https%3A%2F%2Fbitcoin.org%2Fbitcoin.pdf"
curl "https://agent-data-tools.revmesh2074.workers.dev/pdf/text?url=https%3A%2F%2Fbitcoin.org%2Fbitcoin.pdf&api_key=adt_…"
Without a key the same URL answers 402 Payment Required with x402 and MPP terms, so a wallet client pays USDC per call and retries. Over MCP (https://agent-data-tools.revmesh2074.workers.dev/mcp) this tool is pdf_text.
Example result
{
"url": "https://bitcoin.org/bitcoin.pdf",
"title": null,
"author": null,
"totalPages": 9,
"firstPage": 1,
"pagesRead": 1,
"chars": 46,
"truncated": true,
"pages": [
{
"page": 1,
"chars": 46,
"text": "Bitcoin: A Peer-to-Peer Electronic Cash System"
}
]
}Questions
Do I need a PDF library?
No. The file is fetched and parsed on the server; your script only needs an HTTP client such as requests.
How do I read a whole long PDF?
Call it in steps: firstPage 1, 21, 41 and so on with pages 20, until firstPage passes totalPages. Up to 200 pages fit in one call.
Does it OCR scanned PDFs?
No, it extracts the text layer. Scanned images without text return little or nothing.
How do I pay?
Each successful call costs the tool's price; failed calls are not charged. Then pay with card credits from $1 (the key goes in an Authorization header or as api_key= in the URL) or per call in USDC over x402 or MPP. No account is needed.