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

# Scrape

> Turn any URL into clean Markdown or structured data

Scrape turns any URL into clean Markdown or structured data for AI agents, including JavaScript-heavy pages and dynamic apps.

* It manages the complexities: browser rendering, caching, ads and cookie banners
* Handles dynamic content: JavaScript-rendered sites, and clicks and waits before reading
* Outputs clean Markdown, structured data, screenshots or HTML

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

> [!NOTE]
>
> If a request fails, see [Errors](/api-reference/errors.md) for the error codes and what to do about each one.

## Scraping a URL with ScreenshotRender

### /scrape endpoint

Used to scrape a URL and get its content.

### Installation

```bash Python
pip install screenshotrender
```

```bash Node
npm install screenshotrender
```

### Usage

```python Python
from screenshotrender import ScreenshotRender

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

doc = screenshotrender.scrape("https://example.com", formats=["markdown", "html"])
print(doc.markdown)
```

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

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

const doc = await screenshotrender.scrape("https://example.com", {
  formats: ["markdown", "html"],
});
console.log(doc.markdown);
```

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "formats": ["markdown", "html"]
  }'
```

For more details about the parameters, refer to the [API Reference](/api-reference/endpoint/scrape.md).

> [!TIP]
>
> **PDFs and documents:** to read a PDF or another document from a URL, or to upload one from disk, use [Parse](/features/parse.md).

> [!NOTE]
>
> Each scrape costs 1 credit. JSON, question and highlights formats cost 4 more credits per page. See [Billing](/billing.md) for every cost.

### Response

SDKs return the data object directly. cURL returns the payload exactly as shown below.

```json Response
{
  "success": true,
  "data": {
    "markdown": "This domain is for use in documentation examples without needing permission. This is not a service; avoid relying on it for testing and monitoring purposes.\n\nهذا النطاق مُخصص للاستخدام في أمثلة التوثي...",
    "html": "<!DOCTYPE html><html lang=\"en\"><body><svg viewBox=\"0,0,20,20\" width=\"44\" height=\"44\" fill=\"currentColor\" aria-hidden=\"tr...",
    "metadata": {
      "title": "Example Domain",
      "language": "en",
      "sourceURL": "https://example.com/",
      "url": "https://example.com/",
      "statusCode": 200,
      "contentType": "text/html; charset=utf-8",
      "proxyUsed": "basic",
      "cacheState": "hit",
      "cachedAt": "2026-12-03T12:13:45.080Z"
    }
  },
  "creditsUsed": 1
}
```

### Response metadata and status codes

There are two status layers in a scrape response:

* **Request status**: the HTTP status of the call itself, with the `success` boolean in the body. A processed request returns HTTP `200` with `success: true`, even when the page underneath returned an error code.
* **Page status** (`data.metadata.statusCode`): the HTTP status the website returned for the page, like `200`, `404` or `500`.

So first check that the request succeeded (`success: true`), then check `data.metadata.statusCode` for how the page itself responded.

