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
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&viewportType=mobile" \
--output mobile.png
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));
$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);
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
}
Tablet
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&viewportType=tablet" \
--output tablet.png
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));
$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);
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
}
Desktop
curl "https://api.domshot.com/shot?key=YOUR_API_KEY&url=https://example.com&viewportType=desktop" \
--output desktop.png
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));
$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);
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
}
Custom viewport
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
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));
$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);
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
}
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 |
When using preset viewports (mobile, tablet, desktop), the width, height, and deviceScaleFactor parameters are ignored. These parameters only apply when viewportType=custom.
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