Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
smnandre committed May 28, 2024
1 parent a7c5dd4 commit 39139dd
Showing 1 changed file with 36 additions and 17 deletions.
53 changes: 36 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# 🚀 PageSpeed PHP API Client


<a href="https://github.com/smnandre/pagespeed-api/actions"><img alt="javscript-action status" src="https://github.com/smnandre/pagespeed-api/actions/workflows/CI.yaml/badge.svg"></a>
<a href="https://img.shields.io/github/v/release/smnandre/pagespeed-api"><img alt="release" src="https://img.shields.io/github/v/release/smnandre/pagespeed-api"></a>
<a href="https://img.shields.io/github/license/smnandre/pagespeed-api"><img alt="license" src="https://img.shields.io/github/license/smnandre/pagespeed-api?color=cc67ff"></a>
<a href="https://github.com/smnandre/pagespeed-api/actions"><img alt="javscript-action status" src="https://github.com/smnandre/pagespeed-api/actions/workflows/CI.yaml/badge.svg"></a>
<a href="https://img.shields.io/github/v/release/smnandre/pagespeed-api"><img alt="release" src="https://img.shields.io/github/v/release/smnandre/pagespeed-api"></a>
<a href="https://img.shields.io/github/license/smnandre/pagespeed-api"><img alt="license" src="https://img.shields.io/github/license/smnandre/pagespeed-api?color=cc67ff"></a>
<a href="https://codecov.io/gh/smnandre/pagespeed-api" ><img src="https://codecov.io/gh/smnandre/pagespeed-api/graph/badge.svg?token=RC8Z6F4SPC"/></a>

This PHP library offers an effortless way to leverage Google's PageSpeed Insights 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

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

Expand All @@ -23,25 +23,45 @@ composer require smnandre/pagespeed-api
```php
use PageSpeed\Api\PageSpeedApi;

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

$analysis = $api->analyse('https://www.example.com');
// or with API key (optional)
$analysis = (new PageSpeedApi('YOUR_API_KEY'))->analyse('https://www.example.com');
```

### Get the results
### Audit Scores

```php
use PageSpeed\Api\PageSpeedApi

// LightHouse scores
$analysis->getAuditScores();
// 'performance' => 100,
// 'accessibility' => 88,
// 'best-practices' => 100,
// 'seo' => 90
$analysis = (new PageSpeedApi())->analyse('https://www.example.com');

$analysis->getLoadingMetrics();
$scores = $analysis->getAuditScores();
// array (
// 'performance' => 100,
// 'accessibility' => 88,
// 'best-practices' => 100,
// 'seo' => 90,
// )
```

### Loading Metrics

```php
use PageSpeed\Api\PageSpeedApi

$analysis->getOriginalLoadingMetrics();
$analysis = (new 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',
// )
```

### Parameters
Expand All @@ -62,7 +82,6 @@ $analysis = $api->analyse('https://example.com/', 'desktop');
$analysis = $api->analyse('https://example.com/', 'mobile', 'fr');
```


## Analysis

### Audit categories
Expand Down

0 comments on commit 39139dd

Please sign in to comment.