Jim
Jim

Reputation: 2322

Why is pagespeed insights api returning 404?

I have a request that looks something like this:

async function test() {
    cron.schedule('*/1 * * * *', () => {
      // Test API calls, log response
      axios.get('https://www.googleapis.com/pagespeedonline/v4/runPagespeed', {
        params: {
          url: 'https://www.google.com',
          strategy: 'mobile', // mobile || desktop
        }
      })
      .then( response => {
        console.log(JSON.stringify(response.loadingExperience))
      })
      .catch(err => console.log(err))
    })
  }

However, in my backend and in postman, im getting 404's. Not really sure where to go from here.

Any suggestions?

Upvotes: 0

Views: 654

Answers (1)

Jim
Jim

Reputation: 2322

The pagespeed insight API documentation was incorrect. at the time i copied it, it said v4 in the url. Played around with the version until eventually trying v5. that worked.

the url to send request to is:

https://www.googleapis.com/pagespeedonline/v5/runPagespeed

Upvotes: 1

Related Questions