beleaf / gpsapi
A library for interacting with the GPSAPI
Requires (Dev)
This package is auto-updated.
Last update: 2025-01-14 09:07:21 UTC
README
A library for interacting with the Google PageSpeed Insights API.
Installation
To begin, you'll need to add the library to your composer.json
composer require beleaf/gpsapi
After adding the library, update your packages using composer update
or install them using composer install
.
Usage
Run a test with only the default performance category
require_once './vendor/autoload.php';
$gpsapi = \Beleaf\GPSAPI\Page::test('https://beleaf.au');
$gpsapi->save('output/', true);
Run a test with additional parameters
require_once './vendor/autoload.php';
$gpsapi = \Beleaf\GPSAPI\Page::test('https://beleaf.au', [
'category' => ['performance', 'seo'],
'strategy' => 'mobile',
'key' => 'xxx',
]);
$gpsapi->save('output/', true);
To see what parameters are supported, visit https://developers.google.com/speed/docs/insights/rest/v5/pagespeedapi/runpagespeed#query-parameters.
Run a test including all categories
require_once './vendor/autoload.php';
$gpsapi = \Beleaf\GPSAPI\Page::test('https://beleaf.au', [
'category' => 'all',
]);
$gpsapi->save('output/', true);
API Keys
If you're just trying out the PageSpeed Insights API, you don't need an API key. If you plan on using the API in an automated way and making multiple queries per second, you'll need an API key.
https://developers.google.com/speed/docs/insights/v5/get-started#key
Information about Google PageSpeed Insights API
License
This library is licensed under the MIT License - see the LICENSE file for details.