1

I am using PageSpeed Insights API to grab speed metrics of different websites and integrate the data in a tool I'm creating.

If I try a query using the API test tool (https://developers.google.com/speed/docs/insights/v4/reference/pagespeedapi/runpagespeed), then everything is fine and I get the info I need.

However, when I perform the very same query (as far as I can see) from my server, the response json does not include the same information. Some information is just missing.

Basically, other than the 'initial_url', all the metrics information that should be included in the 'loadingExperience' branch is missing. No info on 'FIRST_CONTENTFUL_PAINT_MS' or 'DOM_CONTENT_LOADED_EVENT_FIRED_MS'.

On the other hand, I can't seem to find the way to request info on USABILITY and SECURITY under the 'ruleGroups' branch. According to the API reference, this branch should feature information on these aspects too, but nothing like that is return after the query. Just the SPEED branch info is returned.

This is the URL I use to query the API:

https://www.googleapis.com/pagespeedonline/v4/runPagespeed?url=https://stackoverflow.com&strategy=mobile&screenshot=true&locale=en&key=XXXXXXXXmyAPIKeyXXXXXXXX';

Am I missing anything? I have checked the API documentation and Google'd for more info on this, but I can't seem to find any parameter to force request this information.

(By the way, this is my first question at StackOverFlow, so I hope I have shared all the necessary information. And apologies if my english is bad. I do my best.)

David Lee
  • 21
  • 4

1 Answers1

0

I'm having the same issue with some websites. The problem is related to the website. Some websites are providing the userExperience.metrics object and some are not. I have no idea what is causing this.

However you can try to use strategy=desktop parameter to get the userExperience.metrics object in version 5. This worked for me.

Working URL: https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://stackoverflow.com&strategy=desktop&key=[SetYourApiKeyHere]

  • I'm having the same issue, i added the strategy but also doesn't work. no metrics on loadingExperience Object [1]: https://i.stack.imgur.com/kk2aK.png did you find a solution? – Chawki Feb 05 '21 at 22:17