Skip to content

/v1/screenshot

Capture a screenshot of any public URL.

GET https://api.urlpix.com/v1/screenshot

Parameters

ParameterTypeDefaultRangeRequiredDescription
urlstringYesTarget URL (http/https only, no private IPs)
formatstringpngpng, jpg, webp, pdfNoOutput format
widthinteger12801–3840NoViewport width in pixels
heightinteger8001–3840NoViewport height in pixels
qualityinteger801–100NoJPEG/WebP compression quality
deviceScalefloat1.01.0–3.0NoDevice pixel ratio (DPR)
delayinteger00–10000NoWait time (ms) after page load
timeoutinteger300001–60000NoTotal timeout in ms
fullPagebooleanfalseNoCapture full scrollable page
waitForSelectorstringCSS selectorNoWait for element before capture
clipstringx,y,w,hNoClip region (comma-separated integers)
blockCookiesbooleanfalseNoBlock cookie consent banners (Starter+)
blockAdsbooleanfalseNoBlock advertisements (Starter+)
darkModebooleanfalseNoEmulate prefers-color-scheme: dark (Starter+)
devicestringSee presetsNoDevice emulation preset (Pro+)
customCSSstringNoInject custom CSS before capture (Pro+)
customJSstringNoExecute custom JavaScript before capture (Pro+)
responsestringjsonNoReturn JSON metadata instead of image
api_keystringNoAPI key (alternative to header)

PDF-Only Parameters

These parameters apply only when format=pdf:

ParameterTypeDefaultRangeRequiredDescription
pageSizestringlettera4, letter, legal, tabloid, a3, a5NoPDF page size (Starter+)
landscapebooleanfalseNoLandscape orientation (Starter+)
marginstringtop,right,bottom,leftNoPage margins in mm (Starter+)
headerTemplatestringHTML stringNoPDF header HTML template (Starter+)
footerTemplatestringHTML stringNoPDF footer HTML template (Starter+)
printBackgroundbooleantrueNoPrint background graphics (Starter+)
scalefloat1.00.1–2.0NoPDF render scale (Starter+)

Authentication

Pass your API key via the X-API-Key header (recommended) or the api_key query parameter.

Response

Binary response (default): The image/PDF bytes with appropriate Content-Type header.

JSON response (response=json): Metadata object with image URL, dimensions, file size, and render time.

Response Headers

HeaderDescription
X-Render-TimeRender duration in milliseconds
X-Image-SizeImage file size in bytes
X-CacheHIT (served from cache) or MISS (freshly rendered)

Examples

curl

bash
# Basic PNG screenshot
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o screenshot.png

# Full page WebP with retina
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&format=webp&fullPage=true&deviceScale=2&quality=90" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o full-retina.webp

# Clip a specific region
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&clip=0,0,800,600" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o clipped.png

# Wait for dynamic content
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&waitForSelector=.loaded&delay=1000" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o dynamic.png

JavaScript (fetch)

javascript
const params = new URLSearchParams({
  url: 'https://example.com',
  format: 'webp',
  width: '1920',
  height: '1080',
  quality: '90',
})

const response = await fetch(
  `https://api.urlpix.com/v1/screenshot?${params}`,
  { headers: { 'X-API-Key': 'sk_live_YOUR_KEY' } }
)

const blob = await response.blob()
const imageUrl = URL.createObjectURL(blob)

Node.js

javascript
import fs from 'fs'

const params = new URLSearchParams({
  url: 'https://example.com',
  format: 'png',
  width: '1920',
  height: '1080',
  deviceScale: '2',
})

const response = await fetch(
  `https://api.urlpix.com/v1/screenshot?${params}`,
  { headers: { 'X-API-Key': process.env.URLPIX_API_KEY } }
)

const buffer = Buffer.from(await response.arrayBuffer())
fs.writeFileSync('screenshot.png', buffer)
console.log(`Size: ${buffer.length} bytes`)

Advanced Parameters

bash
# Block cookie banners and ads
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&blockCookies=true&blockAds=true" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o clean.png

Dark Mode (Starter+)

bash
curl "https://api.urlpix.com/v1/screenshot?url=https://github.com&darkMode=true" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o dark.png

Device Presets (Pro+)

PresetWidthHeightScale
iphone-143908443
iphone-14-pro-max4309323
ipad-air82011802
galaxy-s233607803
macbook-pro14409002
bash
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&device=iphone-14" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o mobile.png

Custom CSS & JS Injection (Pro+)

bash
# Hide a specific element with custom CSS
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&customCSS=.banner%7Bdisplay:none%7D" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o no-banner.png

# Execute JS before screenshot
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&customJS=document.querySelector('.popup').remove()" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o no-popup.png

PDF Options (Starter+)

bash
# A4 landscape PDF with margins
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&format=pdf&pageSize=a4&landscape=true&margin=10,15,10,15" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o document.pdf

# PDF with custom header/footer
curl "https://api.urlpix.com/v1/screenshot?url=https://example.com&format=pdf&headerTemplate=%3Cdiv%20style%3D%22font-size%3A10px%22%3EPage%20%3Cspan%20class%3D%22pageNumber%22%3E%3C%2Fspan%3E%3C%2Fdiv%3E&printBackground=true&scale=0.8" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o styled.pdf

Error Responses

StatusDescription
400Missing url, invalid format, out-of-range parameter, or private IP
401Missing or invalid API key
502Renderer unavailable
504Render timeout exceeded

Caching

Screenshots are cached automatically. Cache TTL depends on your plan:

PlanTTL
Free7 days
Starter14 days
Pro30 days
Business60 days

The cache key is derived from: url, width, height, format, quality, fullPage, deviceScale, delay, and clip.

URLPix — Screenshot & OG Image API