Get a PageSpeed Insights API Key

Step-by-step guide to getting a free PageSpeed Insights API key from Google Cloud Console. Setup takes 2 minutes.
Harlan WiltonHarlan Wilton3 min read Published

Free API key setup in 2 minutes. No billing required for the free tier.

Steps

1. Open Google Cloud Console

Go to console.cloud.google.com

Sign in with any Google account. You don't need a paid Google Cloud account - the PSI API has a free tier.

2. Create or Select a Project

Click the project dropdown at the top of the page:

  • New users: Click "New Project", give it a name like "PSI Testing", and create
  • Existing users: Select an existing project or create a new one

3. Enable the PageSpeed Insights API

  1. Go to APIs & ServicesLibrary (or search "API Library" in the top search bar)
  2. Search for "PageSpeed Insights API"
  3. Click on it and press Enable

The API is now active for your project.

4. Create Credentials

  1. Go to APIs & ServicesCredentials
  2. Click Create CredentialsAPI Key
  3. Copy the key that appears

Your key is ready to use immediately.

Secure Your Key

API keys can be stolen and abused. For example, exposed API keys can lead to significant unauthorized charges if attackers use them to call other billable GCP APIs. Always add restrictions.

For Server-Side Use

Restrict by IP address:

  1. Click on your API key in the Credentials list
  2. Under Application restrictions, select IP addresses
  3. Add your server's IP address(es)
  4. Save

Note: IP restrictions don't work with serverless platforms (Vercel, Cloudflare Workers, AWS Lambda) since they use dynamic IPs. Use HTTP referrer restrictions or a server-side proxy instead.

For Client-Side Use

Restrict by HTTP referrer:

  1. Click on your API key in the Credentials list
  2. Under Application restrictions, select HTTP referrers
  3. Add your domain: yourdomain.com/*
  4. Save

API Restrictions (Critical)

Always limit the key to only the PSI API - this prevents the billing nightmare above:

  1. Under API restrictions, select Restrict key
  2. Choose PageSpeed Insights API from the dropdown
  3. Save

Test Your Key

Verify it works with a curl request:

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

A successful response returns JSON with Lighthouse data. An invalid key returns:

{
  "error": {
    "code": 400,
    "message": "API key not valid. Please pass a valid API key."
  }
}

Quotas

LimitValue
Requests per day25,000
Requests per minute~240
Requests per 100 seconds per user60

Monitor usage at APIs & ServicesPageSpeed Insights APIQuotas.

The daily limit resets at midnight Pacific Time. Official Google Cloud quotas specify a default of 25,000 queries per day and 400 queries per 100 seconds (approx. 4 queries per second). Monitor and manage your limits in the Google Cloud Console. Your actual limits may vary based on project history and usage.

Set up quota alerts: Go to IAM & AdminQuotas & System Limits → find PageSpeed Insights API → Create usage alert at 50%, 80%, and 95% thresholds.

For higher limits: Create multiple GCP projects (each gets its own 25k/day quota) or request a quota increase in the Quotas section. Google is reportedly reasonable about increases for legitimate use cases.

Next Steps

Skip the API Key Dance

Unlighthouse runs Lighthouse locally - no API keys, no quotas, no Google Cloud Console.

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