Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find score inside json result of PageSpeed Insights API v5

I'm trying the Google v5 API page speed insight but i don't find the SCORE inside the JSON result.

This is the api https://www.googleapis.com/pagespeedonline/v5/runPagespeed

In the v4 there is a ruleGroups.SPEED.score that contains an integer with the score.

Where i can find the score inside the v5?

like image 413
bertasoft Avatar asked Nov 13 '18 22:11

bertasoft


People also ask

How is PageSpeed Insights score calculated?

Performance score This score is determined by running Lighthouse to collect and analyze diagnostic information about the page. A score of 90 or above is considered good. 50 to 90 is a score that needs improvement, and below 50 is considered poor.

How do I export PageSpeed Insights report?

If you open up and run Google PageSpeed Insights through the Audit tab in Chrome Developer Tools, there is a button in the left part of the panel that will allow you to download the report as a JSON file. Save this answer. Show activity on this post.

Why is my Lighthouse score different from PageSpeed Insights?

What's the difference or, better said, “the differences” between these two audit tools provided by Google? PageSpeed Insights measures the performance metric only, whereas Lighthouse audits other aspects of a website, as well (SEO, accessibility, progressive web app, etc.)


1 Answers

It is json.lighthouseResult.categories.performance.score as described by Jeroen.

You can return all possible audit categories using the following example:

  • URL: https://www.google.com/
  • Return-Fields: lighthouseResult/categories/*/score
    • * is a wildcard
  • Indentations (PrettyPrint): no
  • Strategy: Desktop
  • Categories:
    • Performance
    • Progressive Web App (PWA)
    • Best practices
    • Accessibility
    • SEO
  • Api-Key: {YOUR_API_KEY}
    With these parameters, the API URL is:

    https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https%3A%2F%2Fstackoverflow.com%2F&fields=lighthouseResult%2Fcategories%2F*%2Fscore&prettyPrint=false&strategy=desktop&category=performance&category=pwa&category=best-practices&category=accessibility&category=seo&key={YOUR_API_KEY}


And the JSON-Response looks like this:
{
    "lighthouseResult": {
        "categories": {
            "performance": {
                "score":0.99
            },
            "accessibility": {
                "score":0.7
            },
            "best-practices": {
                "score":0.77
            },
            "seo": {
                "score":0.9
            },
            "pwa": {
                "score":0.56
            }
        }
    }
}
like image 137
5chw4hn Avatar answered Sep 28 '22 01:09

5chw4hn