# Website Screenshot API - Page Screenshot Generator (`code-node-tools/website-screenshot-api`) Actor

Website screenshot API to capture any webpage as an image. This screenshot API supports full page, viewport, and element screenshots. Website screenshot generator API for automated website screenshot capture, visual testing, monitoring, and thumbnail generation. Reliable page screenshot API.

- **URL**: https://apify.com/code-node-tools/website-screenshot-api.md
- **Developed by:** [CodeNodeTools](https://apify.com/code-node-tools) (community)
- **Categories:** Developer tools, Other, Automation
- **Features:** Limited permissions
- **Stats:** 8 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Website Screenshot API

Capture high-quality **website screenshots** programmatically with this powerful **screenshot API**. Generate full-page, viewport, or element-specific screenshots of any webpage using Playwright browser automation.

### What is Website Screenshot API?

This **website screenshot generator API** is an Apify Actor that captures pixel-perfect screenshots of any URL. Whether you need a simple **page screenshot API** for monitoring, a **website screenshot generator** for thumbnails, or automated visual testing — this tool handles it all.

#### Key Features

- **Full Page Screenshots** - Capture entire scrollable pages
- **Viewport Screenshots** - Screenshot only the visible area
- **Element Screenshots** - Target specific page elements with CSS selectors
- **Batch Processing** - Screenshot multiple URLs in a single run
- **Mobile Emulation** - Test responsive designs
- **Dark Mode Support** - Capture dark theme variants
- **Lazy Loading Support** - Auto-scroll to load dynamic content
- **Element Removal** - Hide cookie banners, popups, and ads
- **Proxy Support** - Bypass geo-restrictions and avoid blocking

### Use Cases

#### Website Monitoring

Track visual changes on websites over time. Perfect for detecting layout breaks, content updates, or competitor changes.

#### Visual Testing & QA

Automate screenshot capture across different viewports and devices for regression testing.

#### Thumbnail Generation

Create website previews and thumbnails for link previews, portfolios, or directories.

#### Social Media Previews

Generate Open Graph images and social media cards from web content.

#### Documentation

Capture clean screenshots for product documentation, tutorials, and marketing materials.

#### Archiving

Create visual archives of web pages for compliance, legal, or historical purposes.

### Input Parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `url` | string | - | Single URL to screenshot |
| `urls` | array | - | Multiple URLs for batch processing |
| `screenshotType` | string | `fullPage` | Type: `fullPage`, `viewport`, or `element` |
| `selector` | string | - | CSS selector for element screenshots |
| `format` | string | `png` | Image format: `png` or `jpeg` |
| `quality` | integer | `80` | JPEG quality (0-100) |
| `width` | integer | `1920` | Viewport width in pixels |
| `height` | integer | `1080` | Viewport height in pixels |
| `deviceScaleFactor` | number | `1` | Scale factor (2 for retina) |
| `isMobile` | boolean | `false` | Enable mobile emulation |
| `waitForSelector` | string | - | Wait for element before capture |
| `waitForTimeout` | integer | `0` | Additional wait time (ms) |
| `waitUntil` | string | `load` | Page load state to wait for |
| `removeElements` | array | - | Selectors of elements to remove |
| `scrollToBottom` | boolean | `false` | Scroll for lazy-loaded content |
| `darkMode` | boolean | `false` | Enable dark color scheme |
| `proxyConfiguration` | object | - | Proxy settings |

### Example Input

#### Basic Screenshot

```json
{
    "url": "https://example.com",
    "screenshotType": "fullPage",
    "format": "png"
}
```

#### Batch Screenshots with Custom Viewport

```json
{
    "urls": [
        "https://example.com",
        "https://github.com",
        "https://apify.com"
    ],
    "width": 1440,
    "height": 900,
    "format": "jpeg",
    "quality": 90
}
```

#### Element Screenshot

```json
{
    "url": "https://example.com",
    "screenshotType": "element",
    "selector": ".hero-section",
    "removeElements": [".cookie-banner", ".chat-widget"]
}
```

#### Mobile Screenshot with Dark Mode

```json
{
    "url": "https://example.com",
    "width": 390,
    "height": 844,
    "isMobile": true,
    "darkMode": true,
    "deviceScaleFactor": 2
}
```

### Output

Each screenshot generates a dataset item with:

```json
{
    "url": "https://example.com",
    "screenshotUrl": "https://api.apify.com/v2/key-value-stores/.../records/screenshot-0",
    "screenshotKey": "screenshot-0",
    "format": "png",
    "width": 1920,
    "height": 1080,
    "screenshotType": "fullPage",
    "timestamp": "2024-01-15T10:30:00.000Z",
    "success": true
}
```

### API Integration

#### Using the Apify API

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_API_TOKEN' });

const run = await client.actor('YOUR_USERNAME/website-screenshot-api').call({
    url: 'https://example.com',
    screenshotType: 'fullPage',
    format: 'png'
});

// Get screenshot URL from dataset
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log('Screenshot URL:', items[0].screenshotUrl);
```

#### Using cURL

```bash
curl -X POST "https://api.apify.com/v2/acts/YOUR_USERNAME~website-screenshot-api/runs?token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "format": "png"}'
```

### Performance Tips

1. **Use viewport screenshots** when you don't need the full page — they're faster
2. **Block unnecessary resources** if you only need the layout
3. **Set appropriate timeouts** for slow-loading sites
4. **Use batch processing** for multiple URLs instead of separate runs
5. **Enable proxy** for sites that block datacenter IPs

### Limitations

- Maximum screenshot dimensions depend on available memory
- Some sites may block automated browsers
- JavaScript-heavy sites may need longer wait times
- Rate limiting may apply to target websites

### Support

- [Apify Documentation](https://docs.apify.com)
- [Crawlee Documentation](https://crawlee.dev)
- [Playwright Documentation](https://playwright.dev)

### License

ISC

# Actor input Schema

## `url` (type: `string`):

URL of the webpage to screenshot

## `urls` (type: `array`):

Multiple URLs for batch screenshot capture

## `screenshotType` (type: `string`):

Type of screenshot to capture

## `selector` (type: `string`):

CSS selector for element screenshot (only used when screenshotType is 'element')

## `format` (type: `string`):

Output image format

## `quality` (type: `integer`):

JPEG quality (0-100, ignored for PNG)

## `width` (type: `integer`):

Viewport width in pixels

## `height` (type: `integer`):

Viewport height in pixels

## `deviceScaleFactor` (type: `number`):

Device scale factor (1 = normal, 2 = retina)

## `isMobile` (type: `boolean`):

Emulate mobile device

## `waitForSelector` (type: `string`):

CSS selector to wait for before taking screenshot

## `waitForTimeout` (type: `integer`):

Additional wait time in milliseconds before screenshot

## `waitUntil` (type: `string`):

Wait until page reaches this state

## `removeElements` (type: `array`):

CSS selectors of elements to remove before screenshot (e.g., cookie banners)

## `scrollToBottom` (type: `boolean`):

Scroll to bottom to trigger lazy loading before screenshot

## `darkMode` (type: `boolean`):

Enable dark mode if site supports it

## `proxyConfiguration` (type: `object`):

Proxy settings for the browser

## Actor input object example

```json
{
  "url": "https://example.com",
  "screenshotType": "fullPage",
  "format": "png",
  "quality": 90,
  "width": 1920,
  "height": 1080,
  "deviceScaleFactor": 1,
  "isMobile": false,
  "waitForTimeout": 0,
  "waitUntil": "load",
  "scrollToBottom": false,
  "darkMode": false,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `screenshots` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "url": "https://example.com",
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("code-node-tools/website-screenshot-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "url": "https://example.com",
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("code-node-tools/website-screenshot-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "url": "https://example.com",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call code-node-tools/website-screenshot-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,code-node-tools/website-screenshot-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/DUkSchwYyKEzvghV0/builds/2j3esykc86A2tRsvN/openapi.json
