Comments (6)
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.
๐ 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:
- url: https://github.com
- strategy: mobile
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.
It uses the old API. There is a newer one (4).
from psi.
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.
See #78
from psi.
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)
- Build is failing HOT 4
- Remove not needed dependencies
- Issues with default outputting of specific sites HOT 5
- TypeError: Cannot read property 'metrics' of undefined page speed HOT 9
- Desktop strategy not working - Quota exceeded HOT 1
- Security Issue HOT 1
- PSI version scores differs from built-in chrome Lighthouse tool HOT 2
- Add option to export to file
- Add option to do PSI test with a device that matches origin's field data HOT 1
- Largest Contentful Paint image was not lazily loaded - Typo? HOT 1
- PSI now returns cached versions when running subsequent requests. HOT 5
- CUMULATIVE_LAYOUT_SHIFT_SCORE has ms unit in output. HOT 1
- Error in Efficiently encode images and Serve images in next-gen formats
- wp rocket and product recommendations HOT 1
- PSI scores vary significantly between runs
- Outdated download dependency has a security vulnerability HOT 1
- Is this project abandoned? HOT 7
- at processTicksAndRejections (internal/process/next_tick.js:76:17) HOT 1
- Update pagespeed insight to v5 HOT 12
- npm still installs V2 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psi.