Skip to content

Dark Mode

Capture screenshots with the browser's dark color scheme preference enabled.

Usage

Use prefers-color-scheme: dark emulation by setting the viewport to dark mode:

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

This tells the browser to prefer dark mode, which triggers @media (prefers-color-scheme: dark) CSS rules on the target page.

Comparison Example

bash
# Light mode (default)
curl "https://api.urlpix.com/v1/screenshot?url=https://github.com" \
  -H "X-API-Key: sk_live_YOUR_KEY" \
  -o light.png

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

JavaScript Example

javascript
const params = new URLSearchParams({
  url: 'https://github.com',
  darkMode: 'true',
  format: 'webp',
})

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

TIP

Not all websites support dark mode. If the target site doesn't implement prefers-color-scheme media queries, the screenshot will look the same regardless of this setting.

URLPix — Screenshot & OG Image API