> ## Documentation Index
> Fetch the complete documentation index at: /llms.txt
> Use this file to discover all available pages before exploring further.

# Parse

> Turn documents (PDFs, Word files, spreadsheets and more) into clean Markdown

Parse turns a document into clean Markdown: a PDF, a Word file, a spreadsheet and more. Send the URL of a public document, or upload a file from disk.

For details, see the [Parse Endpoint API Reference](/api-reference/endpoint/parse.md).

## Quickstart

### Installation

```bash Python
pip install screenshotrender
```

```bash Node
npm install screenshotrender
```

### Parse a document from a URL

Send the document's URL as JSON. For a PDF, `maxPages` caps how many pages are read, and billed.

```python Python
from screenshotrender import ScreenshotRender

screenshotrender = ScreenshotRender(api_key="sr-YOUR-API-KEY")

paper = screenshotrender.parse(
    "https://arxiv.org/pdf/1706.03762",
    parsers=[{"type": "pdf", "max_pages": 2}],
)
print(paper.markdown)
```

```js Node
import ScreenshotRender from "screenshotrender";

const screenshotrender = new ScreenshotRender({ apiKey: "sr-YOUR-API-KEY" });

const paper = await screenshotrender.parse("https://arxiv.org/pdf/1706.03762", {
  parsers: [{ type: "pdf", maxPages: 2 }],
});
console.log(paper.markdown);
```

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/parse" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://arxiv.org/pdf/1706.03762",
    "parsers": [{ "type": "pdf", "maxPages": 2 }]
  }'
```

```json Response
{
  "success": true,
  "data": {
    "markdown": "### Provided proper attribution is provided, Google hereby grants permission to\n\nreproduce the tables and figures in this paper solely for use in journalistic or scholarly works.\n\n## Attention Is All You Need\n\n**Ashish Vaswani<sup>∗</sup> Noam Shazeer<sup>∗</sup> Niki Parmar<sup>∗</sup> Jakob Uszkor...",
    "metadata": {
      "sourceURL": "https://arxiv.org/pdf/1706.03762",
      "url": "https://arxiv.org/pdf/1706.03762",
      "statusCode": 200,
      "contentType": "application/pdf",
      "numPages": 2,
      "totalPages": 15,
      "proxyUsed": "basic",
      "cacheState": "miss"
    }
  },
  "creditsUsed": 2
}
```

`numPages` is the number of pages read, and `totalPages` the length of the document. This paper has 15 pages; the request read 2 and cost 2 credits.

### Upload a file

Send the file as `multipart/form-data`, in a field named `file`. In Python, pass a path, bytes or an open file. In Node, pass the bytes and the file name.

```python Python
from screenshotrender import ScreenshotRender

screenshotrender = ScreenshotRender(api_key="sr-YOUR-API-KEY")

report = screenshotrender.parse("report.pdf")  # a path, bytes or an open file
print(report.markdown)
```

```js Node
import { readFile } from "node:fs/promises";
import ScreenshotRender from "screenshotrender";

const screenshotrender = new ScreenshotRender({ apiKey: "sr-YOUR-API-KEY" });

const report = await screenshotrender.parse({
  data: await readFile("report.pdf"),
  filename: "report.pdf",
});
console.log(report.markdown);
```

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/parse" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -F "file=@report.pdf"
```

## Response

```json Response
{
  "success": true,
  "data": {
    "markdown": "## Quarterly report\n\nRevenue grew 12 percent in the third quarter.\nThe team shipped the new API and the SDKs.",
    "metadata": {
      "sourceURL": "report.pdf",
      "statusCode": 200,
      "contentType": "application/pdf",
      "numPages": 1,
      "totalPages": 1,
      "proxyUsed": "basic"
    }
  },
  "creditsUsed": 1
}
```

## Options with an upload

With an upload, send options as JSON in a form field named `options`. They are the same page options as [Scrape](/features/scrape.md), like `formats`.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/parse" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -F "file=@cities.csv" \
  -F 'options={"formats":["markdown","summary"]}'
```

```json Response
{
  "success": true,
  "data": {
    "markdown": "| city | country | population |\n| --- | --- | --- |\n| Tokyo | Japan | 37400000 |\n| Delhi | India | 31000000 |\n| Shanghai | China | 27100000 |\n",
    "summary": "The page provides a list of cities along with their respective countries and population figures. Key cities mentioned include Tokyo in Japan with a population of 37,400,000; Delhi in India with 31,000,000; and Shanghai in China with 27,100,000.",
    "metadata": {
      "sourceURL": "cities.csv",
      "statusCode": 200,
      "contentType": "application/octet-stream",
      "proxyUsed": "basic"
    }
  },
  "creditsUsed": 1
}
```

A spreadsheet comes back as a Markdown table.

## Supported formats

Upload any of these the same way, like this Word file:

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/parse" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -F "file=@notes.docx"
```

Its text comes back in `data.markdown`.

| Kind | Extensions |
| - | - |
| Documents | `.pdf`, `.docx`, `.doc`, `.docm`, `.odt`, `.rtf` |
| Spreadsheets | `.xlsx`, `.xls`, `.xlsm`, `.xlsb`, `.ods`, `.csv` |
| Presentations | `.pptx`, `.ppt`, `.pptm`, `.odp` |
| Other | `.epub`, `.html`, `.htm`, `.xhtml` |

Uploading any other file type answers `415` with the code `unsupported_file_type`.

## Considerations

* **Size:** uploads are limited to 4 MB. A bigger file answers `413` with the code `file_too_large`: parse it from a URL instead.
* **Cost:** a PDF costs 1 credit per page read. Any other document costs 1 credit. Formats like `json` add their own cost, see [Billing](/billing.md).
* **Uploads or URLs:** send one or the other. A request with both is refused.
