Giter Site home page Giter Site logo

Comments (6)

DanielRuf avatar DanielRuf commented on June 18, 2024

Well, this should be filed as issue at https://github.com/google/google-api-nodejs-client

https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=https://github.com
https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=https://github.com&strategy=mobile

from psi.

JustinBeckwith avatar JustinBeckwith commented on June 18, 2024

๐Ÿ‘‹ greetings folks! This one is weird. At the end of the day, the nodejs api client is really just calling the underlying apiary APIs. From the API explorer, it seems like I only ever get back a speed score. I am using this to test the underlying API:

https://developers.google.com/speed/docs/insights/v4/reference/pagespeedapi/runpagespeed

I'm setting the following parameters:

When I run this query, I get results like this:
https://gist.github.com/JustinBeckwith/06bc533e786570e35892a6fd7e4f2ea9

This has only a single ruleGroup returned, and it's "SPEED". Am I properly understanding how y'all are trying to use the API?

from psi.

DanielRuf avatar DanielRuf commented on June 18, 2024

It uses the old API. There is a newer one (4).

from psi.

JustinBeckwith avatar JustinBeckwith commented on June 18, 2024

Ah, just so I remember what this means later - the ref docs are using v4 of the API, and PSI is using v2 of the API.

from psi.

DanielRuf avatar DanielRuf commented on June 18, 2024

See #78

from psi.

JustinBeckwith avatar JustinBeckwith commented on June 18, 2024

scratches head still having issues with this one. I put together a test that uses googleapis to get the score, and directly hitting the API using axios. Here's the code:

const {google} = require('googleapis');
const axios = require('axios');

async function runPSO() {
  console.log('Running googleapis test....')
  const psi = google.pagespeedonline('v2');
  const res = await psi.pagespeedapi.runpagespeed({
    url: 'https://github.com',
    strategy: 'desktop'
  });
  console.log(res.data);
}

async function runRaw() {
  console.log('Running REST test...');
  const res = await axios.get(
    'https://www.googleapis.com/pagespeedonline/v2/runPagespeed',
    {
      params: {
        url: 'https://github.com',
        strategy: 'desktop'
      }
    }
  );
  console.log(res.data);
}

async function main() {
  await runPSO();
  await runRaw();
}

main().catch(console.error);

The results are:

Running googleapis test....
{ captchaResult: 'CAPTCHA_NOT_NEEDED',
  kind: 'pagespeedonline#result',
  id: 'https://github.com/',
  responseCode: 200,
  title: 'The world\'s leading software development platform ยท GitHub',
  ruleGroups: { SPEED: { score: 45 } },
  pageStats: 
   { numberResources: 48,
     numberHosts: 7,
     totalRequestBytes: '5910',
     numberStaticResources: 42,
     htmlResponseBytes: '55802',
     cssResponseBytes: '563445',
     imageResponseBytes: '1700091',
     javascriptResponseBytes: '754073',
     otherResponseBytes: '2010',
     numberJsResources: 4,
     numberCssResources: 3 },
  formattedResults: 
   { locale: 'en_US',
     ruleResults: 
      { AvoidLandingPageRedirects: [Object],
        EnableGzipCompression: [Object],
        LeverageBrowserCaching: [Object],
        MainResourceServerResponseTime: [Object],
        MinifyCss: [Object],
        MinifyHTML: [Object],
        MinifyJavaScript: [Object],
        MinimizeRenderBlockingResources: [Object],
        OptimizeImages: [Object],
        PrioritizeVisibleContent: [Object] } },
  version: { major: 1, minor: 15 } }
Running REST test...
{ captchaResult: 'CAPTCHA_NOT_NEEDED',
  kind: 'pagespeedonline#result',
  id: 'https://github.com/',
  responseCode: 200,
  title: 'The world\'s leading software development platform ยท GitHub',
  ruleGroups: { SPEED: { score: 45 } },
  pageStats: 
   { numberResources: 48,
     numberHosts: 7,
     totalRequestBytes: '5910',
     numberStaticResources: 42,
     htmlResponseBytes: '55802',
     cssResponseBytes: '563444',
     imageResponseBytes: '1700080',
     javascriptResponseBytes: '754069',
     otherResponseBytes: '2010',
     numberJsResources: 4,
     numberCssResources: 3 },
  formattedResults: 
   { locale: 'en_US',
     ruleResults: 
      { AvoidLandingPageRedirects: [Object],
        EnableGzipCompression: [Object],
        LeverageBrowserCaching: [Object],
        MainResourceServerResponseTime: [Object],
        MinifyCss: [Object],
        MinifyHTML: [Object],
        MinifyJavaScript: [Object],
        MinimizeRenderBlockingResources: [Object],
        OptimizeImages: [Object],
        PrioritizeVisibleContent: [Object] } },
  version: { major: 1, minor: 15 } }

As far as I can tell - we are returning the exact same data using the npm module as you would get talking to the API directly. It's entirely possible the backend service implementation changed :/ I'm going to close out the issue in the other repository. If you can reproduce an issue where the API behaves differently than the results returned from the npm module... let me know!

from psi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.