PHPackages                             smnandre/pagespeed-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. smnandre/pagespeed-api

ActiveLibrary[API Development](/categories/api)

smnandre/pagespeed-api
======================

PageSpeed Insight PHP Api Client 🚀 Analyse web pages for performances metrics, core web vitals...

v1.1.0(1mo ago)1617.1k↓15.1%2MITPHPPHP &gt;=8.3CI passing

Since May 15Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/smnandre/pagespeed-api)[ Packagist](https://packagist.org/packages/smnandre/pagespeed-api)[ GitHub Sponsors](https://github.com/smnandre)[ RSS](/packages/smnandre-pagespeed-api/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (8)Dependencies (14)Versions (10)Used By (0)

🚀 PageSpeed PHP API Client
==========================

[](#-pagespeed-php-api-client)

[![PHP Version](https://camo.githubusercontent.com/b70c5d640e4c5368ff55b55a6cd756d72a500a6e32ab31c74ceea9931026b857/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2543322541307068702d253345253344253230382e332d3737374242342e7376673f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://github.com/smnandre/pagespeed-api/blob/main/composer.json)[![CI](https://github.com/smnandre/pagespeed-api/actions/workflows/CI.yaml/badge.svg)](https://github.com/smnandre/pagespeed-api/actions)[![Release](https://camo.githubusercontent.com/f8d68d4fa81f84b01c391d99b6f1b341730ff2bc9e7b8372945d492e51cd6bf3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f736d6e616e6472652f7061676573706565642d617069)](https://github.com/smnandre/pagespeed-api/releases)[![License](https://camo.githubusercontent.com/dda602601e14e76735ad79e7126d7aa3b64dd9a4a4393f9eed8479765f3bbe1e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736d6e616e6472652f7061676573706565642d6170693f636f6c6f723d636336376666)](https://github.com/smnandre/pagespeed-api/blob/main/LICENSE)[![Codecov](https://camo.githubusercontent.com/ae0dc113ad23f3db6e06ecdd42705559437dbaa7d3f03831fdddea22e287b2c5/68747470733a2f2f636f6465636f762e696f2f67682f736d6e616e6472652f7061676573706565642d6170692f67726170682f62616467652e7376673f746f6b656e3d5243385a364634535043)](https://codecov.io/gh/smnandre/pagespeed-api)

This PHP library offers an effortless way to leverage Google's [PageSpeed Insights](https://pagespeed.web.dev/) API.

Analyze your web pages for performance metrics, get detailed reports, and optimize your site with ease. 🚀

Installation
------------

[](#installation)

```
composer require smnandre/pagespeed-api
```

Usage
-----

[](#usage)

### Initialize the API

[](#initialize-the-api)

```
use PageSpeed\Api\PageSpeedApi;

$pageSpeedApi = new PageSpeedApi();

// or with API key (optional)
$pageSpeedApi = new PageSpeedApi('YOUR_API_KEY');
```

### Run analysis

[](#run-analysis)

```
// Analyze a page
$analysis = $pageSpeedApi->analyse('https://example.com/');

// ...with a specific strategy (mobile or desktop)
$analysis = $pageSpeedApi->analyse('https://example.com/', 'mobile');

// ...with a specific locale (e.g., fr_FR)
$analysis = $pageSpeedApi->analyse('https://example.com/', locale: 'fr_FR');

// ...with a specific category (performance, accessibility, best-practices, seo)
$analysis = $pageSpeedApi->analyse('https://example.com/', categories: 'performance');
```

#### Parameters

[](#parameters)

ParameterDescriptionDefault`url`The URL of the page to analyze.-`strategy`The analysis strategy to use. Possible values are `mobile` or `desktop`.`mobile``locale`The locale to use for the analysis.`en``categories`The categories to analyze. If not specified, all categories will be analyzed.-Report
------

[](#report)

A display-ready view of an analysis: category scores and Core Web Vitals reached by property, serialisable to array or JSON.

```
use PageSpeed\Api\PageSpeedApi;

$pageSpeedApi = new PageSpeedApi();
$report = $pageSpeedApi->analyse('https://www.example.com')->report();

// Scores (null when the category was not analysed)
$report->performance->value;          // 88
$report->performance->rating;         // Rating::NeedsImprovement
$report->performance->rating->value;  // 'needs-improvement'
$report->seo->value;                  // 90

// Core Web Vitals (null when field data is unavailable)
$report->lcp->value;   // 2300
$report->lcp->unit;    // 'ms'
$report->lcp->rating;  // Bucket::Fast

// Serialise for a template, a CLI or an API
$report->toArray();
json_encode($report);
```

Scores (`performance`, `accessibility`, `bestPractices`, `seo`) expose `value` (0-100), `rating` (a `Rating` following the [Score Evaluation](#score-evaluation) thresholds), and `category` (`Category`). Metrics (`lcp`, `cls`, `inp`, `fcp`, `fid`, `ttfb`) expose `value`, `unit`, and `rating` (a `Bucket`: `Fast`, `Average` or `Slow`). Any property is `null` when the underlying data is absent.

Audit Scores
------------

[](#audit-scores)

[![audit-scores.png](docs/audit-scores.png)](docs/audit-scores.png)

```
use PageSpeed\Api\PageSpeedApi;

$pageSpeedApi = new PageSpeedApi();
$analysis = $pageSpeedApi->analyse('https://www.example.com');

$scores = $analysis->getAuditScores();

// array (
//   'performance' => 100,
//   'accessibility' => 88,
//   'best-practices' => 100,
//   'seo' => 90,
// )
```

### Audit categories

[](#audit-categories)

\#CategoryDescription⚡**Performance**Measures how quickly the content on your page loads and becomes interactive.🌍**Accessibility**Evaluates how accessible your page is to users, including those with disabilities.🏆**Best Practices**Assesses your page against established web development best practices.⚓**SEO**Analyzes your page's search engine optimization, ensuring it follows SEO guidelines.### Score Evaluation

[](#score-evaluation)

MinMax⬜️Description049🟥🟥🟥🟥🟥⬜️⬜️⬜️⬜️⬜️Poor5089🟧🟧🟧🟧🟧🟧🟧🟧🟧️⬜️️Needs improvement90100🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩GoodCore Web Vitals
---------------

[](#core-web-vitals)

[![core-web-vitals.png](docs/core-web-vitals.png)](docs/core-web-vitals.png)

### Loading Metrics

[](#loading-metrics)

```
use PageSpeed\Api\PageSpeedApi;

$pageSpeedApi = new PageSpeedApi();
$analysis = $pageSpeedApi->analyse('https://www.example.com');

$metrics = $analysis->getLoadingMetrics();

// array (
//   'CUMULATIVE_LAYOUT_SHIFT_SCORE' => 'FAST',
//   'EXPERIMENTAL_TIME_TO_FIRST_BYTE' => 'AVERAGE',
//   'FIRST_CONTENTFUL_PAINT_MS' => 'FAST',
//   'FIRST_INPUT_DELAY_MS' => 'FAST',
//   'INTERACTION_TO_NEXT_PAINT' => 'FAST',
//   'LARGEST_CONTENTFUL_PAINT_MS' => 'FAST',
// )
```

### Main Metrics

[](#main-metrics)

AbbrMetricDescription**FCP****First Contentful Paint**Time taken for the first piece of content to appear on the screen.**SI****Speed Index**How quickly the contents of a page are visibly populated.**FID****First Input Delay**Time from a user's first interaction to when the browser can respond.**CLS****Cumulative Layout Shift**Measure of visual stability; the sum of all individual layout shift scores.**LCP****Largest Contentful Paint**Time taken for the largest content element to appear.**INP****Interaction to Next Paint**Time from a user interaction to the next visual update in response.Contributing
------------

[](#contributing)

Contributions are welcome! If you would like to contribute, please fork the repository and submit a pull request.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance93

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 97.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~112 days

Recently: every ~193 days

Total

8

Last Release

36d ago

Major Versions

v0.9.4 → v1.0.02026-03-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/a8951d49b371d210280a58ce48969a07d1f49924810f8a1fab3a9343eb46fdc9?d=identicon)[simonandre](/maintainers/simonandre)

---

Top Contributors

[![smnandre](https://avatars.githubusercontent.com/u/1359581?v=4)](https://github.com/smnandre "smnandre (38 commits)")[![mwansinck](https://avatars.githubusercontent.com/u/11411864?v=4)](https://github.com/mwansinck "mwansinck (1 commits)")

---

Tags

apiapi-clientcore-web-vitalsgooglegoogle-pagespeed-insightsinsightspage-speedpage-speed-insightsperformancephpseospeedapiclientgoogleperformanceInsightsseoPageSpeedlightousepage-speed-insightscore-web-vitals

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/smnandre-pagespeed-api/health.svg)

```
[![Health](https://phpackages.com/badges/smnandre-pagespeed-api/health.svg)](https://phpackages.com/packages/smnandre-pagespeed-api)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k6.0M777](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M236](/packages/sulu-sulu)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47394.5k5](/packages/deepseek-php-deepseek-php-client)[sgrodzicki/pagespeed

A PHP library to interact with the PageSpeed Insights API

47137.0k](/packages/sgrodzicki-pagespeed)[storyblok/php-content-api-client

PHP Client for Storyblok Content API

11189.5k15](/packages/storyblok-php-content-api-client)[skeeks/yii2-google-api

Component for work with google api based on google/apiclient

1244.0k1](/packages/skeeks-yii2-google-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
