# PageSpeed Budget Monitor: Core Web Vitals pass/fail & changes (`asunoki/pagespeed-budget-monitor`) Actor

Check many pages against performance budgets (score, LCP, CLS, TBT, optional real-user INP/LCP) with Google's PageSpeed Insights API and your own key. Pass / fail / unknown per page, and the change since your last run.

- **URL**: https://apify.com/asunoki/pagespeed-budget-monitor.md
- **Developed by:** [Seisuke Nagahara](https://apify.com/asunoki) (community)
- **Categories:** Developer tools, SEO tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 page checkeds

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 Budget Monitor — Core Web Vitals pass / fail, with change tracking

Give it a list of pages and your performance budgets. Each page is tested with **Google's official PageSpeed Insights API** (Lighthouse) using **your own free Google API key**, and you get **pass / fail / unknown** per page with the reason, real-user Core Web Vitals from the **Chrome UX Report API**, and **what changed since your last run**. Run it weekly on a schedule to catch a slow release before your customers do.

### What it does

1. Tests every page × device (mobile, desktop or both) once with PageSpeed Insights (lab test).
2. Looks up real-user data (28-day p75 of real Chrome visits) for the page, or for the whole site when the page has too little traffic.
3. Checks your budgets and writes one row per page × device: `pass`, `fail` (which budget was missed) or `unknown` (a value was not measured — **never counted as pass or fail**).
4. Optional: compares with values from a previous run that you supply, and flags real regressions only (not lab noise).
5. Saves `report.csv`, `report.html` (a one-page client report, readable on a phone) and a run summary (`OUTPUT`).

### Your Google API key

Google's shared keyless quota for PageSpeed Insights is used up most of the time, so this Actor is meant to be used with your own key. Creating one takes about 5 minutes.

**Fastest start:** Google's [PageSpeed Insights get-started page](https://developers.google.com/speed/docs/insights/v5/get-started) has a **Get a Key** button. A key for the PageSpeed Insights API alone is enough for the lab checks (score, LCP, CLS, TBT). Enable the Chrome UX Report API later if you want real-user data. Without it the lab checks still run and the real-user fields say `crux_not_enabled`. Restrict the key as in step 4 below.

Step by step in the Google Cloud console:

1. Open the Google Cloud console (https://console.cloud.google.com/) and **create a project** (for example `pagespeed-monitor`), or select an existing one.
2. **Enable the two APIs** in that project: *APIs & Services › Library* › search **"PageSpeed Insights API"** › **Enable**; then search **"Chrome UX Report API"** › **Enable**.
3. **Create the key**: *APIs & Services › Credentials* › **Create credentials** › **API key**.
4. **Restrict the key** (recommended): click the key › *API restrictions* › **Restrict key** › select **PageSpeed Insights API** and **Chrome UX Report API** › **Save**. Leave *Application restrictions* at **None** (website or IP restrictions block requests from Apify's servers).
5. Copy the key and paste it into this Actor's **Google API key** field. Paste it nowhere else.

About cost on Google's side: Google's documentation says the Chrome UX Report API quota "is offered without charge", and Google publishes no usage price for the PageSpeed Insights API. This Actor uses nothing paid on Google's side. If the console asks you to add a billing account to enable these APIs, you can stop and ask us in the Issues tab.

Your key is a **secret input**: stored encrypted by Apify, sent to Google only in a request header (never in a URL), and never written to results, files or the log. You use Google's APIs under your own Google account and Google's terms; this Actor never shares one key between users.

Google's documentation:

- PageSpeed Insights API, get started: https://developers.google.com/speed/docs/insights/v5/get-started
- Chrome UX Report API (key and quota): https://developer.chrome.com/docs/crux/api
- Create and restrict API keys: https://docs.cloud.google.com/docs/authentication/api-keys
- Enable an API: https://docs.cloud.google.com/apis/docs/getting-started

### Pricing (pay per event)

You pay only for **pages that were measured**: one `page-checked` event per page × device with a complete Lighthouse result (score, LCP, CLS, TBT). Pages that could not be measured, duplicates and rows saved before a restart are **free**. Apify also charges a small fixed Actor-start event per run. The current prices are on the Pricing tab.

| Run | Events | At $0.004 per page × device |
|---|---|---|
| 1 page, mobile (the prefilled example) | 1 | $0.004 + start |
| 1 page, mobile + desktop | 2 | $0.008 + start |
| 50 pages, mobile, weekly (≈ 4.3 runs a month) | 215 / month | ≈ $0.86 / month + starts |
| 200 pages, mobile + desktop, once | 400 | $1.60 + start |

Set **Maximum cost per run** in the run options to cap a run: the Actor stops before testing a page it could not charge for, and nothing beyond the cap is charged.

### What you get per page

| Field | Meaning |
|---|---|
| `status` | `pass` / `fail` / `unknown` against all budgets |
| `reason` | which budgets failed, or why it is unknown |
| `performanceScore`, `lcpMs`, `cls`, `tbtMs`, `fcpMs`, `speedIndexMs` | lab values (one Lighthouse run in Google's data centre, simulated device and network) |
| `fieldStatus` | `page` or `origin` (real-user data found), `no_field_data` (Google has no real-user data for the page or the site), `not_requested`, or a setup problem such as `crux_not_enabled` |
| `field` | real-user p75 LCP, INP, CLS with `source` (`crux` or `psi`), `scope` (`page` / `origin`) and the collection `period` |
| `checks` | each budget with value, limit and `pass` / `fail` / `unknown` |
| `change` | difference to your baseline; `regressed: true` only beyond lab noise (score −5, LCP +300 ms, CLS +0.02, TBT +100 ms); `comparable: false` when the Lighthouse major version or the final URL (redirect) changed |
| `billed` | `true` if this row was a charged event |
| `error`, `errorMessage` | why a page was not measured (free) |

Lab and real-user numbers measure different things and often disagree: the **Core Web Vitals assessment** is based on real-user data, the **Lighthouse score** is a lab score. Real-user values come from the Chrome UX Report API, so they keep working when Google removes the real-user block from PageSpeed Insights results, which Google has announced. If the Chrome UX Report API is not enabled for your key, the Actor tells you in the log and (with `auto`) uses the PageSpeed Insights real-user block as long as Google still provides it.

### Budgets (defaults)

| Budget | Default | Source of the default |
|---|---|---|
| Minimum performance score | 50 | Lighthouse "needs improvement" line |
| Max LCP (lab) | 2,500 ms | Google's "good" LCP threshold |
| Max CLS (lab) | 0.1 | Google's "good" CLS threshold |
| Max TBT (lab) | 200 ms | Lighthouse "good" TBT line |
| Max INP / LCP (real users, p75) | off | set them if you want real-user checks; no real-user data = `unknown` |

### Errors and what to do

| Code | Meaning | Charged | Run |
|---|---|---|---|
| `url_rejected` | Google could not test the URL (400): not public, blocked, not HTML, DNS error | no | continues |
| `google_server_error` | Google / Lighthouse error (5xx) after 3 attempts | no | continues |
| `timeout`, `network_error` | no answer after 3 attempts | no | continues |
| `lab_incomplete` | Lighthouse returned no score, LCP, CLS or TBT | no | continues |
| `key_invalid` | the key is wrong: copy it again from *Credentials* | no | stops ¹ |
| `api_not_enabled` | **PageSpeed Insights API** is not enabled in the key's project: *Library › PageSpeed Insights API › Enable* | no | stops ¹ |
| `key_restricted` | the key's API restrictions do not include **PageSpeed Insights API** | no | stops ¹ |
| `key_app_restricted` | the key has website / IP / app restrictions: set *Application restrictions* to None | no | stops ¹ |
| `quota_exceeded` | the daily quota of the key's project is used up (or no key was given) | no | stops |
| `rate_limited` | Google's per-minute limit kept being hit after pauses: lower **Parallel checks** | no | stops |
| `spending_limit` | your maximum cost per run is reached | — | stops |
| `fieldStatus: crux_not_enabled` / `crux_key_restricted` | enable or allow **Chrome UX Report API** for the key; lab checks still run | — | continues |

¹ The run is marked as failed when a key was given and no page could be measured, so a scheduled run does not fail silently.

Quotas are set by Google on your project (Google Cloud console › APIs & Services › the API › Quotas). The Chrome UX Report API allows 150 queries per minute per project.

### Change since a previous run — you supply the previous values

This Actor **keeps no results between runs**. Google's API terms do not allow building a database or permanent copy of API results beyond what the response cache header permits (Google APIs Terms of Service §5(e)), so the comparison uses values that you hold yourself:

- **Baseline values** (recommended): paste `{"url", "strategy", "performanceScore", "lcpMs", "cls", "tbtMs"}` rows, for example from last month's `report.csv`.
- **Compare with dataset**: select a results dataset of an earlier run that you still hold. It is read for this run only; nothing is copied or kept.
  Rows are matched by page and device (mobile and desktop are never mixed). A value missing on either side is not compared.

### Limits

- Up to 500 different URLs per run; public pages only (no login).
- One Lighthouse run per page × device takes about 10–30 s at Google; lab results vary between runs, so small changes are treated as noise.
- Real-user data exists only for pages and sites with enough Chrome traffic; otherwise real-user checks are `unknown`.
- Real-user data: Chrome UX Report, Google, licensed under CC BY 4.0. This Actor is not produced or endorsed by Google.

# Actor input Schema

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

Public page URLs (up to 500 different URLs per run). Each page is tested once per device. Duplicates are removed. Cost: one charged event per page × device that was measured; pages that could not be measured are free.

## `apiKey` (type: `string`):

Your own free Google API key. In the key's Google Cloud project enable "PageSpeed Insights API" and "Chrome UX Report API", and restrict the key to those two APIs (step-by-step guide in the README, section "Your Google API key"). Secret: stored encrypted by Apify, sent to Google only in a request header, never written to results, files or the log. Without a key Google's shared quota is usually used up and the pages fail with quota_exceeded (not charged).

## `strategies` (type: `array`):

mobile, desktop or both. Each page × device is one test and, when measured, one charged event (e.g. 10 pages × both devices = 20 events).

## `minPerformanceScore` (type: `integer`):

Lighthouse performance score (0-100) a page must reach. Default 50.

## `maxLcpMs` (type: `integer`):

Largest Contentful Paint in the lab test, milliseconds. Default 2500 (Google "good").

## `maxCls` (type: `string`):

Decimal number, e.g. 0.1 (Google "good" threshold).

## `maxTbtMs` (type: `integer`):

Total Blocking Time in the lab test, milliseconds. Default 200.

## `maxFieldInpMs` (type: `integer`):

Optional. Real-user INP p75 (28 days), milliseconds. Empty = not checked. Google "good" = 200. Pages and sites without real-user data get unknown for this check (never pass, never fail).

## `maxFieldLcpMs` (type: `integer`):

Optional. Real-user LCP p75 (28 days), milliseconds. Empty = not checked. Google "good" = 2500. No real-user data = unknown.

## `comparisonMode` (type: `string`):

Leave empty to choose automatically: pasted baseline values, else a selected dataset, else no comparison.

## `baseline` (type: `array`):

List of {"url", "strategy", "performanceScore", "lcpMs", "cls", "tbtMs"} from your own records (for example last month's report.csv). Optional: "lighthouseVersion", "finalUrl", "checkedAt".

## `baselineDatasetId` (type: `string`):

A results dataset of an earlier run that you still hold. Read-only: the Actor reads it for this run and copies nothing.

## `maxConcurrency` (type: `integer`):

Tests running at the same time (1-8). Lower it if the run stops with rate_limited (Google's per-minute limit).

## `htmlReport` (type: `boolean`):

Also save report.html (one page, no external files) in the key-value store: status, lab values, real-user values and changes, readable on a phone.

## `reportTitle` (type: `string`):

Shown at the top of report.html, e.g. the client or site name. Optional.

## `fieldSource` (type: `string`):

Real-user data is the 28-day p75 from the Chrome UX Report. Used for the optional real-user budgets and shown for information. Pages with too little traffic have no page data (the origin is used instead); with no data at all the row says fieldStatus = no_field_data and real-user checks are unknown.

## Actor input object example

```json
{
  "urls": [
    "https://example.com/"
  ],
  "strategies": [
    "mobile"
  ],
  "minPerformanceScore": 50,
  "maxLcpMs": 2500,
  "maxCls": "0.1",
  "maxTbtMs": 200,
  "maxConcurrency": 4,
  "htmlReport": true,
  "fieldSource": "auto"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `csv` (type: `string`):

No description

## `html` (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 = {
    "urls": [
        "https://example.com/"
    ],
    "strategies": [
        "mobile"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("asunoki/pagespeed-budget-monitor").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://example.com/"],
    "strategies": ["mobile"],
}

# Run the Actor and wait for it to finish
run = client.actor("asunoki/pagespeed-budget-monitor").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://example.com/"
  ],
  "strategies": [
    "mobile"
  ]
}' |
apify call asunoki/pagespeed-budget-monitor --silent --output-dataset

```

## MCP server setup

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

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/lkEmYv6h1ZjoA1E52/builds/NYL1IuEqcRvCM0vfL/openapi.json
