# Extract Text from PDF API

> Extract the text of a PDF, by URL or as an inline base64 upload. Optionally restrict it to a page range and detect tables, returned as Markdown. Runs locally on PDFium — no third-party document API, no per-page fee.

Category: [Tools APIs](https://upapi.io/apis/tools) · Last updated 2026-11-02

## How to call it

- Endpoint: `POST https://api.upapi.io/pdf-extract-text.post`, key in the `X-Api-Key` header, JSON body.
- Cost: 2 weighted units per call.
- Timeout: 25 seconds.
- Cache: identical requests are served from cache for 86400 seconds, unbilled.
- Try it without writing code: https://app.upapi.io/try/pdf-extract-text.post

```bash
curl -X POST https://api.upapi.io/pdf-extract-text.post \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{ "url": "https://example.com/report.pdf", "tables": false }'
```

## Request parameters

- `url` (string) — Public URL of the PDF to read (e.g. https://example.com/report.pdf). Provide this OR `file`, not both.
- `file` (string) — The PDF itself, base64-encoded (no data: URI prefix). Max 3.7 MB decoded — base64 inflates by 4/3 and the API request body is capped at 5 MB. Supply `url` instead for anything larger. Expected media type application/pdf.
- `pages` (string) — Page range to extract, 1-based and inclusive (e.g. 1-5,8,11-13). Omit for the whole document.
- `tables` (boolean) — Also detect tables and return each one as a Markdown table (e.g. false). Slower — leave off unless you need them.

## Response fields

- `text` (string, required) — All extracted text, pages joined by a blank line
- `pages` (integer, required) — Number of pages the document contains
- `tables` (array) — Detected tables; null unless `tables` was true
- `pageTexts` (array, required) — Text of each extracted page, in order
- `truncated` (boolean, required) — True when output was cut at the 600000-character response cap
- `extractedPages` (array, required) — 1-based page numbers actually extracted

## Example request and response

The example response is generated from the published output schema: it shows the shape and field names, not values from a recorded call.

```json
{
  "url": "https://example.com/report.pdf",
  "tables": false
}
```

```json
{
  "text": "Hello, world",
  "pages": 1,
  "tables": [
    {
      "page": 1,
      "rows": 1,
      "index": 1,
      "columns": 1,
      "markdown": "example"
    }
  ],
  "pageTexts": [
    "example"
  ],
  "truncated": false,
  "extractedPages": [
    1
  ]
}
```

## Frequently asked questions

### How much does the Extract Text from PDF API cost per call?

Each call spends 2 weighted units of your plan's monthly quota. Full pricing is at https://upapi.io/pricing.

### How do I authenticate to the Extract Text from PDF API?

Send your key in the X-Api-Key header. A free guest key is available without creating an account.

### Are Extract Text from PDF API responses cached?

Yes — identical requests are served from cache for 86400 seconds, and a cache hit is not billed.

## More Tools APIs

- [OCR an Image](https://upapi.io/apis/tools/image-ocr)
- [Render HTML or URL to PDF](https://upapi.io/apis/tools/html-to-pdf)
- [Fetch URL as Markdown](https://upapi.io/apis/tools/fetch-markdown)
- [Get Cloudflare Page Title](https://upapi.io/apis/tools/cloudflare-page-title)
- [Search Hacker News](https://upapi.io/apis/tools/hackernews-search)
- [Capture Website Screenshot](https://upapi.io/apis/tools/screenshot)
