Does this URL pass Core Web Vitals? Check CrUX field data in Python, with an honest origin fallback
PageSpeed Insights answers "does this one URL pass Core Web Vitals?" well. It answers badly when you have 300 URLs, a template you want to compare, or a weekly report to produce. The CrUX API is the source of that field data, and it is small enough to call from a short script with no dependencies. The catch is that a few details of the response are easy to get wrong, and one of them silently…
Core Web Vitals can be evaluated using the CrUX API through a Python script. This API provides real-user data from Chrome, aggregated over a 28-day window and refreshed daily. For each metric, you receive a histogram and a 75th percentile value. A page passes a Core Web Vital when its 75th percentile value falls within the "good" range.
The script handles several traps, such as CLS being a string, a 404 response being normal, falling back to origin changes the meaning, and a missing metric not being a pass. To use the script, save it as crux_cwv.py, provide an API key, and run it with a list of URLs and an output CSV file. The script supports checking the page speed performance on different devices, such as PHONE, DESKTOP, or TABLET, and generates a report indicating whether each URL passes the Core Web Vitals.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.