The Google PageSpeed Insights API is a valuable tool for web developers looking to optimize performance. You can access the Google PageSpeed Insights API from this web page but if you want to take it a step further, you can install the PageSpeed Insights Node module and have this tool readily available at all times right from your terminal.
First if you don’t already have Node.js or NPM installed on your system be sure to complete those installations before proceeding with these instructions. For Mac users, you just need to have XCode and Homebrew then you can brew install node and both Node and NPM will be installed on your system. Linux users can use their native package manager (yum, apt-get, pacman) and Windows users can download the installer here or use the Windows package manager Chocolatey.
Now that you have both Node and NPM installed on your system we can proceed with setting up the PageSpeed Insights Node module that will provide you the ability to quickly run pagespeed reports from your Terminal. To install the PageSpeed Insights Node module enter the following command and press enter:
npm install—global psi
Once the installation is complete, you can type: psi https://google.com to perform a PageSpeed insights report on google.com.