Acquire a PageSpeed Insights API key from Google Cloud Console; unauthenticated requests are subject to stricter rate limits
Send GET requests to https://www.googleapis.com/pagespeedonline/v5/runPagespeed with parameters url, strategy (mobile or desktop), and key
Parse the lighthouseResult.categories object for performance, accessibility, best-practices, and seo score values (0–1 scale)
Extract Core Web Vitals audit details from lighthouseResult.audits including largest-contentful-paint, total-blocking-time, and cumulative-layout-shift numeric values
Store results with a timestamp and the strategy value so you can track score drift over deployments across both mobile and desktop strategies
Known gotchas
PSI API scores are lab data (simulated load) from a single Lighthouse run, not field data; they can vary between consecutive calls due to server variance and should be averaged across multiple runs for stable baselines
The API measures the page at analysis time with a headless Chrome emulation; pages behind authentication walls, cookie walls, or geofenced content will score differently than what real users experience
Rate limits apply per API key; batch-processing large URL lists without throttling will result in quota errors, and Google does not guarantee consistent infrastructure load conditions between test runs
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp