{"id":13394854,"url":"https://github.com/GoogleChromeLabs/psi","last_synced_at":"2025-03-13T20:31:44.130Z","repository":{"id":17426465,"uuid":"20199636","full_name":"GoogleChromeLabs/psi","owner":"GoogleChromeLabs","description":"PageSpeed Insights Reporting for Node","archived":false,"fork":false,"pushed_at":"2021-04-10T00:13:45.000Z","size":508,"stargazers_count":3111,"open_issues_count":15,"forks_count":126,"subscribers_count":53,"default_branch":"master","last_synced_at":"2025-02-24T10:12:45.632Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleChromeLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-26T22:05:17.000Z","updated_at":"2025-02-24T09:31:00.000Z","dependencies_parsed_at":"2022-09-23T18:22:06.067Z","dependency_job_id":null,"html_url":"https://github.com/GoogleChromeLabs/psi","commit_stats":null,"previous_names":["addyosmani/psi"],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fpsi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fpsi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fpsi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fpsi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleChromeLabs","download_url":"https://codeload.github.com/GoogleChromeLabs/psi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240457978,"owners_count":19804489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T17:01:34.065Z","updated_at":"2025-03-13T20:31:44.089Z","avatar_url":"https://github.com/GoogleChromeLabs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Tools","Analyzers - API"],"sub_categories":["Meetups"],"readme":"# psi [![Build Status](https://travis-ci.org/GoogleChromeLabs/psi.svg?branch=master)](https://travis-ci.org/GoogleChromeLabs/psi) [![NPM psi package](https://img.shields.io/npm/v/psi.svg)](https://npmjs.org/package/psi)\n\n\u003e PageSpeed Insights with reporting\n\n![](screenshot.png)\n\nRun mobile and desktop performance tests for your deployed site using [Google PageSpeed Insights v5](https://developers.google.com/speed/docs/insights/v5/about) with tidy reporting for your build process.\n\n\n## Install\n\n```\n$ npm install psi\n```\n\n\n## Usage\n\n\u003c!-- TODO Update this section with v5+ information --\u003e\n\n```js\nconst psi = require('psi');\n\n(async () =\u003e {\n  // Get the PageSpeed Insights report\n  const { data } = await psi('https://theverge.com');\n  console.log('Speed score:', data.lighthouseResult.categories.performance.score);\n\n  // Output a formatted report to the terminal\n  await psi.output('https://theverge.com');\n  console.log('Done');\n\n  // Supply options to PSI and get back speed\n  const data2 = await psi('https://theverge.com', {\n    nokey: 'true',\n    strategy: 'desktop'\n  });\n  console.log('Speed score:', data2.data.lighthouseResult.categories.performance.score);\n})();\n```\n\nAs of PSI 2.x, we expose both the PageSpeed Insights speed and usability scores. The latter is based on [usability rules](https://developers.google.com/speed/docs/insights/rules) that score a page based on factors like the presence of a sensible mobile [viewport](https://developers.google.com/speed/docs/insights/ConfigureViewport).\n\n## API\n\n### psi(url, [options])\n\nReturns a promise for the response data from Google PageSpeed Insights.\n\n#### url\n\nType: `string`\n\nURL of the page for which the PageSpeed Insights API should generate results.\n\n#### options\n\nType: `Object`\n\n##### key\n\nType: `string`\u003cbr\u003e\nDefault: Free tier\n\nWhen using this module for a production-level build process, registering for an API key from the [Google Developer Console](https://developers.google.com/speed/docs/insights/v1/getting_started#auth) is recommended.\n\n##### strategy\n\nType: `string`\u003cbr\u003e\nDefault: `mobile`\u003cbr\u003e\nValues: `mobile` `desktop`\n\nStrategy to use when analyzing the page.\n\n##### locale\n\nType: `string`\u003cbr\u003e\nDefault: `en_US`\n\nLocale results should be generated in.\n\n##### threshold\n\nType: `number`\u003cbr\u003e\nDefault: `70`\n\nThreshold score to pass the PageSpeed test. Useful for setting a performance budget.\n\n##### links\n\nType: `boolean`\u003cbr\u003e\nDefault: `false`\n\nIf passed adds links with more info about opportunities. Useful for checking documentation about opportunities.\n\n### psi.output(url, [options])\n\nOutput the formatted report to the terminal.\n\nReturns a promise for the response data from Google PageSpeed Insights.\n\n`url` and `options` are the same as `psi()`.\n\n\n## CLI\n\n```\n$ npm install --global psi\n```\n\n```\n$ psi --help\n\n  Usage\n    $ psi \u003curl\u003e\n\n  Options\n    --key        Google API Key. By default the free tier is used\n    --strategy   Strategy to use when analyzing the page: mobile|desktop\n    --format     Output format: cli|json|tap\n    --locale     Locale results should be generated in\n    --threshold  Threshold score to pass the PageSpeed test\n\n  Example\n    $ psi https://addyosmani.com --strategy=mobile\n```\n\n## Common Use cases\n\n\u003cdetails\u003e\n \u003csummary\u003eGetting PSI into your build process.\u003c/summary\u003e\u003cbr\u003e\n\nA sample [Gulp](https://github.com/addyosmani/psi-gulp-sample) project using PSI is available.\n\nIf you use Grunt, [`grunt-pagespeed`](https://github.com/jrcryer/grunt-pagespeed) is a task by James Cryer that uses PSI under the hood.\n\nFor testing local projects, we recommend using [`psi-ngrok`](https://github.com/denar90/psi-ngrok) or [`ngrok`](http://www.jamescryer.com/2014/06/12/grunt-pagespeed-and-ngrok-locally-testing/).\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGetting filmstrips\u003c/summary\u003e\n\n**Filmstrips** are returned by the v5 API as data uri's but the psi tool does not expose them on the cli. If you want to get **filmstrips** (or any audit details) you can require `psi` and get them from the `audits` object:\n\n```javascript\nconst psi = require('psi');\n\n(async () =\u003e {\n  // Get the PageSpeed Insights report\n  const {data} = await psi('https://theverge.com');\n  console.log(data.lighthouseResult.audits['screenshot-thumbnails'].details.items);\n})();\n```\n\n\u003c/details\u003e\n\n## License\n\nApache-2.0 - Copyright 2015 Google Inc\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoogleChromeLabs%2Fpsi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGoogleChromeLabs%2Fpsi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGoogleChromeLabs%2Fpsi/lists"}