# Screenshot

Source: https://docs.scrappey.com/docs/screenshot

> Capture a full-page browser screenshot and receive it as a base64-encoded JPEG in the response, or have it uploaded to a public URL.

## Parameters

| Parameter          | Type    | Required | Description                                                                  |
| ------------------ | ------- | -------- | ---------------------------------------------------------------------------- |
| `screenshot`       | boolean | Yes      | Enables full-page screenshot capture and returns base64 in the response.     |
| `screenshotUpload` | boolean | No       | Also uploads the screenshot to DigitalOcean Spaces and returns a public URL. |
| `screenshotWidth`  | number  | No       | Width of the viewport before capture (in pixels). Default: 1280.             |
| `screenshotHeight` | number  | No       | Height of the viewport before capture (in pixels). Default: 1024.            |
| `fullPage`         | boolean | No       | Captures the full scrollable page height. Default: false.                    |
| `abortOnDetection` | array   | No       | List of URL patterns to block before page load (e.g. cookie-banner scripts). |
| `abortOnPostRequest` | boolean | No     | When true, only POST requests matching `abortOnDetection` are blocked.       |

Notes:

* Full-page capture is always used regardless of the resolution you set.
* Screenshots are produced as JPEG with quality 80.

## Request

Full-page base64 only:

```bash
curl -X POST "https://publisher.scrappey.com/api/v1?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "cmd": "request.get",
    "url": "https://example.com",
    "screenshot": true,
    "screenshotWidth": 1440,
    "screenshotHeight": 4000
  }'
```

Full-page base64 + upload to Spaces:

```json
{
  "cmd": "request.get",
  "url": "https://example.com",
  "screenshot": true,
  "screenshotUpload": true,
  "screenshotWidth": 1920,
  "screenshotHeight": 1080
}
```

Blocking cookie banners for a clean screenshot:

```json
{
  "cmd": "request.get",
  "url": "https://example.com",
  "screenshot": true,
  "abortOnDetection": [
    "cookiebot.com",
    "onetrust.com",
    "quantcast.com",
    "trustarc.com",
    "/consent",
    "gdpr-consent",
    "cookie-law-info"
  ]
}
```

If any network request URL contains one of the specified values, it will be aborted before loading.

## Response

| Field                    | Type   | Description                                                                                                                                                |
| ------------------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `solution.screenshot`    | string | Base64-encoded JPEG of the full page.                                                                                                                      |
| `solution.screenshotUrl` | string | Public URL in Spaces, present only when `screenshotUpload: true`. Filenames include a prefix with dimensions: `screenshots/{width}x{height}_{random}.jpg`. |
| `abortOnDetectionResponse` | array | List of blocked requests, each with URL, headers, and payload. Present when `abortOnDetection` is used. |

Response snippet when `screenshotUpload: true`:

```json
{
  "solution": {
    "screenshot": "<base64>",
    "screenshotUrl": "https://<bucket-cdn>/screenshots/1920x1080_abCDeFgHiJKLmNopQrSt.jpg"
  }
}
```

## Blocking Cookie Banners

Many websites show cookie or GDPR consent banners that can cover content and appear in screenshots. Use `abortOnDetection` to block the network requests these banners depend on before the page loads.

The browser intercepts all network requests while loading the page. If a request URL matches a pattern you specify, that request is blocked. Cookie banners often fail to load when their consent or tracking scripts are blocked, preventing the banner from ever appearing.

Common providers whose URLs you may want to block:

* Cookiebot
* OneTrust
* Quantcast
* TrustArc
* Cookie Law Info
* Custom GDPR or consent endpoints

Their request URLs often contain keywords like: `cookie`, `consent`, `gdpr`, `privacy`.

By default, all matching requests are blocked. Set `abortOnPostRequest: true` to restrict blocking to POST requests only.

After the page loads, blocked requests are available in `abortOnDetectionResponse`. Each entry includes the request URL, headers, and payload (if present) — useful for debugging or fine-tuning which patterns you block.

## Tips

* Base64 payloads can be large. If response size is a concern, prefer `screenshotUpload: true`.
* Choose `screenshotWidth` / `screenshotHeight` to influence layout before capture.
* JPEG is used to optimize size.
* Blocking cookie banners improves screenshot consistency across sites.
* For a full session recording instead of a single still, use [Record Video](/docs/record-video).

## Related concepts

Go deeper in the [Scrappey knowledge base](https://scrappey.com/qa):

- [Headless browser](https://scrappey.com/qa/web-scraping-apis/what-is-a-headless-browser) — what renders the page you capture
- [Headless browsers](https://scrappey.com/qa/web-automation/headless-browsers-guide) — driving a real browser to scrape
