Allscreenshots Docs
Features

Viewport and devices

Control viewport size and emulate real devices

Viewport and devices

Control how pages are rendered by setting custom viewport dimensions or emulating real devices. This is essential for capturing responsive designs and mobile-specific layouts.

Custom viewport

Set exact viewport dimensions:

{
  "url": "https://example.com",
  "viewport": {
    "width": 1440,
    "height": 900,
    "deviceScaleFactor": 2
  }
}

Viewport parameters

ParameterTypeRangeDefaultDescription
widthinteger100-40961920Viewport width in CSS pixels
heightinteger100-40961080Viewport height in CSS pixels
deviceScaleFactorinteger1-31Device pixel ratio (DPR)

Device scale factor

The deviceScaleFactor controls the pixel density:

  • 1 - Standard display (96 DPI)
  • 2 - Retina/HiDPI display (192 DPI)
  • 3 - Ultra-high DPI (288 DPI)

Higher values produce sharper images but larger file sizes.

Device presets

Use device presets instead of manual viewport configuration:

{
  "url": "https://example.com",
  "device": "iphone_15"
}

Device presets automatically configure:

  • Viewport dimensions
  • Device scale factor
  • Mobile/touch behavior
  • User agent (where applicable)

Desktop devices

PresetDimensionsDPRDescription
desktop_hd1920×10801Standard HD desktop
desktop_large2560×14401Large/QHD desktop
desktop_retina1920×10802Retina desktop
laptop1440×9001Standard laptop
laptop_retina1440×9002MacBook Pro style

iPhone devices

PresetDimensionsDPRDescription
iphone_se375×6672iPhone SE
iphone_xr414×8962iPhone XR
iphone_12390×8443iPhone 12
iphone_12_pro_max428×9263iPhone 12 Pro Max
iphone_14390×8443iPhone 14
iphone_14_pro_max430×9323iPhone 14 Pro Max
iphone_15393×8523iPhone 15
iphone_15_pro_max430×9323iPhone 15 Pro Max

iPad devices

PresetDimensionsDPRDescription
ipad768×10242Standard iPad
ipad_mini768×10242iPad Mini
ipad_pro_11834×11942iPad Pro 11"
ipad_pro_12_91024×13662iPad Pro 12.9"

Android devices

PresetDimensionsDPRDescription
pixel_5393×8512.75Google Pixel 5
pixel_7412×9152.625Google Pixel 7
pixel_7_pro412×8923.5Google Pixel 7 Pro
samsung_galaxy_s21360×8003Samsung Galaxy S21
samsung_galaxy_s23360×7803Samsung Galaxy S23
galaxy_tab_s7800×12802Samsung Galaxy Tab S7
surface_pro_7912×13682Microsoft Surface Pro 7

Social media presets

Optimized dimensions for social platforms:

PresetDimensionsDescription
facebook_og1200×630Facebook Open Graph
twitter_card1200×675Twitter/X Card
linkedin_post1200×627LinkedIn Post
instagram_square1080×1080Instagram Square
instagram_portrait1080×1350Instagram Portrait
instagram_story1080×1920Instagram Story

Examples

Mobile screenshot

curl -X POST 'https://api.allscreenshots.com/v1/screenshots' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://example.com",
    "device": "iphone_15"
  }' --output mobile.png

Retina desktop

curl -X POST 'https://api.allscreenshots.com/v1/screenshots' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://example.com",
    "viewport": {
      "width": 1920,
      "height": 1080,
      "deviceScaleFactor": 2
    }
  }' --output retina.png

Social media preview

curl -X POST 'https://api.allscreenshots.com/v1/screenshots' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "https://example.com",
    "device": "twitter_card"
  }' --output og-image.png

Responsive comparison

Use composition to capture multiple devices:

{
  "url": "https://example.com",
  "variants": [
    { "device": "desktop_hd", "label": "Desktop" },
    { "device": "ipad_pro_11", "label": "Tablet" },
    { "device": "iphone_15", "label": "Mobile" }
  ],
  "output": {
    "layout": "horizontal"
  }
}

Full page screenshots

Capture the entire scrollable page:

{
  "url": "https://example.com",
  "fullPage": true,
  "viewport": {
    "width": 1920,
    "height": 1080
  }
}

For full page captures, the height in viewport only sets the initial viewport. The final image height matches the page content.

Best practices

Match your target audience

Use device presets that match your users' devices:

// Analytics shows 60% mobile traffic
const mobileScreenshot = await capture({
  url: 'https://example.com',
  device: 'iphone_15',
});

Use appropriate DPR

Higher DPR produces sharper images but larger files:

Use caseRecommended DPR
Thumbnails1
Documentation1-2
Marketing2
Print2-3

Consider aspect ratios

Social platforms have specific requirements:

// Twitter/X card
const twitterCard = await capture({
  url: 'https://example.com',
  device: 'twitter_card', // 1200×675 (16:9)
});

// Instagram
const instagramSquare = await capture({
  url: 'https://example.com',
  device: 'instagram_square', // 1080×1080 (1:1)
});

On this page