Other metadata fields include `title`, `description`, `language`, `sourceURL` (the URL you asked for), `url` (the URL after redirects), `contentType`, and `cacheState` with `cachedAt` when the page came from the cache (see [maxAge](/advanced-scraping-guide.md#cache-and-max-age)).

## Scrape Formats

Choose the formats you want in `formats`. You can ask for several at once, and each one comes back under its own key in `data`.

| Format | Returns | Credits per page |
| - | - | - |
| `markdown` (default) | `data.markdown`: clean Markdown of the page | 1 |
| `summary` | `data.summary`: a short summary of the page | 1 |
| `html` | `data.html`: cleaned HTML | 1 |
| `rawHtml` | `data.rawHtml`: the HTML the server sent, unmodified | 1 |
| `links` | `data.links`: every link on the page | 1 |
| `images` | `data.images`: every image URL on the page | 1 |
| `screenshot` | `data.screenshot`: a link to a PNG, kept 30 days. See [Screenshot](/features/screenshot.md) | 1 |
| `branding` | `data.branding`: the brand name, colors, fonts, logo and design system | 1 |
| `{ "type": "json", ... }` | `data.json`: structured data. See [JSON mode](/features/llm-extract.md) | 5 |
| `{ "type": "question", ... }` | `data.answer`: the answer to a question about the page | 5 |
| `{ "type": "highlights", ... }` | `data.highlights`: the passages that match a query | 5 |

A request with several formats costs 1 credit for the page plus the extra for each paid format.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.screenshotrender.com",
    "formats": ["summary", "rawHtml", "links", "images", "branding"]
  }'
```

```json Response
{
  "success": true,
  "data": {
    "rawHtml": "<!DOCTYPE html><html lang=\"en\" class=\"geist_2ae47f08-module__h69qWW__variable geist_mono_eb58308d-module__w_p2Lq__variab...",
    "links": [
      "https://www.screenshotrender.com/playground",
      "https://www.screenshotrender.com/#integrations",
      "https://www.screenshotrender.com/pricing",
      "... 4 more"
    ],
    "images": [
      "https://www.screenshotrender.com/_next/image?url=%2Fmake_.png&w=256&q=75",
      "https://www.screenshotrender.com/_next/image?url=%2Fn8n.png&w=256&q=75",
      "https://www.screenshotrender.com/_next/image?url=%2FAirtable.png&w=256&q=75",
      "... 5 more"
    ],
    "summary": "ScreenshotRender provides a robust API for capturing website screenshots without clutter such as cookie banners and ads. The service promises automated UI cleanup, enabling users to get clean, production-ready images with minimal setup. It...",
    "metadata": {
      "title": "ScreenshotRender · Screenshot API for Cloudflare, SPAs, and clean previews",
      "description": "Render a pixel-perfect screenshot of any URL. A Cloudflare screenshot, a JavaScript-heavy SPA, or a cookie-banner-free p...",
      "language": "en",
      "sourceURL": "https://www.screenshotrender.com/",
      "url": "https://www.screenshotrender.com/",
      "statusCode": 200,
      "contentType": "text/html; charset=utf-8",
      "proxyUsed": "basic"
    },
    "branding": {
      "brandName": "ScreenshotRender",
      "colorScheme": "light",
      "colors": {
        "primary": "#FF7A00",
        "secondary": "#364153",
        "accent": "#FF6900",
        "background": "#FFFFFF",
        "textPrimary": "#030712",
        "link": "#FF6900"
      },
      "fonts": [
        {
          "family": "Arial",
          "role": "body"
        }
      ],
      "...": "typography, spacing, components, images, logo and more"
    }
  },
  "creditsUsed": 1
}
```

## Extract structured data

### /scrape (with json) endpoint

Used to extract structured data from scraped pages. Describe the data with a JSON Schema (or a Pydantic model in Python), and it comes back in `data.json`.

```python Python
from pydantic import BaseModel
from screenshotrender import ScreenshotRender

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

class Story(BaseModel):
    title: str
    points: int

class TopStories(BaseModel):
    stories: list[Story]

doc = screenshotrender.scrape(
    "https://news.ycombinator.com",
    formats=[{"type": "json", "prompt": "The top 3 stories", "schema": TopStories}],
)
print(doc.json)
```

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

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

const schema = {
  type: "object",
  properties: {
    stories: {
      type: "array",
      items: {
        type: "object",
        properties: { title: { type: "string" }, points: { type: "number" } },
        required: ["title", "points"],
      },
    },
  },
  required: ["stories"],
};

const doc = await screenshotrender.scrape("https://news.ycombinator.com", {
  formats: [{ type: "json", prompt: "The top 3 stories", schema }],
});
console.log(doc.json);
```

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://news.ycombinator.com",
    "formats": [
      {
        "type": "json",
        "prompt": "The top 3 stories",
        "schema": {
          "type": "object",
          "properties": {
            "stories": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "title": { "type": "string" },
                  "points": { "type": "number" }
                },
                "required": ["title", "points"]
              }
            }
          },
          "required": ["stories"]
        }
      }
    ]
  }'
