screenshotpro-devices
v1.0.0
Published
Device emulation definitions for ScreenshotPro API - viewport sizes, user agents, and device capabilities
Downloads
14
Maintainers
Readme
screenshotpro-devices
Device emulation definitions for ScreenshotPro API - viewport sizes, user agents, and device capabilities compatible with Puppeteer and Playwright.
Installation
npm install screenshotpro-devicesUsage
import devices from 'screenshotpro-devices';
// Get all device names
console.log(devices.names);
// ['iphone_15_pro_max', 'iphone_15_pro_max_landscape', 'iphone_15_pro', ...]
// Get a specific device
const iphone = devices.devices['iphone_15_pro'];
console.log(iphone);
// {
// id: 'iphone_15_pro',
// name: 'iPhone 15 Pro',
// userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0...',
// viewport: {
// width: 393,
// height: 852,
// deviceScaleFactor: 3,
// isMobile: true,
// hasTouch: true,
// isLandscape: false
// }
// }
// Use with Playwright
import { chromium } from 'playwright';
const browser = await chromium.launch();
const context = await browser.newContext({
...iphone.viewport,
userAgent: iphone.userAgent,
});
const page = await context.newPage();
await page.goto('https://example.com');API
devices
Main export containing all device definitions.
Properties:
names: string[]- Array of all device keys (lowercase with underscores)devices: Record<string, Device>- Object mapping device keys to device definitions
Device
Device definition interface (compatible with Puppeteer/Playwright).
interface Device {
name: string; // Display name (e.g., "iPhone 15 Pro")
userAgent: string; // User agent string
viewport: Viewport; // Viewport configuration
}Viewport
Viewport configuration interface (compatible with Puppeteer/Playwright).
interface Viewport {
width: number; // Viewport width in pixels
height: number; // Viewport height in pixels
deviceScaleFactor?: number; // Device pixel ratio (e.g., 2, 3)
isMobile?: boolean; // Whether device is mobile
isLandscape?: boolean; // Whether device is in landscape orientation
hasTouch?: boolean; // Whether device has touch support
}Supported Devices
The package includes 40 device definitions (20 unique devices × 2 orientations):
iPhone Devices (10 models = 20 definitions)
- iPhone 15 Pro Max (portrait + landscape)
- iPhone 15 Pro (portrait + landscape)
- iPhone 15 (portrait + landscape)
- iPhone 14 Pro Max (portrait + landscape)
- iPhone 14 Pro (portrait + landscape)
- iPhone 14 (portrait + landscape)
- iPhone 13 Pro Max (portrait + landscape)
- iPhone 13 (portrait + landscape)
- iPhone 12 Pro (portrait + landscape)
- iPhone SE (portrait + landscape)
Android Devices (6 models = 12 definitions)
- Samsung Galaxy S23 Ultra (portrait + landscape)
- Google Pixel 7 Pro (portrait + landscape)
- Google Pixel 7 (portrait + landscape)
- OnePlus 11 (portrait + landscape)
- Galaxy S9+ (portrait + landscape)
- Nexus 5X (portrait + landscape)
Tablet Devices (4 models = 8 definitions)
- iPad Pro 12.9" (portrait + landscape)
- iPad Pro 11" (portrait + landscape)
- iPad Mini (portrait + landscape)
- Galaxy Tab S4 (portrait + landscape)
Device Key Format
Device names are converted to lowercase keys with underscores:
"iPhone 15 Pro"→"iphone_15_pro""iPad Pro 12.9"→"ipad_pro_12.9""Galaxy S23 Ultra"→"galaxy_s23_ultra"
Examples
List all iPhone devices
import devices from 'screenshotpro-devices';
const iPhones = devices.names
.filter(name => name.startsWith('iphone'))
.map(name => devices.devices[name]);
console.log(iPhones);Get only portrait devices
import devices from 'screenshotpro-devices';
const portraitDevices = devices.names
.filter(name => !name.includes('landscape'))
.map(name => devices.devices[name]);
console.log(portraitDevices);Use with Puppeteer
import puppeteer from 'puppeteer';
import devices from 'screenshotpro-devices';
const browser = await puppeteer.launch();
const page = await browser.newPage();
const device = devices.devices['iphone_15_pro'];
await page.setUserAgent(device.userAgent);
await page.setViewport(device.viewport);
await page.goto('https://example.com');TypeScript Support
The package includes full TypeScript definitions. All interfaces are exported:
import devices, { Device, Viewport } from 'screenshotpro-devices';Contributing
We welcome contributions! If you'd like to add more device definitions or update existing ones, please open a pull request at https://github.com/screenshotpro/devices.
License
Apache 2.0 - See LICENSE file for details.
Related Packages
- screenshotpro-validations - Validation schemas for ScreenshotPro API requests
Support
- Issues: https://github.com/screenshotpro/devices/issues
- Email: [email protected]
- Website: https://screenshotpro.io
