Tutorial

How to Capture Screenshots with Custom Viewport Sizes

Set exact viewport dimensions for pixel-perfect screenshots. Control width, height, and device pixel ratio.

Steps

  1. Set width and heightUse width=1920&height=1080 for standard HD, or any custom size. Height is optional — defaults to auto.
  2. Control device pixel ratioSet scale=2 for retina-quality screenshots (2x resolution). Default is 1.
  3. Common presetsCommon sizes: 1920x1080 (desktop), 1440x900 (laptop), 768x1024 (tablet), 375x812 (iPhone).

Code Examples

# 4K screenshot
curl "https://snapapi.tech/v1/screenshot?url=https://example.com&api_key=YOUR_KEY&width=3840&height=2160&scale=1" -o 4k.png

# Retina mobile
curl "https://snapapi.tech/v1/screenshot?url=https://example.com&api_key=YOUR_KEY&width=375&height=812&scale=2" -o retina-mobile.png
import requests

# 4K screenshot
response = requests.get("https://snapapi.tech/v1/screenshot", params={
    "url": "https://example.com",
    "api_key": "YOUR_KEY",
    "width": "3840",
    "height": "2160"
})
with open("4k.png", "wb") as f:
    f.write(response.content)
// Retina mobile screenshot
const res = await fetch(
  "https://snapapi.tech/v1/screenshot?" + new URLSearchParams({
    url: "https://example.com",
    api_key: "YOUR_KEY",
    width: "375",
    height: "812",
    scale: "2"
  })
);
require("fs").writeFileSync("retina-mobile.png", Buffer.from(await res.arrayBuffer()));
Get Free API KeyFull API Docs