```

Output:

```json Response
{
  "success": true,
  "data": {
    "json": {
      "stories": [
        {
          "title": "NSA advises immediate transition to post-quantum cryptography",
          "points": 2373
        },
        {
          "title": "Anatomy of an AI Kill Chain",
          "points": 240
        },
        {
          "title": "Show HN: misa77 – Up to 3x faster decompression than zstd, with better ratios",
          "points": 89
        }
      ]
    },
    "metadata": {
      "title": "Hacker News",
      "language": "en",
      "sourceURL": "https://news.ycombinator.com/",
      "url": "https://news.ycombinator.com/",
      "statusCode": 200,
      "contentType": "text/html; charset=utf-8",
      "proxyUsed": "basic",
      "cacheState": "hit",
      "cachedAt": "2026-12-03T12:15:08.498Z"
    }
  },
  "creditsUsed": 5
}
```

You can also extract without a schema, with only a prompt. See [JSON mode](/features/llm-extract.md).

## Question format

Ask a question about the page. The answer comes back in `data.answer`.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "formats": [
      { "type": "question", "question": "Who may use this domain, and for what?" }
    ]
  }'
```

```json Response
{
  "success": true,
  "data": {
    "answer": "This domain is for use in documentation examples without needing permission.",
    "metadata": {
      "title": "Example Domain",
      "language": "en",
      "sourceURL": "https://example.com/",
      "url": "https://example.com/",
      "statusCode": 200,
      "contentType": "text/html; charset=utf-8",
      "proxyUsed": "basic",
      "cacheState": "hit",
      "cachedAt": "2026-12-03T12:20:11.503Z"
    }
  },
  "creditsUsed": 5
}
```

## Highlights format

Get the passages of the page that match a query, in `data.highlights`.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.python.org/3/tutorial/introduction.html",
    "formats": [
      { "type": "highlights", "query": "how strings are written" }
    ]
  }'
```

```json Response
{
  "success": true,
  "data": {
    "highlights": "Python can manipulate text (represented by type [str](https://docs.python.org/3/builtins/stdtypes.html#str), so-called “strings”) as well as numbers. This includes characters “!”, words “rabbit”, names “Paris”, sentences “Got your back.”, etc. “Yay! :)”. They can be enclosed in single quotes ('...')...",
    "metadata": {
      "title": "3. An Informal Introduction to Python — Python 3.15.2 documentation",
      "description": "In the following examples, input and output are distinguished by the presence or absence of prompts (>>> and …): to repe...",
      "language": "en",
      "sourceURL": "https://docs.python.org/3/tutorial/introduction.html",
      "url": "https://docs.python.org/3/tutorial/introduction.html",
      "statusCode": 200,
      "contentType": "text/html",
      "proxyUsed": "basic",
      "cacheState": "hit",
      "cachedAt": "2026-12-03T11:23:52.448Z"
    }
  },
  "creditsUsed": 5
}
```

## Interacting with the page with Actions

Run actions on the page before it is read: wait, click, and take screenshots along the way. Actions run in order.

```bash cURL
curl -s -X POST "https://www.screenshotrender.com/api/v1/scrape" \
  -H "Authorization: Bearer $SCREENSHOTRENDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.python.org/3/",
    "formats": ["markdown"],
    "actions": [
      { "type": "wait", "milliseconds": 1000 },
      { "type": "click", "selector": "a[href=\"tutorial/index.html\"]" },
      { "type": "wait", "milliseconds": 1000 },
      { "type": "screenshot" }
    ]
  }'
```

```json Response
{
  "success": true,
  "data": {
    "markdown": "### Navigation\n\n- [index](https://docs.python.org/3/genindex.html \"General Index\")\n- [modules](https://docs.python.org/3/py-modindex.html \"Python Module Index\")...",
    "actions": {
      "screenshots": [
        "https://www.screenshotrender.com/files/screenshots/yqQzq-6RCimYa79f9K_tiyJ6vD2cC5No.png"
      ],
      "scrapes": [],
      "javascriptReturns": [],
      "pdfs": []
    },
    "metadata": {
      "title": "The Python Tutorial — Python 3.15.2 documentation",
      "description": "Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but...",
      "language": "en",
      "sourceURL": "https://docs.python.org/3/",
      "url": "https://docs.python.org/3/tutorial/index.html",
      "statusCode": 200,
      "contentType": "text/html",
      "proxyUsed": "basic"
    }
  },
  "creditsUsed": 1
}
```

Each `screenshot` action adds a link to `data.actions.screenshots`. See the [Advanced scraping guide](/advanced-scraping-guide.md#actions) for every action.

## More page options

Read only the main content, keep or drop parts of the page, wait for late content, load the page from another country or as a phone, send your own headers, and accept cached pages. See the [Advanced scraping guide](/advanced-scraping-guide.md).
