Your Lighthouse score says the page is slow, your users say it is fine, and you do not know which number to trust or whether either one is getting worse.
I ran into this today with python.org. One mobile Lighthouse run gave a Largest Contentful Paint (LCP) of 3,495 ms. That is "needs improvement". Google's real-user data for the same site, from Chrome users on phones, gives a p75 LCP of 1,195 ms. That is comfortably "good". Both numbers are correct. They measure different things.
- Lab data (Lighthouse) is one simulated load on a throttled phone. It is repeatable and it tells you why a page is slow.
- Field data (Chrome UX Report, CrUX) is what real visitors experienced over the last 28 days. Google uses this one for Core Web Vitals in Search.
The usual approach is to open PageSpeed Insights, paste a URL, look at the score and close the tab. That breaks down when you have 20 or 200 URLs, when you want to know whether this week is worse than last week, and when the keyless API answers with 429 Too Many Requests. That happened to me twice in a row while writing this post.
Below is a small Python script that does both checks for a list of URLs, keeps a history in a CSV file and prints an alert when something gets worse. It uses only the standard library and two free Google APIs.
Step 1: get a free Google API key
- Open the Google Cloud console and create a project (or reuse one).
- Enable Chrome UX Report API and PageSpeed Insights API for that project.
- Create an API key under APIs & Services → Credentials.
Both APIs are free. The key just gives you your own quota instead of the shared anonymous one. Note: a key only works for the APIs you enabled on it. My first key only had CrUX enabled, and PageSpeed Insights answered 403 Forbidden.
export GOOGLE_API_KEY="paste-your-key-here" Step 2: real-user history from the CrUX History API
The CrUX History API returns up to 25 weekly data points (about 6 months) of p75 values per metric. Each point covers a rolling 28-day window. You can ask for a single page (url) or a whole site (origin). Low-traffic pages often have no page-level data, so the origin is the safe fallback.
import json, os, urllib.request KEY = os.environ["GOOGLE_API_KEY"] CRUX = "https://chromeuxreport.googleapis.com/v1/records:queryHistoryRecord?key=" + KEY METRICS = ["largest_contentful_paint", "interaction_to_next_paint", "cumulative_layout_shift"] def post(url, body): req = urllib.request.Request(url, data=json.dumps(body).encode(), headers={"Content-Type": "application/json"}) with urllib.request.urlopen(req, timeout=60) as r: return json.load(r) def crux_history(target, form_factor="PHONE"): """target = a full page URL or an origin like https://example.com""" key = "origin" if target.rstrip("/").count("/") == 2 else "url" for body in ({key: target}, {"origin": "/".join(target.split("/")[:3])}): body.update(formFactor=form_factor, metrics=METRICS) try: rec = post(CRUX, body)["record"] except urllib.error.HTTPError as e: if e.code == 404: # not enough traffic at this level, try the origin continue raise end = rec["collectionPeriods"][-1]["lastDate"] out = {"level": "url" if "url" in rec["key"] else "origin", "lastDate": f"{end['year']}-{end['month']:02d}-{end['day']:02d}"} for m, v in rec["metrics"].items(): out[m] = v["percentilesTimeseries"]["p75s"] return out return None h = crux_history("https://www.python.org") print(h["level"], h["lastDate"]) for m in METRICS: print(m, h[m][-5:]) The real output I got today (2026-11-18):
origin 2026-11-14 largest_contentful_paint [1111, 1133, 1154, 1182, 1195] interaction_to_next_paint [94, 94, 94, 94, 94] cumulative_layout_shift ['0.00', '0.00', '0.00', '0.00', '0.00'] Two things to notice. CLS comes back as a string, so convert it with float(). And LCP is still "good" (under 2,500 ms), but it went up in each of the last five weekly points. A single PageSpeed check would never show you that trend.
Step 3: lab data from the PageSpeed Insights API
The field data tells you that something changed. The lab run tells you why.
import urllib.parse PSI = "https://www.googleapis.com/pagespeedonline/v5/runPagespeed?" def lab(url, strategy="mobile"): q = urllib.parse.urlencode([("url", url), ("strategy", strategy), ("category", "performance"), ("key", KEY)]) with urllib.request.urlopen(PSI + q, timeout=120) as r: lh = json.load(r)["lighthouseResult"] a = lh["audits"] ops = sorted((x for x in a.values() if (x.get("details") or {}).get("overallSavingsMs", 0) > 0), key=lambda x: -x["details"]["overallSavingsMs"]) return {"performance": round(lh["categories"]["performance"]["score"] * 100), "lcpMs": round(a["largest-contentful-paint"]["numericValue"]), "tbtMs": round(a["total-blocking-time"]["numericValue"]), "cls": round(a["cumulative-layout-shift"]["numericValue"], 3), "top": [(x["title"], round(x["details"]["overallSavingsMs"])) for x in ops[:3]]} For python.org on mobile, today's Lighthouse 13.6 run gave:
performance 89, LCP 3495 ms, FCP 2131 ms, TBT 73 ms, CLS 0.003, 23 requests, 474 KB top fixes: Render-blocking requests (~1250 ms), Reduce unused CSS (~620 ms, 132 KB), Reduce unused JavaScript (~310 ms, 61 KB) So the lab says "fix render-blocking CSS first". The field data says real users are still fine, but slowly getting worse. Together they give you a priority list and a reason to act now rather than later.
Step 4: one script for a list of URLs, with history and alerts
Put your URLs in urls.txt, one per line. The script appends one row per URL per day to cwv_history.csv and prints an alert when the real-user p75 LCP rises by more than 10% compared with 4 weeks earlier, or when it crosses the 2,500 ms "good" line.
import csv, datetime, sys, time GOOD_LCP = 2500 today = datetime.date.today().isoformat() urls = [u.strip() for u in open("urls.txt") if u.strip()] alerts = [] with open("cwv_history.csv", "a", newline="") as f: w = csv.writer(f) for u in urls: try: h = crux_history(u) lb = lab(u) except Exception as e: # keep going, report at the end alerts.append(f"{u}: error {e}") continue lcp = h["largest_contentful_paint"] if h else [] now, before = (lcp[-1], lcp[-5]) if len(lcp) >= 5 else (None, None) w.writerow([today, u, h and h["level"], now, h and h["interaction_to_next_paint"][-1], lb["performance"], lb["lcpMs"], lb["top"][0][0] if lb["top"] else ""]) if now and (now > GOOD_LCP or now > before * 1.10): alerts.append(f"{u}: real-user LCP p75 {before} -> {now} ms; first fix: {lb['top'][:1]}") time.sleep(1) # be polite to the free quota print("\n".join(alerts) or "no alerts") sys.exit(1 if alerts else 0) The non-zero exit code is useful: a cron wrapper or CI job can send you an e-mail only when there is something to look at.
Step 5: run it every day
CrUX history updates once a week, but the lab run catches a broken deploy the same day. A daily cron job is enough:
# crontab -e 15 6 * * * cd /home/me/cwv && /usr/bin/python3 cwv.py >> cwv.log 2>&1 After a month you have a CSV you can open in any spreadsheet and chart. That is usually more convincing in a meeting than a single screenshot of a score.
Honest limits
- Lab numbers move. Two Lighthouse runs of the same page can differ by several points. Alert on field data or on big lab changes, not on a 3-point dip.
- Field data needs traffic. Small sites and new pages often have no CrUX record at all (HTTP 404). The script falls back to the origin, but a brand-new site has neither.
- Field data lags. It is a 28-day rolling window, published weekly. A fix you ship today shows fully in about a month.
- Quota. With your own key the free quota is fine for a few hundred URLs a day. Without a key, expect
429errors, as I got today.
If you do not want to run this yourself
I built a hosted version of exactly this: real Lighthouse in headless Chrome for a list of URLs (no PageSpeed quota), the same CrUX field data and weekly history in each row, and a monitoring mode that only reports pages whose score dropped. It is the Lighthouse PageSpeed Checker actor on Apify (martin10291/lighthouse-pagespeed-audit, $10 per 1,000 audited pages, you run it with your own Apify token), and the same API is on RapidAPI with a free plan of 100 calls. The script above works fine without it. The hosted version is just less to maintain once you have many URLs or want mobile and desktop for each one.
What do you track today: lab scores, field data, or neither? I would like to hear which metric actually made your team fix something.
You can try the same thing in the browser, without code: radarbg.com/apis/lighthouse-pagespeed-audit
Disclosure: I build the tool used in this post, and the article was written with AI assistance. If a code sample does not work for you, tell me in the comments and I will fix it.