---
agent:
  instructions: "Search crawlapi docs via GET /.well-known/search?q={query} (add &format=json or Accept: application/json for JSON)."
  endpoint: "https://docs.crawlapi.dev/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://docs.crawlapi.dev/llms.txt"
---

> Documentation index: https://docs.crawlapi.dev/llms.txt
> Search docs: https://docs.crawlapi.dev/.well-known/search?q={query}
> OpenAPI 3.1 specification: https://docs.crawlapi.dev/openapi.json

# PDFs and documents

> Extract text and tables from PDF, Office, OpenDocument, EPUB, RTF, CSV, JSON, and RSS/Atom URLs.

Pass a document URL to `POST /v1/scrape` the same way you scrape a web page. crawlapi detects the file type automatically and extracts clean markdown or structured tables.

## Example

**cURL**

```bash
curl -sS https://api.crawlapi.dev/v1/scrape \
  -H "Authorization: Bearer $CRAWLAPI_API_KEY" \
  -H 'content-type: application/json' \
  --data '{"url": "https://arxiv.org/pdf/1706.03762"}'
```

**TypeScript**

```typescript
const response = await fetch('https://api.crawlapi.dev/v1/scrape', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CRAWLAPI_API_KEY}`,
    'content-type': 'application/json',
  },
  body: JSON.stringify({ url: 'https://arxiv.org/pdf/1706.03762' }),
});
const body = await response.json();
if (!body.success) throw new Error(`${body.error.code}: ${body.error.message}`);
console.log(body.data.metadata.title);
console.log(body.data.markdown.slice(0, 500));
```

**Python**

```python
import os
import requests

response = requests.post(
    "https://api.crawlapi.dev/v1/scrape",
    headers={"Authorization": f"Bearer {os.environ['CRAWLAPI_API_KEY']}"},
    json={"url": "https://arxiv.org/pdf/1706.03762"},
    timeout=65,
)
body = response.json()
if not body["success"]:
    raise RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
print(body["data"]["metadata"]["title"])
print(body["data"]["markdown"][:500])
```

Parsed text returns in `data.markdown`, or extracted tables in `data.json` when you pass `"format": "json"`.

## Supported formats

| Format | `format: "markdown"` | `format: "json"` |
| --- | --- | --- |
| PDF | Text, headings, and tables (up to `300` pages) | Extracted tables |
| Office (`DOCX`, `XLSX`, `XLSM`, `XLSB`, `PPTX`, `DOC`, `XLS`, `PPT`) | Paragraphs, headings, sheets, and slides as markdown | Extracted tables |
| OpenDocument (`ODT`, `ODS`, `ODP`) | Paragraphs, sheets, and slides | Extracted tables |
| EPUB, RTF | Book and document text as markdown | Extracted tables, if any |
| CSV | Single Markdown table | Single table |
| JSON | Fenced `json` code block | Parsed payload in `embedded` plus extracted record tables |
| RSS / Atom feeds | Title, description, and feed entries | Table of entries (`title`, `link`, `published`, `author`, `summary`) |
| Plain text / Markdown | Decoded text | Parsed Markdown tables, if any |

RSS and Atom feeds populate `data.links` with entry URLs; other document formats return `[]`.

## Choosing markdown vs JSON

- **Use `format: "markdown"`** for reading and indexing PDFs, Word documents, slide decks, EPUBs, RTFs, and feed summaries as clean prose with headings and Markdown tables. See [Markdown](https://docs.crawlapi.dev/markdown.md) for link and output-size rules.
- **Use `format: "json"`** when you want structured rows from CSVs, spreadsheets (`XLSX`/`ODS`), PDFs with tables, RSS/Atom feed entries (`tables`), or raw parsed payloads from JSON endpoints (`embedded`). See [Structured JSON](https://docs.crawlapi.dev/json.md) for the four JSON keys.

## Limits and failure codes

| Condition | Result |
| --- | --- |
| File size over `32 MiB` | `422 UNSUPPORTED_CONTENT` (`retryable: false`), except CSV and plain text/markdown which truncate cleanly with `metadata.truncated: true` |
| PDF over `300` pages | First `300` pages returned with `metadata.truncated: true` |
| Scanned image-only PDF (no text layer) | `422 SCANNED_PDF` (`retryable: false`) — OCR is not supported |
| Password-protected PDF or Office file | `422 LOGIN_REQUIRED` (`retryable: false`) |
| Empty file, or `format: "json"` with no tables or JSON data | `422 NO_CONTENT` (`retryable: false`) — use `format: "markdown"` for plain text |
| Images, audio, video, archives, or unreadable files | `422 UNSUPPORTED_CONTENT` (`retryable: false`) |

See [Errors and retries](https://docs.crawlapi.dev/errors.md) for the full error schema and retry helpers.
