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

# Screenshots

> Capture a page, the full page or one element, as a phone, tablet or desktop, in light or dark mode, as JPEG, PNG, WebP or PDF. 1 credit.

`/screenshot` opens a URL in a headless Chrome browser, captures it, stores the image and returns a public URL to it. Cookie banners and ad slots are hidden on every capture. You choose:

* **What to capture:** the viewport, the full scrollable page (`full_page`) or one element (`selector`).
* **What to render it as:** a viewport size (`width`, `height`), or a real device (`device`) with its viewport, pixel density, touch support and user agent, so the page serves its phone or tablet layout.
* **How the page looks:** its dark theme (`dark_mode`), and with ads and trackers blocked (`block_ads`).
* **When to capture:** after a delay (`wait_for`), or once an element appears (`wait_for_selector`).
* **The output:** `jpeg` (smaller), `png` (lossless), `webp` (best compression) or `pdf` (the whole page as a document), with `quality` for JPEG and WebP.

## Example requests

```bash Default (1440×900 JPEG) theme={"theme":"css-variables"}
curl "https://api.prefetch.io/screenshot?url=https://stripe.com" \
  -H "X-API-Key: $PREFETCH_API_KEY"
```

```bash iPhone 15, dark mode theme={"theme":"css-variables"}
curl "https://api.prefetch.io/screenshot?url=https://github.com&device=iphone_15&dark_mode=true" \
  -H "X-API-Key: $PREFETCH_API_KEY"
```

```bash One element as PNG theme={"theme":"css-variables"}
curl "https://api.prefetch.io/screenshot?url=https://stripe.com/pricing&selector=%23pricing&format=png" \
  -H "X-API-Key: $PREFETCH_API_KEY"
```

```bash Full page, no ads, WebP theme={"theme":"css-variables"}
curl "https://api.prefetch.io/screenshot?url=https://www.theverge.com&full_page=true&block_ads=true&format=webp&quality=70" \
  -H "X-API-Key: $PREFETCH_API_KEY"
```

```javascript Node.js theme={"theme":"css-variables"}
const params = new URLSearchParams({
  url: "https://stripe.com",
  device: "pixel_7",
  format: "webp",
  block_ads: "true",
});

const res = await fetch(`https://api.prefetch.io/screenshot?${params}`, {
  headers: { "X-API-Key": process.env.PREFETCH_API_KEY },
});
const { data } = await res.json();
console.log(data.screenshot_url);
```

```python Python theme={"theme":"css-variables"}
import os, requests

r = requests.get(
    "https://api.prefetch.io/screenshot",
    params={"url": "https://stripe.com", "device": "pixel_7", "format": "webp", "block_ads": "true"},
    headers={"X-API-Key": os.environ["PREFETCH_API_KEY"]},
)
print(r.json()["data"]["screenshot_url"])
```

## Example response

```json theme={"theme":"css-variables"}
{
  "success": true,
  "data": {
    "url": "https://github.com",
    "screenshot_url": "https://assets.prefetch.io/screenshots/github-iphone15.jpg",
    "viewport": { "width": 393, "height": 659 },
    "format": "jpeg",
    "full_page": false,
    "captured_at": "2026-10-13T09:36:12.000Z",
    "device": "iphone_15",
    "device_scale_factor": 3,
    "dark_mode": true,
    "selector": null
  },
  "meta": {
    "requestId": "c1d2e3f4-5a6b-7c8d-9e0f-1a2b3c4d5e6f",
    "durationMs": 2450
  }
}
```

`viewport` is in CSS pixels. The image is `viewport × device_scale_factor` pixels, so an `iphone_15` capture is 1,179 pixels wide. `warnings` appears when something wasn't as you asked but the capture still happened, for example a `wait_for_selector` that never appeared.

## Devices

| `device` | Viewport | Density |
| - | - | - |
| `iphone_15` | 393 × 659 | 3× |
| `iphone_15_pro_max` | 430 × 739 | 3× |
| `iphone_se` | 320 × 568 | 2× |
| `pixel_7` | 412 × 839 | 2.625× |
| `galaxy_s8` | 360 × 740 | 3× |
| `ipad` | 810 × 1080 | 2× |
| `ipad_mini` | 768 × 1024 | 2× |
| `ipad_pro_11` | 834 × 1194 | 2× |
| `galaxy_tab_s4` | 712 × 1138 | 2.25× |
| `desktop_retina` | 1280 × 720 | 2× |

A device sets the viewport, so `width` and `height` are ignored when you pass one.

## Elements

`selector` captures the first element that matches a CSS selector, whole: `#pricing`, `header`, `.hero img`. Prefetch waits up to 10 seconds for it. If nothing matches, the request fails with `422` and `TARGET_ELEMENT_NOT_FOUND`, and isn't charged. An element can't be captured as a PDF.

`wait_for_selector` is different: it's best effort. The page is captured once the selector appears, or after 10 seconds, with a warning, if it never does.

## Formats

| Format | Best for | Notes |
| - | - | - |
| `jpeg` | General use, thumbnails | Smallest files, lossy. `quality` 1–100, default 85. |
| `png` | Logos, UI elements, exact pixels | Lossless, larger files. |
| `webp` | Web display | Best size for the quality. `quality` 1–100, default 85. |
| `pdf` | Documents, archiving | The whole page, printed with backgrounds. |

Images larger than 8 MB, such as a long page at a phone's pixel density, are scaled down until they fit.

## Limits

| Parameter | Default | Range |
| - | - | - |
| `width` | 1440 | 320–2560 |
| `height` | 900 | 240–5000 |
| `format` | `jpeg` | `jpeg`, `png`, `webp`, `pdf` |
| `full_page` | `false` | |
| `device` | none | See [Devices](#devices) |
| `dark_mode` | `false` | |
| `selector` | none | A CSS selector, up to 200 characters |
| `wait_for` | 0 | 0–30,000 ms |
| `wait_for_selector` | none | A CSS selector, up to 200 characters |
| `block_ads` | `false` | |
| `quality` | 85 | 1–100 |

## Credits

**1 credit** per capture, whatever the options. Failures are never charged.

## Next

> [card] [Batch screenshots](https://docs.prefetch.io/jobs/batches.md)
>
> Capture up to 500 URLs in one job with `POST /batch/screenshot`.

> [card] [API reference](https://docs.prefetch.io/api-reference/endpoint/screenshot.md)
>
> Every parameter, and a playground to try it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.