PageSpeed Insights API . pagespeedapi

Instance Methods

runpagespeed(url, category=None, utm_campaign=None, locale=None, utm_source=None, strategy=None)

Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.

Method Details

runpagespeed(url, category=None, utm_campaign=None, locale=None, utm_source=None, strategy=None)
Runs PageSpeed analysis on the page at the specified URL, and returns PageSpeed scores, a list of suggestions to make that page faster, and other information.

Args:
  url: string, The URL to fetch and analyze (required)
  category: string, A Lighthouse category to run; if none are given, only Performance category will be run (repeated)
    Allowed values
      accessibility - 
      best-practices - 
      performance - 
      pwa - 
      seo - 
  utm_campaign: string, Campaign name for analytics.
  locale: string, The locale used to localize formatted results
  utm_source: string, Campaign source for analytics.
  strategy: string, The analysis strategy (desktop or mobile) to use, and desktop is the default
    Allowed values
      desktop - Fetch and analyze the URL for desktop browsers
      mobile - Fetch and analyze the URL for mobile devices

Returns:
  An object of the form:

    {
    "kind": "pagespeedonline#result", # Kind of result.
    "captchaResult": "A String", # The captcha verify result
    "originLoadingExperience": { # Metrics of the aggregated page loading experience of the origin
      "metrics": {
        "a_key": { # The type of the metric.
          "category": "A String",
          "percentile": 42,
          "distributions": [
            {
              "max": 42,
              "proportion": 3.14,
              "min": 42,
            },
          ],
        },
      },
      "id": "A String", # The url, pattern or origin which the metrics are on.
      "overall_category": "A String",
      "initial_url": "A String",
    },
    "loadingExperience": { # Metrics of end users' page loading experience.
      "metrics": {
        "a_key": { # The type of the metric.
          "category": "A String",
          "percentile": 42,
          "distributions": [
            {
              "max": 42,
              "proportion": 3.14,
              "min": 42,
            },
          ],
        },
      },
      "id": "A String", # The url, pattern or origin which the metrics are on.
      "overall_category": "A String",
      "initial_url": "A String",
    },
    "version": { # The version of PageSpeed used to generate these results.
      "major": 42, # The major version number of PageSpeed used to generate these results.
      "minor": 42, # The minor version number of PageSpeed used to generate these results.
    },
    "analysisUTCTimestamp": "A String", # The UTC timestamp of this analysis.
    "lighthouseResult": { # Lighthouse response for the audit url as an object.
      "stackPacks": [ # The Stack Pack advice strings.
        {
          "id": "A String", # The stack pack id.
          "title": "A String", # The stack pack title.
          "descriptions": { # The stack pack advice strings.
            "a_key": "A String", # The specific stack pack description.
          },
          "iconDataURL": "A String", # The stack pack icon data uri.
        },
      ],
      "fetchTime": "A String", # The time that this run was fetched.
      "categoryGroups": { # Map of category groups in the LHR.
        "a_key": { # A grouping contained in a category that groups similar audits together.
          "description": "A String", # An optional human readable description of the category group.
          "title": "A String", # The title of the category group.
        },
      },
      "configSettings": { # The configuration settings for this LHR.
        "locale": "A String", # The locale setting.
        "onlyCategories": "",
        "emulatedFormFactor": "A String", # The form factor the emulation should use.
      },
      "runWarnings": [ # List of all run warnings in the LHR. Will always output to at least `[]`.
        "",
      ],
      "finalUrl": "A String", # The final resolved url that was audited.
      "lighthouseVersion": "A String", # The lighthouse version that was used to generate this LHR.
      "environment": { # Environment settings that were used when making this LHR.
        "benchmarkIndex": 3.14, # The benchmark index number that indicates rough device class.
        "networkUserAgent": "A String", # The user agent string that was sent over the network.
        "hostUserAgent": "A String", # The user agent string of the version of Chrome used.
      },
      "timing": { # Timing information for this LHR.
        "total": 3.14, # The total duration of Lighthouse's run.
      },
      "i18n": { # The internationalization strings that are required to render the LHR.
        "rendererFormattedStrings": { # Internationalized strings that are formatted to the locale in configSettings.
          "toplevelWarningsMessage": "A String", # The label shown preceding important warnings that may have invalidated an entire report.
          "labDataTitle": "A String", # The title of the lab data performance category.
          "passedAuditsGroupTitle": "A String", # The heading that is shown above a list of audits that are passing.
          "auditGroupExpandTooltip": "A String", # The tooltip text on an expandable chevron icon.
          "warningHeader": "A String", # The label shown above a bulleted list of warnings.
          "notApplicableAuditsGroupTitle": "A String", # The heading shown above a list of audits that do not apply to a page.
          "crcLongestDurationLabel": "A String", # The label for values shown in the summary of critical request chains.
          "opportunitySavingsColumnLabel": "A String", # The heading for the estimated page load savings of opportunity audits.
          "errorMissingAuditInfo": "A String", # The error string shown next to an erroring audit.
          "varianceDisclaimer": "A String", # The disclaimer shown below a performance metric value.
          "lsPerformanceCategoryDescription": "A String", # The disclaimer shown under performance explaning that the network can vary.
          "manualAuditsGroupTitle": "A String", # The heading shown above a list of audits that were not computerd in the run.
          "opportunityResourceColumnLabel": "A String", # The heading for the estimated page load savings opportunity of an audit.
          "crcInitialNavigation": "A String", # The label for the initial request in a critical request chain.
          "scorescaleLabel": "A String", # The label that explains the score gauges scale (0-49, 50-89, 90-100).
          "errorLabel": "A String", # The label shown next to an audit or metric that has had an error.
        },
      },
      "userAgent": "A String", # The user agent that was used to run this LHR.
      "audits": { # Map of audits in the LHR.
        "a_key": { # An audit that was performed in this run. Keyed by audit id.
          "description": "A String", # The description of the audit.
          "title": "A String", # The human readable title.
          "explanation": "A String", # An explanation of the errors in the audit.
          "errorMessage": "A String", # An error message from a thrown error inside the audit.
          "score": "",
          "details": { # Freeform details section of the audit.
            "a_key": "",
          },
          "warnings": "",
          "scoreDisplayMode": "A String", # The enumerated score display mode.
          "displayValue": "A String", # The value that should be displayed on the UI for this audit.
          "id": "A String", # The audit's id.
        },
      },
      "runtimeError": { # A top-level error message that, if present, indicates a serious enough problem that this Lighthouse result may need to be discarded.
        "message": "A String", # A human readable message explaining the error code.
        "code": "A String", # The enumerated Lighthouse Error code.
      },
      "categories": { # Map of categories in the LHR.
        "seo": { # The Search-Engine-Optimization (SEO) category, containing all seo related audits.
          "description": "A String", # A more detailed description of the category and its importance.
          "title": "A String", # The human-friendly name of the category.
          "auditRefs": [ # An array of references to all the audit members of this category.
            {
              "group": "A String", # The category group that the audit belongs to (optional).
              "id": "A String", # The audit ref id.
              "weight": 3.14, # The weight this audit's score has on the overall category score.
            },
          ],
          "manualDescription": "A String", # A description for the manual audits in the category.
          "score": "",
          "id": "A String", # The string identifier of the category.
        },
        "best-practices": { # The best practices category, containing all web best practice related audits.
          "description": "A String", # A more detailed description of the category and its importance.
          "title": "A String", # The human-friendly name of the category.
          "auditRefs": [ # An array of references to all the audit members of this category.
            {
              "group": "A String", # The category group that the audit belongs to (optional).
              "id": "A String", # The audit ref id.
              "weight": 3.14, # The weight this audit's score has on the overall category score.
            },
          ],
          "manualDescription": "A String", # A description for the manual audits in the category.
          "score": "",
          "id": "A String", # The string identifier of the category.
        },
        "pwa": { # The Progressive-Web-App (PWA) category, containing all pwa related audits.
          "description": "A String", # A more detailed description of the category and its importance.
          "title": "A String", # The human-friendly name of the category.
          "auditRefs": [ # An array of references to all the audit members of this category.
            {
              "group": "A String", # The category group that the audit belongs to (optional).
              "id": "A String", # The audit ref id.
              "weight": 3.14, # The weight this audit's score has on the overall category score.
            },
          ],
          "manualDescription": "A String", # A description for the manual audits in the category.
          "score": "",
          "id": "A String", # The string identifier of the category.
        },
        "accessibility": { # The accessibility category, containing all accessibility related audits.
          "description": "A String", # A more detailed description of the category and its importance.
          "title": "A String", # The human-friendly name of the category.
          "auditRefs": [ # An array of references to all the audit members of this category.
            {
              "group": "A String", # The category group that the audit belongs to (optional).
              "id": "A String", # The audit ref id.
              "weight": 3.14, # The weight this audit's score has on the overall category score.
            },
          ],
          "manualDescription": "A String", # A description for the manual audits in the category.
          "score": "",
          "id": "A String", # The string identifier of the category.
        },
        "performance": { # The performance category, containing all performance related audits.
          "description": "A String", # A more detailed description of the category and its importance.
          "title": "A String", # The human-friendly name of the category.
          "auditRefs": [ # An array of references to all the audit members of this category.
            {
              "group": "A String", # The category group that the audit belongs to (optional).
              "id": "A String", # The audit ref id.
              "weight": 3.14, # The weight this audit's score has on the overall category score.
            },
          ],
          "manualDescription": "A String", # A description for the manual audits in the category.
          "score": "",
          "id": "A String", # The string identifier of the category.
        },
      },
      "requestedUrl": "A String", # The original requested url.
    },
    "id": "A String", # Canonicalized and final URL for the document, after following page redirects (if any).
  }