Overview
TheScreenshotAPI provides methods for capturing screenshots of websites with various options and configurations.
Methods
take()
Captures a screenshot with full configuration options.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
options | ScreenshotOptions | Yes | Screenshot configuration options |
ScreenshotOptions
Returns
Promise<ScreenshotResult> - Screenshot result with data and metadata
ScreenshotResult
Examples
takeBatch()
Captures multiple screenshots in batch.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
options | BatchScreenshotOptions | Yes | Batch screenshot configuration |
BatchScreenshotOptions
Returns
Promise<BatchScreenshotResult> - Batch screenshot results
BatchScreenshotResult
Examples
screenshot()
Convenience method for basic screenshots.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to screenshot |
options | Partial<ScreenshotOptions> | No | Optional screenshot options |
Returns
Promise<ScreenshotResult> - Screenshot result
Example
fullPage()
Convenience method for full-page screenshots.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to screenshot |
options | Partial<ScreenshotOptions> | No | Optional screenshot options (fullPage is automatically set to true) |
Returns
Promise<ScreenshotResult> - Full-page screenshot result
Example
element()
Convenience method for element screenshots.Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
url | string | Yes | URL to screenshot |
selector | string | Yes | CSS selector for the element |
options | Partial<ScreenshotOptions> | No | Optional screenshot options |
Returns
Promise<ScreenshotResult> - Element screenshot result
Example
Advanced Usage
Custom Timing
Performance Optimization
Error Handling
Batch Processing with Progress
File Format Details
PNG Format
- Lossless compression: No quality loss
- Supports transparency: Alpha channel
- Larger file sizes: Better for screenshots with text
- Default choice: Best quality for most use cases
JPEG Format
- Lossy compression: Smaller file sizes
- No transparency: White background for transparent elements
- Quality range: 0-100 (default: 80)
- Best for: Photographs, gradients, when file size matters
Viewport Considerations
Common Viewports
Device Pixel Ratio
Best Practices
Performance
- Use appropriate formats: PNG for quality, JPEG for size
- Set reasonable timeouts: Don’t wait unnecessarily long
- Batch when possible: Reduce overhead
- Cache results: Avoid redundant screenshots
