# Google PageSpeed Insights – Core Web Vitals & Lighthouse (BYOK) (`pinkish_armada/pagespeed-insights`) Actor

Bulk Google PageSpeed Insights audits via the official PSI API. Bring your own free Google API key. Performance, accessibility, best-practices and SEO scores, Core Web Vitals (LCP, CLS, INP), CrUX field data, opportunities and diagnostics for mobile and desktop.

- **URL**: https://apify.com/pinkish_armada/pagespeed-insights.md
- **Developed by:** [Phuc Tiet](https://apify.com/pinkish_armada) (community)
- **Categories:** SEO tools, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 audited pages

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

## Google PageSpeed Insights – Core Web Vitals & Lighthouse (BYOK)

Run **Google PageSpeed Insights** on any list of URLs through the **official PSI API**. You bring your own free Google API key; we return clean JSON with Lighthouse scores, Core Web Vitals lab metrics, Chrome UX Report (CrUX) field data, opportunities and diagnostics — for **mobile and/or desktop**.

### Why this Actor

- 💸 **$1.50 per 1,000 successful audits** ($0.0015 each). Dedicated PSI Actors often charge $10–$80 per 1,000.
- 🔑 **Bring your own Google API key.** Google's free PSI quota is yours; we never store the key outside your run and we never call PSI with our own key.
- ✅ **Charge only on success.** Missing key, invalid URLs, HTTP 400/403/429 from Google and timeouts are free.
- 📊 **Structured output.** Scores (0–100), LCP/CLS/INP/TBT/FCP, CrUX categories, top opportunities and diagnostics — ready for Sheets, dashboards, agents (MCP / Make / Zapier / n8n).
- 🤖 **Agent-friendly.** One Actor call, no browser, no proxies, limited permissions.

### How much does it cost?

| Event | Price |
|---|---|
| Successful page audit (one URL × one strategy) | **$0.0015** |
| Actor start | $0.00005 / GB (Apify platform) |

Failed audits (bad key, rate limit, timeout, invalid URL) are **not charged**. Platform compute for a typical 10-URL mobile run is a few tenths of a cent.

**Example:** 500 URLs × mobile = up to **$0.75** in Actor fees (plus your free Google PSI quota).

### Input

```json
{
  "urls": ["https://www.example.com/", "https://www.gov.uk/"],
  "googleApiKey": "YOUR_GOOGLE_API_KEY",
  "strategies": ["mobile"],
  "categories": ["performance"]
}
```

| Field | Required | Default | Description |
|---|---|---|---|
| `urls` | yes | – | Pages to audit (max 500). Bare domains get `https://`. |
| `googleApiKey` | yes | – | Secret. Free key with [PageSpeed Insights API](https://developers.google.com/speed/docs/insights/v5/get-started) enabled. |
| `strategies` | no | `["mobile"]` | `mobile` and/or `desktop`. Each pair is one audit. |
| `categories` | no | `["performance"]` | `performance`, `accessibility`, `best-practices`, `seo`. |
| `maxConcurrency` | no | `2` | Parallel PSI calls (keep low for free-tier quotas). |
| `timeoutSecs` | no | `120` | Per-audit timeout. |
| `locale` | no | – | Optional Lighthouse locale (`en`, `de`, …). |

#### Get a free Google API key (2 minutes)

1. Open https://developers.google.com/speed/docs/insights/v5/get-started
2. Create (or pick) a Google Cloud project.
3. Enable **PageSpeed Insights API**.
4. Create an API key and paste it into `googleApiKey`.
5. (Recommended) Restrict the key to the PageSpeed Insights API.

We do **not** need, store or use the Actor owner's Google key. Every customer uses their own.

### Output (one row per URL × strategy, shortened)

```json
{
  "url": "https://www.example.com/",
  "finalUrl": "https://www.example.com/",
  "strategy": "mobile",
  "scores": {
    "performance": 92,
    "accessibility": null,
    "bestPractices": null,
    "seo": null
  },
  "metrics": {
    "firstContentfulPaintMs": 1200,
    "largestContentfulPaintMs": 1800,
    "totalBlockingTimeMs": 50,
    "cumulativeLayoutShift": 0.01,
    "speedIndexMs": 1500,
    "timeToInteractiveMs": 2100
  },
  "loadingExperience": {
    "overallCategory": "FAST",
    "lcp": { "percentile": 1600, "category": "FAST" },
    "cls": { "percentile": 5, "category": "FAST" },
    "inp": { "percentile": 80, "category": "FAST" }
  },
  "opportunities": [
    { "id": "unused-javascript", "title": "Reduce unused JavaScript", "displayValue": "Est savings of 120 KiB", "score": 0.5 }
  ],
  "diagnostics": [],
  "status": "ok",
  "checkedAt": "2026-10-15T01:00:00.000Z"
}
```

Error rows use `"status": "error"` with `errorCode` such as `MISSING_API_KEY`, `API_KEY_FORBIDDEN`, `RATE_LIMITED`, `TIMEOUT`, `INVALID_URL`, `BAD_REQUEST`.

### Related tools

- [On-Page SEO Audit](https://apify.com/pinkish_armada/seo-page-audit) – titles, meta, headings, schema (no Google key).
- [Broken Link Checker](https://apify.com/pinkish_armada/broken-link-checker) – crawl your site for 404s.
- [Sitemap URL Extractor](https://apify.com/pinkish_armada/sitemap-url-extractor) – feed this Actor a full URL list.

### FAQ

**Do I need a paid Google Cloud account?**\
No. The PageSpeed Insights API has a free quota suitable for moderate bulk use. Stay within Google's rate limits (`maxConcurrency` 1–2 helps).

**Is this the same as running Lighthouse locally?**\
Lab metrics come from Google's Lighthouse on their infrastructure (via PSI). Field data (CrUX) is real-user Chrome data when Google has enough samples for that URL/origin.

**Why BYOK instead of a shared key?**\
Google's anonymous/keyless quota is exhausted quickly from shared cloud IPs. Your own key keeps quota predictable and keeps us legally clean (your project, your quota).

**Can AI agents call this?**\
Yes. Public PPE Actors with limited permissions are available via the [Apify MCP server](https://mcp.apify.com) and agentic payments where eligible.

### Legal / ToS

Uses only the **official Google PageSpeed Insights API** with **your** API key. Follow [Google's API Terms](https://developers.google.com/terms). Do not use this Actor to probe sites you are not allowed to measure at volume.

### Changelog

- **1.0.0** – Initial release: bulk URL×strategy PSI audits, BYOK, scores + CWV + CrUX + opportunities/diagnostics, PPE $0.0015 / success.

# Actor input Schema

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

Pages to audit with the official Google PageSpeed Insights API. Up to 500 URLs per run. Bare domains get https://.

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

Your own Google Cloud API key with the PageSpeed Insights API enabled. Free quota from Google. Create one at https://developers.google.com/speed/docs/insights/v5/get-started — we never store or reuse this key outside your run.

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

Device strategies to run per URL. Each URL×strategy pair is one charged audit on success.

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

Which Lighthouse categories to request. Performance is enough for Core Web Vitals; add more only if you need them (each category makes the PSI call slower).

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

Optional Lighthouse locale (e.g. en, de, fr). Leave empty for English.

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

Concurrent calls to Google. Keep at 1–2 to stay under Google's free-tier rate limits.

## `timeoutSecs` (type: `integer`):

PSI audits can take 30–90 s. Timed-out audits are not charged.

## Actor input object example

```json
{
  "urls": [
    "https://www.example.com/",
    "https://www.gov.uk/"
  ],
  "strategies": [
    "mobile"
  ],
  "categories": [
    "performance"
  ],
  "maxConcurrency": 2,
  "timeoutSecs": 120
}
```

# Actor output Schema

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

Scores, Core Web Vitals and status per URL×strategy.

## `opportunities` (type: `string`):

Performance opportunities unwound from successful audits.

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

Audited / failed counts and settings.

# 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.example.com/",
        "https://www.gov.uk/"
    ],
    "strategies": [
        "mobile"
    ],
    "categories": [
        "performance"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("pinkish_armada/pagespeed-insights").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.example.com/",
        "https://www.gov.uk/",
    ],
    "strategies": ["mobile"],
    "categories": ["performance"],
}

# Run the Actor and wait for it to finish
run = client.actor("pinkish_armada/pagespeed-insights").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.example.com/",
    "https://www.gov.uk/"
  ],
  "strategies": [
    "mobile"
  ],
  "categories": [
    "performance"
  ]
}' |
apify call pinkish_armada/pagespeed-insights --silent --output-dataset

```

## MCP server setup

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

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/wu8Cx0xN7PfTSiwXx/builds/9yDJiFThhcFEWrz2G/openapi.json
