PageSpeed Insights API Guide

Complete guide to using the PageSpeed Insights API. Get Lighthouse performance data programmatically with 25,000 free requests per day.
Harlan WiltonHarlan Wilton4 min read Published

The PageSpeed Insights API returns Lighthouse performance data for any URL. Free tier gives you 25,000 requests per day.

What You Get

Every API response includes:

DataDescription
Performance score0-100 Lighthouse score
Core Web VitalsLCP, CLS, TBT lab data
Field dataReal Chrome user metrics (when available)
OpportunitiesSpecific optimization suggestions
DiagnosticsDetailed performance breakdowns

The response combines lab data (Lighthouse synthetic tests) with field data from the Chrome User Experience Report when enough real user data exists for that URL.

Note: Google is discontinuing CrUX field data in the PSI API. For field data, consider using the CrUX API directly.

Quick Start

Test any URL with a single curl command:

curl "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://example.com&key=YOUR_API_KEY"

The API returns JSON with everything Lighthouse captures. No authentication beyond the API key.

When to Use the PSI API

Good for:

  • Spot-checking individual URLs programmatically
  • Integrating performance scores into dashboards
  • CI checks on critical landing pages
  • Monitoring specific URLs over time

Limitations:

  • Single URL per request
  • Rate limited (~240 requests per minute)
  • No crawling — you must provide URLs
  • Lab data only for new/low-traffic URLs

API vs CLI vs Unlighthouse

FeaturePSI APILighthouse CLIUnlighthouse
URLs per request11Entire site
Rate limit~240/minNoneNone
InfrastructureGoogle serversYour machineYour machine
CostFree (25k/day)FreeFree CLI
Field dataYesNoNo
URL discoveryManualManualAutomatic crawl

The PSI API is useful when you need field data or want to avoid running Lighthouse locally. For site-wide testing, the single-URL limitation becomes impractical.

How It Works

PSI runs Lighthouse on Google's servers from one of four locations: Oregon, South Carolina, Netherlands, or Taiwan. The location is chosen automatically based on your IP, which can affect score consistency for sites without a CDN.

  • Mobile tests simulate a Moto G4 on a slow 4G connection with CPU throttling (source)
  • Desktop tests run on a fast wired connection with no throttling
  • Lighthouse version: Currently uses Lighthouse 13.0 — PWA category removed (release notes)

Scores can vary ±5 points between runs due to network conditions and server load. For accurate monitoring, run multiple tests and use the median.

Response Structure

Key paths in the JSON response:

lighthouseResult.categories.performance.score → 0-1 (multiply by 100)
lighthouseResult.audits['largest-contentful-paint'].numericValue → LCP in ms
lighthouseResult.audits['cumulative-layout-shift'].numericValue → CLS score
lighthouseResult.audits['total-blocking-time'].numericValue → TBT in ms
loadingExperience.metrics → Field data (real users)
originLoadingExperience.metrics → Origin-level field data

The loadingExperience object contains real user metrics from CrUX. If the URL doesn't have enough traffic, this will be empty and you'll only get lab data.

Request Parameters

ParameterRequiredDescription
urlYesURL to analyze
keyYesYour API key
strategyNodesktop (default) or mobile
categoryNoperformance, accessibility, seo, best-practices (filter to reduce response size)
localeNoLocale for the report (e.g., en_US)

Request multiple categories by repeating the parameter:

curl "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://example.com&key=YOUR_KEY&category=performance&category=accessibility"

Tip: Responses can be 1-5MB. Filtering by category reduces response size significantly.

For origin-level CrUX data instead of URL-specific, use the origin: prefix:

curl "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=origin:https://example.com&key=YOUR_KEY"

Getting Started

  1. Get your API key — 2-minute setup in Google Cloud Console
  2. Choose your languageNode.js or Python
  3. Scale upBulk testing guide
  4. Handle limitsRate limit strategies

Skip the Complexity

Testing URLs one at a time doesn't scale. Building queue systems, handling rate limits, and managing retries adds complexity that isn't your core product.

Unlighthouse crawls your entire site and runs Lighthouse on every page automatically. No API keys, no rate limits, no queue management.

npx unlighthouse --site https://your-site.com

For historical tracking and scheduled scans, Unlighthouse Cloud handles everything.

Try Unlighthouse Cloud