# PageSpeed Insights & Core Web Vitals Benchmark (`nextforbes/pagespeed-benchmark`) Actor

Lighthouse scores and Core Web Vitals for a list of URLs in one run, ranked against each other: gaps vs the best page, pass/fail per threshold, top opportunities with savings, and a monitor mode that reports only what changed.

- **URL**: https://apify.com/nextforbes/pagespeed-benchmark.md
- **Developed by:** [nikolas law](https://apify.com/nextforbes) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 audits

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?

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

## PageSpeed Insights & Core Web Vitals Benchmark

Lighthouse scores and Core Web Vitals for a **list of URLs in one run**, ranked against each other. Bring your own free Google API key; the Actor does the batching, the comparison and the history.

A single PageSpeed Insights report tells you one page's numbers. This Actor tells you where you stand:

- **Ranking table.** Every URL ranked per device by performance score, with the **gap to the best page** in score points, LCP, TBT and CLS. Put your page next to 3 competitors and the table is your to-do list.
- **Pass / fail per Core Web Vital.** LCP, INP and CLS rated good / needs-improvement / poor against Google's thresholds, using **real-user (CrUX) data when Google has it** and lab data otherwise. One `cwv.pass` boolean per page.
- **Top opportunities with savings.** The Lighthouse opportunities sorted by estimated milliseconds saved, plus the heaviest failing audits for accessibility, best practices and SEO.
- **Only what changed.** Turn on **monitor mode**, schedule it daily, and you get score deltas per URL, a flag when a page starts or stops passing Core Web Vitals, and nothing for pages that did not move.

Source: the official Google PageSpeed Insights API v5. No scraping, no login, no proxies.

### Use cases

- Agencies: a weekly client report of their site vs. three competitors, straight into Google Sheets or Looker Studio.
- SEO teams: catch a Core Web Vitals regression the day it happens, before Search Console shows it four weeks later.
- Developers: audit every landing page after a deploy with one scheduled run and a Slack alert on `cwvPassChanged`.
- E-commerce: compare category pages across markets (`example.de`, `example.fr`, `example.it`) on mobile and desktop.
- AI agents / RAG: structured, typed performance data with the comparison already done.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `urls` | array | — | Full page URLs. Add 2+ to get a meaningful ranking. |
| `googleApiKey` | string (secret) | — | Your PageSpeed Insights API key (free, 25,000 queries/day). Google no longer serves keyless requests, so without it every URL returns an `error` item with instructions. |
| `strategy` | `mobile` / `desktop` / `both` | `mobile` | `both` produces two audits per URL. |
| `categories` | array | all four | `performance`, `accessibility`, `best-practices`, `seo`. Performance is always included. |
| `monitorMode` | boolean | `false` | Compare with the previous run and output only changed audits. |
| `minScoreChange` | integer | `1` | Monitor mode: minimum move (0-100 points) in any category to count as changed. A Core Web Vitals pass/fail flip always counts. |
| `maxOpportunities` | integer | `5` | Opportunities per audit and failing audits per other category. |
| `concurrency` | integer | `2` | Parallel API requests (1-5). |
| `locale` | string | `en` | Language of audit titles. |

Getting a key takes two minutes: Google Cloud Console → APIs & Services → Library → enable **PageSpeed Insights API** → Credentials → Create API key. No billing account is needed for the free quota.

Example:

```json
{
  "urls": [
    "https://www.yoursite.com/pricing",
    "https://www.competitor-a.com/pricing",
    "https://www.competitor-b.com/plans"
  ],
  "googleApiKey": "AIza...",
  "strategy": "both",
  "monitorMode": true
}
```

### Output

Three item types in the same dataset (use the **Audits** and **Benchmark** views, or filter on `type`).

#### `audit` — one per URL and device

```json
{
  "type": "audit",
  "url": "https://www.yoursite.com/pricing",
  "finalUrl": "https://www.yoursite.com/pricing",
  "strategy": "mobile",
  "fetchedAt": "2026-11-09T10:15:00.000Z",
  "lighthouseVersion": "12.8.2",
  "scores": { "performance": 61, "accessibility": 83, "bestPractices": 96, "seo": 92, "overall": 83 },
  "lab": { "lcpMs": 3413, "clsScore": 0.041, "tbtMs": 318, "fcpMs": 1950, "speedIndexMs": 4120, "ttiMs": 5820, "ttfbMs": 412 },
  "field": {
    "source": "url",
    "lcp": { "p75": 2900, "rating": "needs-improvement", "distribution": { "good": 0.63, "needsImprovement": 0.25, "poor": 0.12 } },
    "inp": { "p75": 310, "rating": "needs-improvement", "distribution": { "good": 0.6, "needsImprovement": 0.3, "poor": 0.1 } },
    "cls": { "p75": 0.05, "rating": "good", "distribution": { "good": 0.91, "needsImprovement": 0.06, "poor": 0.03 } },
    "fcp": { "p75": 2100, "rating": "needs-improvement", "distribution": { "good": 0.66, "needsImprovement": 0.22, "poor": 0.12 } },
    "ttfb": { "p75": 1210, "rating": "needs-improvement", "distribution": { "good": 0.55, "needsImprovement": 0.32, "poor": 0.13 } },
    "overall": "needs-improvement"
  },
  "cwv": {
    "pass": false,
    "basis": "field",
    "field": { "lcp": "needs-improvement", "inp": "needs-improvement", "cls": "good", "pass": false },
    "lab": { "lcp": "needs-improvement", "cls": "good", "tbt": "needs-improvement", "pass": false }
  },
  "opportunities": [
    { "id": "render-blocking-resources", "title": "Eliminate render-blocking resources", "score": 0, "savingsMs": 1230, "savingsBytes": null, "metricSavings": { "FCP": 1230, "LCP": 1230 }, "displayValue": "Potential savings of 1,230 ms" },
    { "id": "unused-javascript", "title": "Reduce unused JavaScript", "score": 50, "savingsMs": 600, "savingsBytes": 184320, "metricSavings": { "LCP": 600 }, "displayValue": "Potential savings of 180 KiB" }
  ],
  "topIssues": [
    { "category": "accessibility", "id": "image-alt", "title": "Image elements have [alt] attributes", "weight": 10, "displayValue": null },
    { "category": "seo", "id": "meta-description", "title": "Document has a meta description", "weight": 1, "displayValue": null }
  ],
  "previous": { "fetchedAt": "2026-11-08T10:15:00.000Z", "scores": { "performance": 55, "accessibility": 83, "bestPractices": 96, "seo": 92, "overall": 82 }, "lab": { "lcpMs": 3900, "clsScore": 0.04, "tbtMs": 410 }, "field": { "lcp": 3000, "inp": 320, "cls": 0.05 }, "cwvPass": false },
  "changes": { "since": "2026-11-08T10:15:00.000Z", "scores": { "performance": 6, "accessibility": 0, "bestPractices": 0, "seo": 0, "overall": 1 }, "lab": { "lcpMs": -487, "clsScore": 0.001, "tbtMs": -92 }, "field": { "lcp": -100, "inp": -10, "cls": 0 }, "cwvPassChanged": null },
  "changed": true
}
```

`previous`, `changes` and `changed` are present only in monitor mode. `field` is `null` when Google has no real-user data for the page or its origin; `cwv.basis` is then `lab`.

#### `benchmark` — one per run

```json
{
  "type": "benchmark",
  "fetchedAt": "2026-11-09T10:16:40.000Z",
  "summary": { "urls": 3, "audits": 3, "strategies": ["mobile"], "avgPerformance": 72.3, "cwvPassing": 1, "cwvAssessed": 3, "cwvPassRate": 0.333, "improved": 1, "regressed": 0 },
  "best": { "mobile": { "url": "https://www.competitor-a.com/pricing", "performance": 94, "lcpMs": 1820 } },
  "table": [
    { "rank": 1, "of": 3, "url": "https://www.competitor-a.com/pricing", "strategy": "mobile", "scores": { "performance": 94, "accessibility": 95, "bestPractices": 100, "seo": 100, "overall": 97 }, "lcpMs": 1820, "clsScore": 0.01, "tbtMs": 60, "fieldLcpMs": 2100, "fieldInpMs": 140, "fieldCls": 0.02, "cwvPass": true, "cwvBasis": "field", "cwv": { "lcp": "good", "inp": "good", "cls": "good", "pass": true }, "gapToBest": { "performance": 0, "overall": 0, "lcpMs": 0, "tbtMs": 0, "clsScore": 0 }, "topOpportunity": null, "changes": null },
    { "rank": 2, "of": 3, "url": "https://www.yoursite.com/pricing", "strategy": "mobile", "scores": { "performance": 61, "accessibility": 83, "bestPractices": 96, "seo": 92, "overall": 83 }, "lcpMs": 3413, "clsScore": 0.041, "tbtMs": 318, "fieldLcpMs": 2900, "fieldInpMs": 310, "fieldCls": 0.05, "cwvPass": false, "cwvBasis": "field", "cwv": { "lcp": "needs-improvement", "inp": "needs-improvement", "cls": "good", "pass": false }, "gapToBest": { "performance": -33, "overall": -14, "lcpMs": 1593, "tbtMs": 258, "clsScore": 0.031 }, "topOpportunity": { "id": "render-blocking-resources", "title": "Eliminate render-blocking resources", "savingsMs": 1230 }, "changes": { "performance": 6, "overall": 1, "lcpMs": -487, "cwvPassChanged": null } }
  ]
}
```

With `strategy: "both"` the table holds one ranking per device (`rank` / `of` are per device) and `best` has a `mobile` and a `desktop` entry. The benchmark always covers **all** audited URLs, also in monitor mode.

#### `error` — one per URL that could not be audited

```json
{ "type": "error", "url": "https://www.example.com/", "strategy": "mobile", "error": "HTTP 400: Lighthouse returned error: FAILED_DOCUMENT_REQUEST...", "hint": "Lighthouse could not load this page (unreachable, blocks bots, not HTML, or renders no content). Check the URL in a browser and that it does not block Google's crawler. You were not charged for this URL." }
```

The run still succeeds. Quota and key problems are detected on the first failure and the remaining URLs are skipped with a pointer to the first error, so a wrong key never burns 30 minutes.

A short run report (per-URL status, changes, errors, charged events) is stored in the key-value store under `REPORT`.

### Pricing

Pay per event, no subscription:

| Event | What you pay for |
|---|---|
| `audit` | Each audit item output (URL × device). In monitor mode: each **changed** audit only. |
| `benchmark` | One ranking/comparison item per run (only when at least one audit succeeded). |

Failed URLs are not charged. The API calls go to Google under your own key, so the Actor's compute cost is close to zero and the price reflects that: a daily monitor of 10 URLs on both devices costs cents per month.

### Monitor mode (scheduled change feed)

1. Enable `monitorMode`.
2. Create a schedule (daily is right for most sites; Lighthouse lab scores fluctuate a few points between runs, so `minScoreChange: 3` filters noise).
3. Connect an integration: Slack, email, Google Sheets, Make/Zapier or a webhook. Filter on `changed == true` or `changes.cwvPassChanged != null`.

State is kept per URL and device in the named key-value store `pagespeed-benchmark-state` on your account. The first run outputs every URL (nothing to compare with yet).

### Limits & honesty notes

- **A Google API key is required.** Google has set the keyless quota of the PageSpeed Insights API to zero. The free quota with a key is 25,000 queries/day and 400 per 100 seconds; the Actor retries per-minute limits with backoff and stops cleanly on daily limits.
- Each audit is a real Lighthouse run on Google's servers and takes 10-40 s. 20 URLs × both devices with `concurrency: 2` is roughly 10 minutes of run time (billed by the Actor as events, not minutes).
- Lab metrics (`lab`, `scores`) vary a few points between runs; that is Lighthouse, not the Actor. Real-user `field` data is a 28-day rolling p75 and only exists for pages or origins with enough Chrome traffic.
- `cwv.pass` follows Google's rule: real-user data at the URL level when available, else origin-level, else lab (LCP, CLS and TBT as the INP proxy).
- Pages behind bot protection (Cloudflare challenges, 403 for Google's Lighthouse user agent, paywalls) cannot be lab-audited by anyone, this Actor included. They come back as an `error` item with the HTTP status in the message and the real-user `field` data attached when Google has it; they are not charged and not ranked.
- Lighthouse 12+ reports "insights" instead of classic opportunities for several checks; both appear in `opportunities` with `metricSavings` per metric (CLS savings are unitless and never counted as milliseconds).
- The key is passed as a secret input and sent only to `www.googleapis.com`. It is never written to the dataset, the report or the log.

### Integrations & API

Run from the Apify API, the JavaScript or Python client, Make, Zapier, n8n, LangChain, or any MCP client. Output is available as JSON, CSV, Excel, or via the dataset API.

# Actor input Schema

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

Pages to audit. Add 2+ URLs (your page plus competitors) to get the ranking table and gaps vs the best page.

## `googleApiKey` (type: `string`):

Your own key for the PageSpeed Insights API (free: 25,000 queries/day). Create it in Google Cloud Console → APIs & Services → Credentials, and enable 'PageSpeed Insights API' on the project. Google no longer serves requests without a key, so this field is required in practice. The key is stored encrypted and only sent to googleapis.com.

## `strategy` (type: `string`):

Mobile is what Google uses for ranking signals. 'both' runs two audits per URL.

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

Categories to score. Performance is always needed for Core Web Vitals; the others add their 0-100 score and failing audits to each item.

## `monitorMode` (type: `boolean`):

Remembers the last scores per URL and device. Audits whose scores did not move by at least 'Min score change' are not output (and not charged); every output item carries the previous scores and the deltas. The benchmark item is always produced and shows changes for all URLs. Schedule the Actor daily and you get a change feed.

## `minScoreChange` (type: `integer`):

Minimum change in any category score (0-100 points) for an audit to count as changed.

## `maxOpportunities` (type: `integer`):

Top performance opportunities (sorted by estimated savings) and top failing audits per other category.

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

How many URLs are audited at the same time. Each PageSpeed request takes 10-40 s. Keep at 1-2 with a fresh key; 3-4 is fine within the default 400 queries/100 s quota.

## `locale` (type: `string`):

Locale for audit titles (e.g. en, de, fr, el).

## Actor input object example

```json
{
  "urls": [
    "https://www.wikipedia.org",
    "https://www.bbc.com"
  ],
  "strategy": "mobile",
  "categories": [
    "performance",
    "accessibility",
    "best-practices",
    "seo"
  ],
  "monitorMode": false,
  "minScoreChange": 1,
  "maxOpportunities": 5,
  "concurrency": 2,
  "locale": "en"
}
```

# Actor output Schema

## `audits` (type: `string`):

Scores, Core Web Vitals and opportunities per URL and device (items with type = audit).

## `benchmark` (type: `string`):

Ranking table with gaps vs the best page, pass/fail per threshold and changes vs the previous run (item with type = benchmark).

## `allItems` (type: `string`):

Audits, benchmark and error items together.

## `report` (type: `string`):

Per-URL status, changes and errors for this run.

# 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 = {
    "urls": [
        "https://www.wikipedia.org",
        "https://www.bbc.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("nextforbes/pagespeed-benchmark").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 = { "urls": [
        "https://www.wikipedia.org",
        "https://www.bbc.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("nextforbes/pagespeed-benchmark").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 '{
  "urls": [
    "https://www.wikipedia.org",
    "https://www.bbc.com"
  ]
}' |
apify call nextforbes/pagespeed-benchmark --silent --output-dataset

```

## MCP server setup

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

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/OUvJPcpLUHcrBu5Bo/builds/JXDQF6LVSujZMnUTQ/openapi.json
