Skip to main content

CLI + API for Google PageSpeed Insights

Project description


CLI 🖥 + API for Google PageSpeed Insights

PythonPSI PyPI - Downloads


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


pip install PythonPSI


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


$ psi --category seo --stratergy desktop --locale en

    "captchaResult": "CAPTCHA_NOT_NEEDED",
    "kind": "pagespeedonline#result",
    "id": "",
    "loadingExperience": {
    "originLoadingExperience": {
    "lighthouseResult": {
    "analysisUTCTimestamp": {


$ psi --help

    Usage: psi [OPTIONS] URL

    --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

    --locale TEXT         The locale used to localize formatted results
    --stratergy TEXT      The analysis strategy (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

    --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('', 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

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for PythonPSI, version 1.9.0
Filename, size File type Python version Upload date Hashes
Filename, size PythonPSI-1.9.0-py3-none-any.whl (6.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size PythonPSI-1.9.0.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page