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

# Viewport Presets

> Capture screenshots at different device sizes

## Viewport Presets

Control the viewport size to capture screenshots at different device dimensions. DomShot provides presets for common devices or you can define custom dimensions.

## Preset viewports

| Preset    | Width  | Height | Device Scale Factor |
| --------- | ------ | ------ | ------------------- |
| `mobile`  | 375px  | 812px  | 3x                  |
| `tablet`  | 768px  | 1024px | 2x                  |
| `desktop` | 1920px | 1080px | 1x                  |

## Mobile

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&viewportType=mobile" \
    --output mobile.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    viewportType: 'mobile'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('mobile.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'viewportType' => 'mobile'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('mobile.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("viewportType", "mobile")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

## Tablet

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&viewportType=tablet" \
    --output tablet.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    viewportType: 'tablet'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('tablet.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'viewportType' => 'tablet'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('tablet.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("viewportType", "tablet")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

## Desktop

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&viewportType=desktop" \
    --output desktop.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    viewportType: 'desktop'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('desktop.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'viewportType' => 'desktop'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('desktop.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("viewportType", "desktop")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

## Custom viewport

<CodeGroup dropdown>
  ```bash bash theme={null}
  curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&viewportType=custom&width=1280&height=720&deviceScaleFactor=2" \
    --output custom.png
  ```

  ```typescript typescript theme={null}
  const params = new URLSearchParams({
    key: 'YOUR_API_KEY',
    url: 'https://example.com',
    viewportType: 'custom',
    width: '1280',
    height: '720',
    deviceScaleFactor: '2'
  });

  await fetch(`https://api.domshot.com/shot?${params}`)
    .then(res => res.blob())
    .then(blob => fs.writeFile('custom.png', blob));
  ```

  ```php php theme={null}
  $params = [
    'key' => 'YOUR_API_KEY',
    'url' => 'https://example.com',
    'viewportType' => 'custom',
    'width' => '1280',
    'height' => '720',
    'deviceScaleFactor' => '2'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, 'https://api.domshot.com/shot?' . http_build_query($params));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $result = curl_exec($ch);
  file_put_contents('custom.png', $result);
  curl_close($ch);
  ```

  ```go go theme={null}
  package main

  import (
      "net/http"
      "net/url"
  )

  func main() {
      params := url.Values{}
      params.Set("key", "YOUR_API_KEY")
      params.Set("url", "https://example.com")
      params.Set("viewportType", "custom")
      params.Set("width", "1280")
      params.Set("height", "720")
      params.Set("deviceScaleFactor", "2")

      resp, _ := http.Get("https://api.domshot.com/shot?" + params.Encode())
      defer resp.Body.Close()

      // Save response to file
  }
  ```
</CodeGroup>

## Parameters

| Parameter           | Type   | Default   | Description                                                  |
| ------------------- | ------ | --------- | ------------------------------------------------------------ |
| `viewportType`      | string | `desktop` | `mobile`, `tablet`, `desktop`, or `custom`                   |
| `width`             | number | `1920`    | Custom viewport width (required when `viewportType=custom`)  |
| `height`            | number | `1080`    | Custom viewport height (required when `viewportType=custom`) |
| `deviceScaleFactor` | number | `1`       | Device pixel ratio for high-DPI displays                     |

<Warning>
  When using preset viewports (`mobile`, `tablet`, `desktop`), the `width`, `height`, and `deviceScaleFactor` parameters are ignored. These parameters only apply when `viewportType=custom`.
</Warning>

## Device scale factor

The device scale factor controls the pixel density for capturing screenshots on high-DPI displays:

* **1x** - Standard displays (desktop default)
* **2x** - Retina displays (tablet default)
* **3x** - Super Retina displays (mobile default)

Higher scale factors produce larger, sharper images at the cost of file size.

## See also

* [Full Page Screenshots](/guides/screenshots/full-page) - Capture entire page length
* [Image Formats](/guides/screenshots/formats) - PNG, JPEG, WebP options
