"I think it is the following: json.lighthouseResult.categories.performance.score
Returns a decimal with 1 as maximum. So you have to multiply with 100 to get the percentage. Works for me.. However I don't seem to get the same value every time. It fluctuates..." as Jeroen say. 100% correct
"That could not be correct. I've checked this with a few pages and json.lighthouseResult.categories.performance.score is much higher than the score from developers.google.com/speed/pagespeed/insights – Pascal Bajorat"
It is not correct because you see Desktop result not mobile result.
Desktop in 90% case 99 or 100.
Try this:
URL: https://www.google.com/
Return-Fields: lighthouseResult/categories/*/score
* is a wildcard
Indentations (PrettyPrint): no
Strategy: Mobile
Categories:
Performance
Progressive Web App (PWA)
Best practices
Accessibility
SEO
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=mobile&category=performance&category=pwa&category=best-practices&category=accessibility&category=seo
And the JSON-Response looks like this:
{
"lighthouseResult": {
"categories": {
"performance": {
"score":0.87
},
"accessibility": {
"score":0.7
},
"best-practices": {
"score":0.77
},
"seo": {
"score":0.9
},
"pwa": {
"score":0.56
}
}
}
}