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

# Screenshot

> Capture full-page screenshots of any public webpage and get them back as PNG images.

# Screenshot

**Base URL:** `https://drain.lat/api/v1/screenshot`

<AccordionGroup>
  <Accordion title="GET /" icon="camera">
    Take a screenshot of any public webpage and return it as a PNG image.

    ```
    GET /api/v1/screenshot
    ```

    <ParamField query="url" type="string" required>
      The full URL to screenshot. Must start with `https://`.
    </ParamField>

    <ParamField query="width" type="number">
      Viewport width in pixels. Max `2560`. Default `1440`.
    </ParamField>

    <ParamField query="height" type="number">
      Viewport height in pixels. Max `1440`. Default `900`.
    </ParamField>

    <ParamField query="fullPage" type="boolean">
      Capture the full scrollable page instead of just the viewport. Default `false`.
    </ParamField>

    <ParamField query="format" type="string">
      Output format. `png` or `jpeg`. JPEG is faster and smaller. Default `png`.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/screenshot?url=https://github.com" \
        -H "x-api-key: YOUR_API_KEY" \
        --output screenshot.png
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch(
        "https://drain.lat/api/v1/screenshot?url=https://github.com&width=1920&height=1080",
        { headers: { "x-api-key": "YOUR_API_KEY" } }
      );

      // Node.js - save to file
      const buffer = await res.arrayBuffer();
      require("fs").writeFileSync("screenshot.png", Buffer.from(buffer));

      // Browser - use as image
      const blob = await res.blob();
      const imgUrl = URL.createObjectURL(blob);
      ```

      ```python Python theme={null}
      import requests

      res = requests.get(
          "https://drain.lat/api/v1/screenshot",
          params={"url": "https://github.com", "width": 1920, "height": 1080, "fullPage": "true"},
          headers={"x-api-key": "YOUR_API_KEY"}
      )

      with open("screenshot.png", "wb") as f:
          f.write(res.content)
      ```
    </CodeGroup>

    Returns a raw image binary. Content type is `image/png` or `image/jpeg` depending on the `format` param.

    ```
    Content-Type: image/png
    Content-Type: image/jpeg
    ```

    **Examples**

    ```
    # Default (1440x900, PNG)
    GET /api/v1/screenshot?url=https://example.com

    # Full HD JPEG (faster)
    GET /api/v1/screenshot?url=https://example.com&width=1920&height=1080&format=jpeg

    # Full page
    GET /api/v1/screenshot?url=https://example.com&fullPage=true

    # Max resolution
    GET /api/v1/screenshot?url=https://example.com&width=2560&height=1440
    ```

    <Warning>
      Requests to `localhost`, `127.0.0.1`, and private IP ranges are blocked. Only public URLs are supported.
    </Warning>
  </Accordion>
</AccordionGroup>
