Skip to main content

PyPSI

CLI 🖥 + API for Google PageSpeed Insights

PythonPSI PyPI - Downloads

PyPSI

PageSpeed Insights (PSI) reports on the performance of a page on both mobile and desktop devices, and provides suggestions on how that page may be improved.

PSI provides both lab and field data about a page. Lab data is useful for debugging performance issues, as it is collected in a controlled environment. However, it may not capture real-world bottlenecks. Field data is useful for capturing true, real-world user experience - but has a more limited set of metrics.

PyPSI uses PageSpeed Insights API v5

Installation

pip install PythonPSI

Usage

Google seems to have made it mandatory to use an API key, otherwise you may reach service quota limits too soon. Get one from here.

psi <SITE_URL> <OPTION1> <OPTION2> ...

Example:

$ psi developers.google.com --category seo --stratergy desktop --locale en

    {
    "captchaResult": "CAPTCHA_NOT_NEEDED",
    "kind": "pagespeedonline#result",
    "id": "https://developers.google.com/",
    "loadingExperience": {
        ...
    },
    "originLoadingExperience": {
        ...
    },
    "lighthouseResult": {
        ...
    },
    "analysisUTCTimestamp": {
        ...
    }

CLI

$ psi --help

    Usage: psi [OPTIONS] URL

    Options:
    --api_key TEXT        Required to use the API in an automated way and make
                            multiple requests per second

    --category TEXT       A Lighthouse category to run; if none are given, only
                            Performance category will be run

    --metrics TEXT        Returns metrics of a particular field in response
                            object

    --locale TEXT         The locale used to localize formatted results
    --stratergy TEXT      The analysis stratergy (desktop or mobile) to use, and
                            desktop is the default

    --threshold TEXT      Threshold score to pass the PageSpeed test. Useful for
                            setting a performance budget.

    --links TEXT          If passed adds links with more info about
                            opportunities. Useful for checking documentation about
                            opportunities.

    --utm_campaign TEXT   Campaign name for analytics.
    --utm_source TEXT     Campaign source for analytics.
    --captcha_token TEXT  The captcha token passed when filling out a captcha.
    --help                Show this message and exit.

API Usage

from PythonPSI.api import PSI

PSI('google.com', category='seo', locale='en', stratergy='desktop')
# Returns JSON output
  • PSI - Required arguments: 1, Optional arguments: 9

    • URL:
      • Required
      • Default: None
    • api_key:
      • Optional
      • Default: None
    • category:
      • Optional
      • Default: performance
      • Options: accessibility, best_practices, performance, pwa, seo
    • metrics:
      • Optional
      • Default: None
      • Options: kind, captchaResult, id, loadingExperience, originLoadingExperience, analysisUTCTimestamp, lighthouseResult, version
    • locale:
      • Optional
      • Default: en
    • stratergy:
      • Optional
      • Default: desktop
      • Options: desktop, mobile
    • threshold:
      • Optional
      • Default: None
      • Options: INT 0-100
    • links:
      • Optional
      • Default: false
      • Options: true, false
    • utm_campaign:
      • optional
      • Default: None
    • utm_source:
      • Optional
      • Default: None
    • captcha_token:
      • Optional
      • Default: None

Metadata

Release files for PythonPSI 1.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PythonPSI 1.9.2
File Size Uploaded
PythonPSI-1.9.2.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PythonPSI 1.9.2
File Interpreter ABI Platform
PythonPSI-1.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / PythonPSI-1.9.2.tar.gz

Download URL PythonPSI-1.9.2.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
65ae64348687a383f60256ecc9646310bc72d7d11bf0cfe7d481491bbee0fe83
BLAKE2b-256 checksum
How to use checksums
c9379e8fa7ed0bdf0095f4878e0d1a4a006433e85858ae83401a787c6b428706
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.10.4

Release files / PythonPSI-1.9.2-py3-none-any.whl

Download URL PythonPSI-1.9.2-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ca45205961ed4ba694ea2a4acd31547aac98884f90a9cbb551399acde4315c1
BLAKE2b-256 checksum
How to use checksums
9de1e49e4fdab544f02b59cc881c01a28856b6cbc69fcfa4ebc8403b9adb4875
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/58.1.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

1.9.2 This release

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page