Forum Discussion

DerekStratton's avatar
DerekStratton
Qrew Member
10 years ago

How can I use Google's PageSpeed Insights API with my App?

Using Google's PageSpeed Insights API, I would like to create a button, that when pressed, fills out the following fields:

[Speed]

[User Experience]

[Should Fix]

Based on the URL in the field [Website] on the record.

How can I accomplish this?

  • I tried this code:

    var url= "https://www.googleapis.com/pagespeedonline/v1/runPagespeed";
    $.ajax(url, {
      dataType: 'jsonp',
      data: {
        url: "https://quickbase.com",
        key: "AIzaSyD23MrZsN9vxr1GtZ1qQ40AtYfSIQ5qy3s"
      }
    }).then(function(response) {
      console.dir(response);
    });

    But I get an error:
    "Access Not Configured. The API (PageSpeed Insights API) is not enabled for your project. Please use the Google Developers Console to update your configuration."
    I think the problem is that I can't prove I own the domain haversineconsulting.quickbase.com to Google (because I don't own the domain). I think you are going to have to run this through a proxy for which you can verifyyou own the domain through Google and then pump the results to QuickBase. 
  • But then I removed my key and got this response

    https://paste.ee/p/yiLin


    So maybe you can call the service without a key if you operate under some threshold.

    If you want to pursue this contact me offline. It might be very easy to do.
  • Google PageSpeed Insights
    https://haversineconsulting.quickbase.com/db/bkjw64g5e?a=nwr

    Pastie Database
    https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=472

    Notes

    (1) I am not using an authentication key when making the service call to Google but it appears to work. I don't know what limitations Google places on using their service this way but I am sure at some level of activity you will need to use a key and have to confirm ownership of the domain (which you can't do from QuickBase so you would have to use your own proxy).

    (2) In the example you have to enter a URL with http(s) included and blur the record. After the response populates you can save the record.

    (3) I am storing the raw JSON response in the field [Response]. However the response is  very large and I would assume you want to do some extraction or parsing of the results. This could be an extensive amount of work depending on how much information you want to extract.

    (4) Feature only implemented on add new record page.