# Lighthouse Checker (`blue_hero/lighthouse-checker`) Actor

Run Google Lighthouse audits on any URL or entire website via sitemap. Get performance, accessibility, SEO, and best practices scores with mobile/desktop emulation.

- **URL**: https://apify.com/blue\_hero/lighthouse-checker.md
- **Developed by:** [Lucas](https://apify.com/blue_hero) (community)
- **Categories:** SEO tools, E-commerce, Developer tools
- **Stats:** 6 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $12.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Lighthouse Checker

Run Google Lighthouse audits on any URL or entire website via sitemap. Get performance, accessibility, SEO, and best practices scores with mobile/desktop emulation.

### Features

- **Single URL or Batch Processing** - Audit one page or hundreds at once
- **Sitemap Discovery** - Automatically extract URLs from sitemap.xml (supports sitemap indexes and gzipped sitemaps)
- **URL Filtering** - Filter sitemap URLs with regex patterns
- **Device Emulation** - Test as mobile or desktop with configurable viewports
- **Network Throttling** - Simulate slow 3G, fast 3G, or custom network conditions
- **Authenticated Pages** - Support for cookie injection and automated form login
- **Concurrent Processing** - Run multiple audits in parallel (up to 5)
- **Smart Retries** - Automatic retry with third-party resource blocking for flaky pages
- **Detailed Reports** - Full Lighthouse HTML and JSON reports stored for each URL

### Input

| Field | Type | Description |
|-------|------|-------------|
| `url` | string | Single URL to audit |
| `urls` | string\[] | Array of URLs to audit |
| `sitemapUrl` | string | Sitemap URL to discover pages from |
| `maxUrls` | number | Maximum URLs to audit from sitemap |
| `urlPattern` | string | Regex pattern to filter URLs |
| `device` | string | `mobile` or `desktop` (default: `mobile`) |
| `categories` | string\[] | Categories to audit: `performance`, `accessibility`, `best-practices`, `seo`, `pwa` |
| `preset` | string | `quick` (perf only, no throttling), `full` (all categories), `default` |
| `concurrency` | number | Parallel audits (1-5, default: 1) |
| `timeout` | number | Timeout in seconds (30-300, default: 60) |
| `cookies` | object\[] | Session cookies for authenticated pages |
| `login` | object | Automated login configuration |

### Output

Each audited URL produces a dataset item with:

```json
{
  "summary": {
    "url": "https://example.com/",
    "finalUrl": "https://example.com/",
    "fetchTime": "2024-01-15T10:30:00.000Z",
    "scores": {
      "performance": 85,
      "accessibility": 92,
      "bestPractices": 100,
      "seo": 90,
      "pwa": null
    },
    "coreWebVitals": {
      "lcp": 1250,
      "cls": 0.05,
      "fcp": 800,
      "ttfb": 320,
      "inp": null
    }
  },
  "artifacts": {
    "htmlReportUrl": "https://api.apify.com/v2/key-value-stores/.../records/report-example-com.html",
    "jsonReportUrl": "https://api.apify.com/v2/key-value-stores/.../records/report-example-com.json",
    "screenshotUrl": "https://api.apify.com/v2/key-value-stores/.../records/screenshot-example-com.jpg"
  }
}
```

### Examples

#### Single URL

```json
{
  "url": "https://example.com/",
  "device": "mobile",
  "categories": ["performance", "accessibility"]
}
```

#### Batch from Sitemap

```json
{
  "sitemapUrl": "https://example.com/sitemap.xml",
  "maxUrls": 100,
  "urlPattern": "/blog/",
  "device": "desktop",
  "categories": ["performance", "seo"],
  "concurrency": 3
}
```

#### Quick Performance Check

```json
{
  "urls": [
    "https://example.com/",
    "https://example.com/about",
    "https://example.com/contact"
  ],
  "preset": "quick",
  "concurrency": 3
}
```

#### Authenticated Pages (Cookies)

```json
{
  "url": "https://example.com/dashboard",
  "cookies": [
    {
      "name": "session_id",
      "value": "abc123",
      "domain": "example.com"
    }
  ]
}
```

#### Authenticated Pages (Login Flow)

```json
{
  "url": "https://example.com/dashboard",
  "login": {
    "loginUrl": "https://example.com/login",
    "usernameSelector": "#email",
    "passwordSelector": "#password",
    "submitSelector": "button[type='submit']",
    "username": "user@example.com",
    "password": "your-password"
  }
}
```

### Key-Value Store Output

In addition to the dataset, the actor stores:

- `summary.json` - Aggregate statistics for the batch
- `report-{slug}.html` - Interactive Lighthouse HTML report for each URL
- `report-{slug}.json` - Full Lighthouse JSON report for each URL
- `screenshot-{slug}.jpg` - Final rendered screenshot for each URL

### Use Cases

- Monitor Core Web Vitals across your entire site
- Track accessibility compliance at scale
- Compare mobile vs desktop performance
- Audit authenticated/logged-in pages
- Integrate Lighthouse into CI/CD pipelines via Apify API
- Generate performance reports for clients

### Limitations

- Maximum 5 concurrent audits (Chrome is resource-intensive)
- Timeout range: 30-300 seconds per audit
- Some sites may block automated browsers

### Resources

- [Google Lighthouse Documentation](https://developer.chrome.com/docs/lighthouse/overview/)
- [Core Web Vitals](https://web.dev/vitals/)
- [Apify Platform Documentation](https://docs.apify.com/)

# Actor input Schema

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

The URL of the page to audit. If 'urls' array or 'sitemapUrl' is provided, they take precedence.

## `sitemapUrl` (type: `string`):

URL of sitemap.xml to extract page URLs from. Supports sitemap indexes and gzipped sitemaps.

## `maxUrls` (type: `integer`):

Maximum number of URLs to audit from sitemap. Leave empty for all URLs.

## `urlPattern` (type: `string`):

Regex pattern to filter URLs. Only URLs matching this pattern will be audited.

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

Array of URLs to audit. Takes precedence over single 'url' field.

## `concurrency` (type: `integer`):

Number of URLs to audit in parallel (default: 1 for sequential processing)

## `device` (type: `string`):

Device emulation mode (mobile or desktop)

## `categories` (type: `array`):

Which Lighthouse categories to audit

## `preset` (type: `string`):

Quick presets: 'quick' (performance only, no throttling), 'full' (all categories), 'default' (standard)

## `timeout` (type: `integer`):

Maximum time to wait for the audit to complete

## `viewport` (type: `object`):

Custom viewport dimensions. When specified, overrides the device preset screen dimensions.

## `throttling` (type: `object`):

Custom network throttling settings. When specified, overrides the preset throttling values.

## `cookies` (type: `array`):

Cookies to inject before audit. Each cookie needs 'name', 'value', and optionally 'domain', 'path', 'expires', 'httpOnly', 'secure', 'sameSite'.

## `login` (type: `object`):

Automated login flow configuration. Provide credentials and selectors for form-based authentication.

## `maxRetries` (type: `integer`):

Maximum number of retry attempts for failed URLs. On retry, slow third-party resources are blocked.

## `retryBlockedPatterns` (type: `array`):

URL patterns to block on retry attempts (e.g., '*://*.mdnplay.dev/\*'). Defaults to common slow embed domains.

## Actor input object example

```json
{
  "url": "https://example.com/",
  "urls": [
    "https://example.com/"
  ],
  "concurrency": 1,
  "device": "mobile",
  "categories": [
    "performance",
    "accessibility",
    "best-practices"
  ],
  "preset": "default",
  "timeout": 60,
  "maxRetries": 1,
  "retryBlockedPatterns": [
    "*://*.mdnplay.dev/*",
    "*://codepen.io/*",
    "*://jsfiddle.net/*",
    "*://codesandbox.io/*"
  ]
}
```

# 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/",
    "urls": [
        "https://example.com/"
    ],
    "retryBlockedPatterns": [
        "*://*.mdnplay.dev/*",
        "*://codepen.io/*",
        "*://jsfiddle.net/*",
        "*://codesandbox.io/*"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("blue_hero/lighthouse-checker").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/",
    "urls": ["https://example.com/"],
    "retryBlockedPatterns": [
        "*://*.mdnplay.dev/*",
        "*://codepen.io/*",
        "*://jsfiddle.net/*",
        "*://codesandbox.io/*",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("blue_hero/lighthouse-checker").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/",
  "urls": [
    "https://example.com/"
  ],
  "retryBlockedPatterns": [
    "*://*.mdnplay.dev/*",
    "*://codepen.io/*",
    "*://jsfiddle.net/*",
    "*://codesandbox.io/*"
  ]
}' |
apify call blue_hero/lighthouse-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,blue_hero/lighthouse-checker"
        }
    }
}

```

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/JHfrDvWmkMc01iCFg/builds/LHwFrrQ27sk1KHjOS/openapi.json
