# PageSpeed Insights — Google Lighthouse Audits (`khadinakbar/google-pagespeed-insights`) Actor

Audit public pages with Google Lighthouse in Chrome. No API key required. Get mobile and desktop performance, accessibility, SEO and best-practice scores, lab metrics, and prioritized fixes. Optional Google API mode is available.

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

## Pricing

from $3.00 / 1,000 successful pagespeed audits

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

### Batch PageSpeed audits without an API key

For developers, SEO teams, and site owners checking pages after a release, this Actor returns **one Google Lighthouse report per URL and device**. Supply public URLs and export performance, accessibility, best-practice, and SEO scores with lab measurements and prioritized fixes.

The default engine runs Google Lighthouse in Chrome on Apify. **No Google account, API key, provider subscription, or browser setup is required.** Audit conditions differ from Google's hosted PageSpeed Insights service, so scores can differ. Each result identifies its source.

### What you get

| Field | Meaning |
| --- | --- |
| `url`, `finalUrl`, `strategy` | Requested page, resolved page, and mobile/desktop device |
| `performanceScore`, `accessibilityScore`, `bestPracticesScore`, `seoScore` | Scores from 0 to 100; unselected categories can be null |
| `lcpMs`, `fcpMs`, `tbtMs`, `speedIndexMs`, `ttfbMs` | Available Lighthouse lab measurements in milliseconds |
| `cls` | Unitless lab layout-shift score |
| `opportunities` | Top optimization recommendations ranked by estimated time savings, then byte savings |
| `failedAudits`, `failedAuditCount` | Failed Lighthouse checks and their total count before detail limits |
| `fieldData.url`, `fieldData.origin` | Separately labeled field measurements when supplied by optional Google API mode |
| `source`, `lighthouseVersion`, `fetchTime`, `warnings` | Audit provenance, engine version, measurement time, and warnings |

The default keyless engine provides lab data. Its CrUX field measurements are marked `available: false`. Lab TBT is distinct from field INP; absent field data does not establish a Core Web Vitals pass.

### Start with your important pages

```json
{
  "urls": ["https://example.com/"],
  "strategies": ["mobile", "desktop"],
  "categories": ["performance", "accessibility", "best-practices", "seo"],
  "maxAudits": 2
}
```

Run the same page on both devices to identify mobile-specific issues. Compare results after a deployment, then assign the largest supported optimization opportunities to your engineering backlog. For broader technical crawl checks after performance triage, use a separate site crawler; this focused workflow audits exactly the URLs you submit.

#### Example result

This shortened example illustrates the persisted report shape; other required fields remain present in the actual Dataset.

```json
{
  "url": "https://example.com/",
  "finalUrl": "https://example.com/",
  "strategy": "mobile",
  "performanceScore": 99,
  "accessibilityScore": 96,
  "bestPracticesScore": 100,
  "seoScore": 80,
  "lcpMs": 795.43,
  "cls": 0,
  "source": "Google Lighthouse (Apify-hosted Chrome)"
}
```

### Input controls and supported pages

- `urls`: 1–100 public HTTP(S) URLs. Exact duplicates and fragments are removed. Embedded credentials, private networks, local hostnames, and custom ports are rejected.
- `strategies`: `mobile` by default; choose `desktop` or both. Each URL/device pair is a separate audit.
- `categories`: performance, accessibility, best-practices, and SEO by default. Selecting fewer categories does not multiply the audit fee.
- `maxAudits`: defaults to 20, maximum 200. Failed attempts also consume this work limit. Input URL order and selected device order determine processing order.
- `maxOpportunities`: 0–30, default 10. `maxFailedAudits`: 0–100, default 30. Set either to zero for compact reports.
- `locale`: audit text language, default `en`.
- `requestTimeoutSecs`: per-audit deadline, 10–120 seconds, default 90. `maxDurationSecs`: run work deadline, 30–1800 seconds, default 900. Leave additional Apify run time for finalization.

Each keyless audit uses a fresh browser session, one bounded attempt, and a 20 MiB browser-network limit. Login-required pages, paywalls, security challenges, and very large pages may be unavailable. Use stable, publicly accessible pages and allow enough run time for the URL/device combinations you request. The Actor audits supplied URLs rather than crawling sitemaps or discovering links.

#### Optional Google-hosted API mode

Advanced callers may enter their own enabled Google PageSpeed key in the secret `apiKey` field to explicitly select Google's hosted API. This optional key is excluded from Dataset results, output, and logs. Keyless Lighthouse remains the default whenever the field is omitted.

Google API mode can include URL/origin CrUX field data when Google returns it; Google has announced its removal from this API. Quota/configuration errors stop additional API work. `maxRetries` controls only transient errors in optional API mode, with one extra attempt by default and at most two. The default keyless engine requires no API key and has no external API request fee.

### Pricing and cost control

