Reputation: 25
I've just started testing the Google Pagespeed API and can't find a clear answer as to how to do batch requests. I have a variable in Javascript containing urls that I'd like to test page speed for. I was wondering how I'd go about making a batch request using it? This is the code I have so far for making requests
fetch(' https://www.googleapis.com/pagespeedonline/v5/runPagespeed?url=https://www.zizzi.co.uk/&key=MYKEY')
.then(res => {
return res.json();
console.log(res.json)
'MYKEY' is replaced with my actual API in the code I am running.
Upvotes: 2
Views: 958
Reputation: 24855
you can't send batch requests to the API.
You also have a limit on how many requests you can make per minute and per day (I think it is quite high, around 25,000 / day).
Instead make multiple requests to the API alongside each other.
You may also consider installing Lighthouse, the engine that powers Page Speed Insights on your own server so you can easily save the JSON to files (as a browser will start to struggle with so many large responses).
Upvotes: 2