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.

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 (400 requests per 100 seconds)
  • 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 limit400/100sNoneNone
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.

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
strategyNomobile (default) or desktop
categoryNoperformance, accessibility, seo, best-practices
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"

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