> ## 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.

# GET /screenshot

> Capture a webpage screenshot and get a public URL to the image. Costs 2 credits.

## Overview

`/screenshot` opens a URL in a headless Chrome browser and captures a screenshot. The image is stored in cloud storage and a public URL is returned. You can configure:

* **Viewport size** — width and height of the browser window
* **Full page** — capture the entire scrollable content instead of just the viewport
* **Format** — JPEG (smaller), PNG (lossless), or WebP (best compression)

## Example requests

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

  ```bash Mobile viewport theme={null}
  curl "https://api.prefetch.io/screenshot?url=https://stripe.com&width=390&height=844" \
    -H "X-API-Key: $PREFETCH_API_KEY"
  ```

  ```bash Full page PNG theme={null}
  curl "https://api.prefetch.io/screenshot?url=https://stripe.com&full_page=true&format=png" \
    -H "X-API-Key: $PREFETCH_API_KEY"
  ```

  ```javascript Node.js theme={null}
  const params = new URLSearchParams({
    url: "https://stripe.com",
    width: "1280",
    height: "800",
    format: "webp",
    full_page: "false",
  });

  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);
  ```
</CodeGroup>

## Example response

```json theme={null}
{
  "success": true,
  "data": {
    "url": "https://stripe.com",
    "screenshot_url": "https://assets.prefetch.io/screenshots/stripe-1440x900-abc123.jpg",
    "viewport": {
      "width": 1440,
      "height": 900
    },
    "format": "jpeg",
    "full_page": false,
    "captured_at": "2026-03-19T14:22:05.000Z"
  },
  "meta": {
    "requestId": "c1d2e3f4-5a6b-7c8d-9e0f-1a2b3c4d5e6f",
    "durationMs": 2540
  }
}
```

## Format comparison

| Format | Best for                         | Notes                                 |
| ------ | -------------------------------- | ------------------------------------- |
| `jpeg` | General use, thumbnails          | Smallest file size, lossy compression |
| `png`  | Logos, UI elements, transparency | Lossless, larger files                |
| `webp` | Web display                      | Best compression-to-quality ratio     |

## Parameter limits

| Parameter   | Default | Min | Max  |
| ----------- | ------- | --- | ---- |
| `width`     | 1440    | 320 | 5000 |
| `height`    | 900     | 320 | 5000 |
| `format`    | `jpeg`  | —   | —    |
| `full_page` | `false` | —   | —    |


## OpenAPI

````yaml GET /screenshot
openapi: 3.1.0
info:
  title: Prefetch API
  description: >-
    Extract brand identity, company data, screenshots, and IAB classifications
    from any URL.
  version: 1.0.0
  contact:
    email: support@prefetch.io
servers:
  - url: https://api.prefetch.io
    description: Production
security:
  - apiKey: []
tags:
  - name: Endpoints
    description: Data extraction endpoints. All require authentication and consume credits.
  - name: Health
    description: Health and readiness probes. No authentication required.
paths:
  /screenshot:
    get:
      tags:
        - Endpoints
      summary: Take a screenshot
      description: >-
        Captures a screenshot of a webpage and returns a public URL to the image
        stored in cloud storage. **Credit cost: 2.**
      operationId: takeScreenshot
      parameters:
        - $ref: '#/components/parameters/url'
        - $ref: '#/components/parameters/screenshotWidth'
        - $ref: '#/components/parameters/screenshotHeight'
        - $ref: '#/components/parameters/screenshotFormat'
        - $ref: '#/components/parameters/screenshotFullPage'
      responses:
        '200':
          description: Screenshot result.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                  data:
                    $ref: '#/components/schemas/ScreenshotData'
                  meta:
                    $ref: '#/components/schemas/Meta'
                required:
                  - success
                  - data
                  - meta
              example:
                success: true
                data:
                  url: https://stripe.com
                  screenshot_url: https://assets.prefetch.io/screenshots/stripe-1440x900.jpg
                  viewport:
                    width: 1440
                    height: 900
                  format: jpeg
                  full_page: false
                  captured_at: '2026-05-14T10:00:00.000Z'
                meta:
                  requestId: c1d2e3f4-5a6b-7c8d-9e0f-1a2b3c4d5e6f
                  durationMs: 2540
        '400':
          description: Invalid URL or parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Revoked key, expired key, credit limit, or blocklisted URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: URL hostname could not be resolved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Service temporarily busy — retry shortly.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '504':
          description: Request timed out.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  parameters:
    url:
      name: url
      in: query
      required: true
      description: >-
        The website URL to process. `https://` is prepended automatically if no
        protocol is provided.
      schema:
        type: string
        example: https://stripe.com
    screenshotWidth:
      name: width
      in: query
      required: false
      description: 'Viewport width in pixels. Range: 320–2560. Default: 1440.'
      schema:
        type: integer
        minimum: 320
        maximum: 2560
        default: 1440
    screenshotHeight:
      name: height
      in: query
      required: false
      description: 'Viewport height in pixels. Range: 240–5000. Default: 900.'
      schema:
        type: integer
        minimum: 240
        maximum: 5000
        default: 900
    screenshotFormat:
      name: format
      in: query
      required: false
      description: 'Image format. Default: `jpeg`.'
      schema:
        type: string
        enum:
          - jpeg
          - png
          - webp
        default: jpeg
    screenshotFullPage:
      name: full_page
      in: query
      required: false
      description: 'Capture full scrollable page height. Default: `false`.'
      schema:
        type: boolean
        default: false
  schemas:
    ScreenshotData:
      type: object
      properties:
        url:
          type: string
          format: uri
          description: The URL that was screenshotted.
          example: https://stripe.com
        screenshot_url:
          type: string
          format: uri
          description: Public URL to the screenshot stored in cloud storage.
          example: https://assets.prefetch.io/screenshots/stripe-1440x900.jpg
        viewport:
          type: object
          properties:
            width:
              type: integer
              example: 1440
            height:
              type: integer
              example: 900
          required:
            - width
            - height
        format:
          type: string
          enum:
            - jpeg
            - png
            - webp
          description: Image format of the screenshot.
          example: jpeg
        full_page:
          type: boolean
          description: Whether the full scrollable height was captured.
          example: false
        captured_at:
          type: string
          format: date-time
          description: ISO 8601 timestamp of when the screenshot was taken.
          example: '2026-03-19T14:22:05.000Z'
      required:
        - url
        - screenshot_url
        - viewport
        - format
        - full_page
        - captured_at
    Meta:
      type: object
      properties:
        requestId:
          type: string
          format: uuid
          description: Unique identifier for this request.
          example: a3f2c1d4-7b6e-4f2a-9c1d-8e3f2a1b4c5d
        durationMs:
          type: integer
          nullable: true
          description: Time taken to process the request in milliseconds.
          example: 1842
      required:
        - requestId
        - durationMs
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - false
        error:
          type: string
          description: Human-readable error message.
          example: Credit limit exceeded
        meta:
          $ref: '#/components/schemas/Meta'
      required:
        - success
        - error
        - meta
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: Your Prefetch API key. Obtain one from the dashboard.

````