Guide / Documents

PDF text extraction that runs where your code already runs

Parsers assume a filesystem, a canvas and a few hundred milliseconds of CPU you may not have. A POST is easier than a runtime.

Why this is annoying in a worker

Most PDF libraries pull in a native canvas for layout, assume Node built-ins, or want 300ms of CPU per page. In an edge runtime that is either unavailable or priced differently than you expect. The alternative is to move parsing out of your process entirely.

The request

Send a URL or a base64 payload. URL is better for anything large: no encoding cost, and the fetch happens on our side.

curl -s -X POST 'https://docparse.p.rapidapi.com/v1/pdf/text' \
  -H 'Content-Type: application/json' \
  -H 'X-RapidAPI-Key: YOUR_KEY' \
  -H 'X-RapidAPI-Host: docparse.p.rapidapi.com' \
  -d '{"url":"https://arxiv.org/pdf/1810.04805"}'
const res = await fetch('https://docparse.p.rapidapi.com/v1/pdf/text', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
    'X-RapidAPI-Host': 'docparse.p.rapidapi.com'
  },
  body: JSON.stringify({ url: pdfUrl })
});
const { text, pages, pageCount, words } = await res.json();

HTML is the same call shape

{
  "url": "https://example.com/",
  "title": "Example Domain",
  "text": "This domain is for use in documentation examples...",
  "characters": 156,
  "words": 25,
  "truncated": false
}

Choosing an endpoint

EndpointReturnsWhen to use
POST /v1/pdf/textfull text, per-page text, page count, wordsthe default for search, summarising, chunking
POST /v1/pdf/infometadata, page count, version, sizevalidation before you pay for extraction
POST /v1/pdf/pagesonly the pages you listlong documents where you need one section
POST /v1/docx/textheadings, lists, tables, paragraphsWord documents from customers
POST /v1/html/textreadable text, title, bylinearticles, blog posts, help pages
POST /v1/html/markdownclean markdownfeeding a model or a CMS

Limits, stated plainly

  • No OCR. A scanned PDF has no text layer, so the text comes back empty. That is a different service.
  • Encrypted or password-protected files are rejected with a clear error rather than a partial parse.
  • A 100-page, 45,000-word PDF takes about three seconds. A 16-page paper is under one.
  • Nothing is stored. The file is held in memory for the request and dropped.

Try DocParse

Pay as you go at $0.05 a call, no monthly minimum. or a monthly plan from $25 once the volume justifies it.

Open the listing on RapidAPI