The Actor uses **Pay per event: $0.003 per successful, validated, saved URL/device report** ($3 per 1,000 reports), **plus caller-paid Apify platform usage** for compute, storage, and transfer. Check the live **Pricing** tab for the current effective fee.

Both devices on one URL produce two result events. All selected Lighthouse categories are included in each event. There is no startup fee. Failed audits, invalid inputs, Google quota/configuration errors, and retries have no result-event fee; platform usage may still accrue. Optional Google API quota belongs to the caller's Google project.

Use Apify's maximum run spending setting together with `maxAudits`. The Actor checks result affordability before starting another audit, preserves the last affordable report, and reports unfinished work explicitly. The event limit covers Actor result charges; platform usage is an additional cost. Browser audits generally use more compute than a simple HTTP lookup.

### Results, partial runs, and terminal records

Successful reports go to the default Dataset, where Apify offers JSON, CSV, and Excel export. `OUTPUT` summarizes outcome and saved rows; `RUN_SUMMARY` includes attempts, failures, skipped work, source, and acknowledged named-event counts.

`COMPLETE` means the scheduled work finished. `PARTIAL` preserves useful results when a page fails or a work/spending limit stops the run. `INVALID_INPUT` explains a user-correctable request. If valid advertised work produces no useful report because all routes fail, the run ends `FAILED` with `UPSTREAM_FAILED`. Missing engine/deployment configuration is `CONFIG_ERROR` and also fails honestly.

The serialized Dataset/billing writer validates each report before persistence and billing. Interrupted or uncertain effects require reconciliation before automatic continuation; storage and billing are separate effects, and SDK acknowledgement is distinct from invoice settlement.

### Call from the Apify API

```bash
curl --request POST \
  'https://api.apify.com/v2/acts/khadinakbar~google-pagespeed-insights/runs' \
  --header "Authorization: Bearer $APIFY_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"urls":["https://example.com/"],"strategies":["mobile","desktop"],"maxAudits":2}'
```

For AI agents and MCP clients: “Audit these public URLs with `khadinakbar/google-pagespeed-insights` on mobile and desktop, without an API key. Wait for the run, read `OUTPUT` and `RUN_SUMMARY`, retrieve every Dataset report, and summarize the largest supported fixes with URL, device, source, measurement time, and actual run cost.” The Actor's core acceptance is its batch API; client-specific hosted MCP behavior must be checked in your chosen client.

### Builder's note and responsible use

Fresh isolated Chrome sessions keep URL/device audits independent. Redirects and subresources pass through a public-address-only proxy that validates and pins DNS destinations; this also prevents an audited page from reaching private services through its resources. Scores remain point-in-time measurements that can vary with network and page changes.

Audit public pages you own or are authorized to assess. Respect applicable site terms and access controls. Results are technical measurements, not ranking guarantees or a guarantee of legal compliance. Google Lighthouse is Apache-2.0 software. This independent Actor is not endorsed by Google.

# Actor input Schema

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

Public HTTP(S) URLs, up to 100. Fragments and exact duplicates are removed.

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

One billable audit per URL and selected device.

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

Select Lighthouse categories. Categories do not multiply the audit fee.

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

Optional: provide your own Google API key only to select Google-hosted PageSpeed instead of the default keyless Lighthouse engine. This confidential value is never written to the dataset, output, or logs.

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

Language tag for Google audit text, for example en or de.

## `maxAudits` (type: `integer`):

Maximum audits, including failed attempts. Both devices count as two audits per URL. URLs are processed in input order, mobile/desktop in selected order.

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

Extra attempts for transient Google API failures in optional API mode. The default keyless browser audit uses one bounded attempt per URL/device.

## `requestTimeoutSecs` (type: `integer`):

Maximum time for each Google API attempt.

## `maxDurationSecs` (type: `integer`):

Stops new work and bounds current API requests. Set Apify run timeout higher to allow finalization.

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

Maximum recommendations sorted by estimated time savings, then byte savings.

## `maxFailedAudits` (type: `integer`):

Maximum failed checks to include per successful audit; failedAuditCount gives the full count.

## Actor input object example

```json
{
  "urls": [
    "https://example.com/"
  ],
  "strategies": [
    "mobile"
  ],
  "categories": [
    "performance",
    "accessibility",
    "best-practices",
    "seo"
  ],
  "locale": "en",
  "maxAudits": 20,
  "maxRetries": 1,
  "requestTimeoutSecs": 90,
  "maxDurationSecs": 900,
  "maxOpportunities": 10,
  "maxFailedAudits": 30
}
```

# Actor output Schema

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

No description

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

No description

## `runSummary` (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/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("khadinakbar/google-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://example.com/"] }

# Run the Actor and wait for it to finish
run = client.actor("khadinakbar/google-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://example.com/"
  ]
}' |
apify call khadinakbar/google-pagespeed-insights --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,khadinakbar/google-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/FQPfTgcPdM250sXdo/builds/LbkU8a27DopmoNXlK/openapi.json
