Pagespeedapi: runpagespeed

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. Try it now.

Request

HTTP request

GET https://www.googleapis.com/pagespeedonline/v4/runPagespeed

Parameters

Parameter name Value Description
Required query parameters
url string The URL to fetch and analyze
Optional query parameters
filter_third_party_resources boolean Indicates if third party resources should be filtered out before PageSpeed analysis. (Default: false)
locale string The locale used to localize formatted results
rule string A PageSpeed rule to run; if none are given, all rules are run
screenshot boolean Indicates if binary data containing a screenshot should be included (Default: false)
snapshots boolean Indicates if binary data containing snapshot images should be included (Default: false)
strategy string The analysis strategy (desktop or mobile) to use, and desktop is the default

Acceptable values are:
  • "desktop": Fetch and analyze the URL for desktop browsers
  • "mobile": Fetch and analyze the URL for mobile devices
utm_campaign string Campaign name for analytics.
utm_source string Campaign source for analytics.

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a response body with the following structure:

{
  "captchaResult": string,
  "kind": "pagespeedonline#result",
  "id": string,
  "responseCode": integer,
  "title": string,
  "ruleGroups": {
    (key): {
      "score": integer,
      "pass": boolean
    }
  },
  "loadingExperience": {
    "id": string,
    "metrics": {
      (key): {
        "median": integer,
        "distributions": [
          {
            "min": integer,
            "max": integer,
            "proportion": double
          }
        ],
        "category": string
      }
    },
    "overall_category": string,
    "initial_url": string
  },
  "pageStats": {
    "numberResources": integer,
    "numberHosts": integer,
    "totalRequestBytes": long,
    "numberStaticResources": integer,
    "htmlResponseBytes": long,
    "textResponseBytes": long,
    "overTheWireResponseBytes": long,
    "cssResponseBytes": long,
    "imageResponseBytes": long,
    "javascriptResponseBytes": long,
    "flashResponseBytes": long,
    "otherResponseBytes": long,
    "numberJsResources": integer,
    "numberCssResources": integer,
    "numberRobotedResources": integer,
    "numberTransientFetchFailureResources": integer,
    "numTotalRoundTrips": integer,
    "numRenderBlockingRoundTrips": integer,
    "robotedUrls": [
      string
    ],
    "transientFetchFailureUrls": [
      string
    ],
    "cms": string
  },
  "formattedResults": {
    "locale": string,
    "ruleResults": {
      (key): {
        "localizedRuleName": string,
        "ruleImpact": double,
        "beta": boolean,
        "groups": [
          string
        ],
        "summary": {
          "format": string,
          "args": [
            {
              "type": string,
              "key": string,
              "value": string,
              "rects": [
                {
                  "left": integer,
                  "top": integer,
                  "width": integer,
                  "height": integer
                }
              ],
              "secondary_rects": [
                {
                  "left": integer,
                  "top": integer,
                  "width": integer,
                  "height": integer
                }
              ]
            }
          ]
        },
        "urlBlocks": [
          {
            "header": {
              "format": string,
              "args": [
                {
                  "type": string,
                  "key": string,
                  "value": string,
                  "rects": [
                    {
                      "left": integer,
                      "top": integer,
                      "width": integer,
                      "height": integer
                    }
                  ],
                  "secondary_rects": [
                    {
                      "left": integer,
                      "top": integer,
                      "width": integer,
                      "height": integer
                    }
                  ]
                }
              ]
            },
            "urls": [
              {
                "result": {
                  "format": string,
                  "args": [
                    {
                      "type": string,
                      "key": string,
                      "value": string,
                      "rects": [
                        {
                          "left": integer,
                          "top": integer,
                          "width": integer,
                          "height": integer
                        }
                      ],
                      "secondary_rects": [
                        {
                          "left": integer,
                          "top": integer,
                          "width": integer,
                          "height": integer
                        }
                      ]
                    }
                  ]
                },
                "details": [
                  {
                    "format": string,
                    "args": [
                      {
                        "type": string,
                        "key": string,
                        "value": string,
                        "rects": [
                          {
                            "left": integer,
                            "top": integer,
                            "width": integer,
                            "height": integer
                          }
                        ],
                        "secondary_rects": [
                          {
                            "left": integer,
                            "top": integer,
                            "width": integer,
                            "height": integer
                          }
                        ]
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    }
  },
  "version": {
    "major": integer,
    "minor": integer
  },
  "invalidRules": [
    string
  ],
  "screenshot": {
    "key": string,
    "mime_type": string,
    "data": bytes,
    "width": integer,
    "height": integer,
    "page_rect": {
      "left": integer,
      "top": integer,
      "width": integer,
      "height": integer
    }
  },
  "snapshots": [
    {
      "key": string,
      "mime_type": string,
      "data": bytes,
      "width": integer,
      "height": integer,
      "page_rect": {
        "left": integer,
        "top": integer,
        "width": integer,
        "height": integer
      }
    }
  ]
}
Property name Value Description Notes
captchaResult string The captcha verify result

Acceptable values are:
  • "CAPTCHA_BLOCKING"
  • "CAPTCHA_MATCHED"
  • "CAPTCHA_NEEDED"
  • "CAPTCHA_NOT_NEEDED"
  • "CAPTCHA_UNMATCHED"
kind string Kind of result.
id string Canonicalized and final URL for the document, after following page redirects (if any).
responseCode integer Response code for the document. 200 indicates a normal page load. 4xx/5xx indicates an error.
title string Title of the page, as displayed in the browser's title bar.
ruleGroups object A map with one entry for each rule group in these results.
ruleGroups.(key) object The name of this rule group: one of "SPEED", "USABILITY", or "SECURITY".
ruleGroups.(key).score integer The score (0-100) for this rule group, which indicates how much better a page could be in that category (e.g. how much faster, or how much more usable, or how much more secure). A high score indicates little room for improvement, while a lower score indicates more room for improvement.
ruleGroups.(key).pass boolean
loadingExperience object Metrics of end users' page loading experience.
loadingExperience.id string The url, pattern or origin which the metrics are on.
loadingExperience.metrics object
loadingExperience.metrics.(key) object The type of the metric.
loadingExperience.metrics.(key).median integer
loadingExperience.metrics.(key).distributions[] list
loadingExperience.metrics.(key).distributions[].min integer
loadingExperience.metrics.(key).distributions[].max integer
loadingExperience.metrics.(key).distributions[].proportion double
pageStats object Summary statistics for the page, such as number of JavaScript bytes, number of HTML bytes, etc.
pageStats.numberResources integer Number of HTTP resources loaded by the page.
pageStats.numberHosts integer Number of unique hosts referenced by the page.
pageStats.totalRequestBytes long Total size of all request bytes sent by the page.
pageStats.numberStaticResources integer Number of static (i.e. cacheable) resources on the page.
pageStats.htmlResponseBytes long Number of uncompressed response bytes for the main HTML document and all iframes on the page.
pageStats.textResponseBytes long Number of uncompressed response bytes for text resources not covered by other statistics (i.e non-HTML, non-script, non-CSS resources) on the page.
pageStats.overTheWireResponseBytes long Number of over-the-wire bytes, uses the default gzip compression strategy as an estimation.
pageStats.cssResponseBytes long Number of uncompressed response bytes for CSS resources on the page.
pageStats.imageResponseBytes long Number of response bytes for image resources on the page.
pageStats.javascriptResponseBytes long Number of uncompressed response bytes for JS resources on the page.
pageStats.flashResponseBytes long Number of response bytes for flash resources on the page.
pageStats.otherResponseBytes long Number of response bytes for other resources on the page.
pageStats.numberJsResources integer Number of JavaScript resources referenced by the page.
pageStats.numberCssResources integer Number of CSS resources referenced by the page.
pageStats.numberRobotedResources integer Number of roboted resources.
pageStats.numberTransientFetchFailureResources integer Number of transient-failed resources.
pageStats.numTotalRoundTrips integer The needed round trips to load the full page
pageStats.numRenderBlockingRoundTrips integer The needed round trips to load render blocking resources
pageStats.robotedUrls[] list List of roboted urls.
pageStats.transientFetchFailureUrls[] list List of transient fetch failure urls.
pageStats.cms string Content management system (CMS) used for the page.

Acceptable values are:
  • "BITRIX"
  • "BLOGGER"
  • "DATALIFE_ENGINE"
  • "DRUPAL"
  • "GOOGLE_SITES"
  • "JOOMLA"
  • "MAGENTO"
  • "PRESTASHOP"
  • "TUMBLR"
  • "UNKNOWN"
  • "VBULLETIN"
  • "WORDPRESS"
formattedResults object Localized PageSpeed results. Contains a ruleResults entry for each PageSpeed rule instantiated and run by the server.
formattedResults.locale string The locale of the formattedResults, e.g. "en_US".
formattedResults.ruleResults object Dictionary of formatted rule results, with one entry for each PageSpeed rule instantiated and run by the server.
formattedResults.ruleResults.(key) object The enum-like identifier for this rule. For instance "EnableKeepAlive" or "AvoidCssImport". Not localized.
formattedResults.ruleResults.(key).localizedRuleName string Localized name of the rule, intended for presentation to a user.
formattedResults.ruleResults.(key).ruleImpact double The impact (unbounded floating point value) that implementing the suggestions for this rule would have on making the page faster. Impact is comparable between rules to determine which rule's suggestions would have a higher or lower impact on making a page faster. For instance, if enabling compression would save 1MB, while optimizing images would save 500kB, the enable compression rule would have 2x the impact of the image optimization rule, all other things being equal.
formattedResults.ruleResults.(key).beta boolean Whether this rule is in 'beta'. Rules in beta are new rules that are being tested, which do not impact the overall score.
formattedResults.ruleResults.(key).groups[] list List of rule groups that this rule belongs to. Each entry in the list is one of "SPEED", "USABILITY", or "SECURITY".
formattedResults.ruleResults.(key).summary nested object A brief summary description for the rule, indicating at a high level what should be done to follow the rule and what benefit can be gained by doing so.
formattedResults.ruleResults.(key).summary.format string A localized format string with {{FOO}} placeholders, where 'FOO' is the key of the argument whose value should be substituted. For HYPERLINK arguments, the format string will instead contain {{BEGIN_FOO}} and {{END_FOO}} for the argument with key 'FOO'.
formattedResults.ruleResults.(key).summary.args[] list List of arguments for the format string.
formattedResults.ruleResults.(key).summary.args[].type string Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, DURATION, VERBATIM_STRING, PERCENTAGE, HYPERLINK, or SNAPSHOT_RECT.

Acceptable values are:
  • "BYTES"
  • "DISTANCE"
  • "DURATION"
  • "HYPERLINK"
  • "INT_LITERAL"
  • "PERCENTAGE"
  • "SNAPSHOT_RECT"
  • "STRING_LITERAL"
  • "URL"
  • "VERBATIM_STRING"
formattedResults.ruleResults.(key).summary.args[].key string The placeholder key for this arg, as a string.
formattedResults.ruleResults.(key).summary.args[].value string Argument value, as a localized string.
formattedResults.ruleResults.(key).summary.args[].rects[] list The screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments. If this is absent for a SNAPSHOT_RECT argument, it means that that argument refers to the entire snapshot.
formattedResults.ruleResults.(key).summary.args[].rects[].left integer
formattedResults.ruleResults.(key).summary.args[].rects[].top integer
formattedResults.ruleResults.(key).summary.args[].rects[].width integer
formattedResults.ruleResults.(key).summary.args[].rects[].height integer
formattedResults.ruleResults.(key).summary.args[].secondary_rects[] list Secondary screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments.
formattedResults.ruleResults.(key).summary.args[].secondary_rects[].left integer
formattedResults.ruleResults.(key).summary.args[].secondary_rects[].top integer
formattedResults.ruleResults.(key).summary.args[].secondary_rects[].width integer
formattedResults.ruleResults.(key).summary.args[].secondary_rects[].height integer
formattedResults.ruleResults.(key).urlBlocks[] list List of blocks of URLs. Each block may contain a heading and a list of URLs. Each URL may optionally include additional details.
formattedResults.ruleResults.(key).urlBlocks[].header nested object Heading to be displayed with the list of URLs.
formattedResults.ruleResults.(key).urlBlocks[].header.format string A localized format string with {{FOO}} placeholders, where 'FOO' is the key of the argument whose value should be substituted. For HYPERLINK arguments, the format string will instead contain {{BEGIN_FOO}} and {{END_FOO}} for the argument with key 'FOO'.
formattedResults.ruleResults.(key).urlBlocks[].header.args[] list List of arguments for the format string.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].type string Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, DURATION, VERBATIM_STRING, PERCENTAGE, HYPERLINK, or SNAPSHOT_RECT.

Acceptable values are:
  • "BYTES"
  • "DISTANCE"
  • "DURATION"
  • "HYPERLINK"
  • "INT_LITERAL"
  • "PERCENTAGE"
  • "SNAPSHOT_RECT"
  • "STRING_LITERAL"
  • "URL"
  • "VERBATIM_STRING"
formattedResults.ruleResults.(key).urlBlocks[].header.args[].key string The placeholder key for this arg, as a string.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].value string Argument value, as a localized string.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].rects[] list The screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments. If this is absent for a SNAPSHOT_RECT argument, it means that that argument refers to the entire snapshot.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].rects[].left integer
formattedResults.ruleResults.(key).urlBlocks[].header.args[].rects[].top integer
formattedResults.ruleResults.(key).urlBlocks[].header.args[].rects[].width integer
formattedResults.ruleResults.(key).urlBlocks[].header.args[].rects[].height integer
formattedResults.ruleResults.(key).urlBlocks[].header.args[].secondary_rects[] list Secondary screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].secondary_rects[].left integer
formattedResults.ruleResults.(key).urlBlocks[].header.args[].secondary_rects[].top integer
formattedResults.ruleResults.(key).urlBlocks[].header.args[].secondary_rects[].width integer
formattedResults.ruleResults.(key).urlBlocks[].header.args[].secondary_rects[].height integer
formattedResults.ruleResults.(key).urlBlocks[].urls[] list List of entries that provide information about URLs in the url block. Optional.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result nested object A format string that gives information about the URL, and a list of arguments for that format string.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.format string A localized format string with {{FOO}} placeholders, where 'FOO' is the key of the argument whose value should be substituted. For HYPERLINK arguments, the format string will instead contain {{BEGIN_FOO}} and {{END_FOO}} for the argument with key 'FOO'.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[] list List of arguments for the format string.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].type string Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, DURATION, VERBATIM_STRING, PERCENTAGE, HYPERLINK, or SNAPSHOT_RECT.

Acceptable values are:
  • "BYTES"
  • "DISTANCE"
  • "DURATION"
  • "HYPERLINK"
  • "INT_LITERAL"
  • "PERCENTAGE"
  • "SNAPSHOT_RECT"
  • "STRING_LITERAL"
  • "URL"
  • "VERBATIM_STRING"
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].key string The placeholder key for this arg, as a string.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].value string Argument value, as a localized string.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].rects[] list The screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments. If this is absent for a SNAPSHOT_RECT argument, it means that that argument refers to the entire snapshot.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].rects[].left integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].rects[].top integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].rects[].width integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].rects[].height integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].secondary_rects[] list Secondary screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].secondary_rects[].left integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].secondary_rects[].top integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].secondary_rects[].width integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].secondary_rects[].height integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[] list List of entries that provide additional details about a single URL. Optional.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].format string A localized format string with {{FOO}} placeholders, where 'FOO' is the key of the argument whose value should be substituted. For HYPERLINK arguments, the format string will instead contain {{BEGIN_FOO}} and {{END_FOO}} for the argument with key 'FOO'.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[] list List of arguments for the format string.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].type string Type of argument. One of URL, STRING_LITERAL, INT_LITERAL, BYTES, DURATION, VERBATIM_STRING, PERCENTAGE, HYPERLINK, or SNAPSHOT_RECT.

Acceptable values are:
  • "BYTES"
  • "DISTANCE"
  • "DURATION"
  • "HYPERLINK"
  • "INT_LITERAL"
  • "PERCENTAGE"
  • "SNAPSHOT_RECT"
  • "STRING_LITERAL"
  • "URL"
  • "VERBATIM_STRING"
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].key string The placeholder key for this arg, as a string.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].value string Argument value, as a localized string.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].rects[] list The screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments. If this is absent for a SNAPSHOT_RECT argument, it means that that argument refers to the entire snapshot.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].rects[].left integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].rects[].top integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].rects[].width integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].rects[].height integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].secondary_rects[] list Secondary screen rectangles being referred to, with dimensions measured in CSS pixels. This is only ever used for SNAPSHOT_RECT arguments.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].secondary_rects[].left integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].secondary_rects[].top integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].secondary_rects[].width integer
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].secondary_rects[].height integer
version object The version of PageSpeed used to generate these results.
version.major integer The major version number of PageSpeed used to generate these results.
version.minor integer The minor version number of PageSpeed used to generate these results.
invalidRules[] list List of rules that were specified in the request, but which the server did not know how to instantiate.
screenshot nested object Base64-encoded screenshot of the page that was analyzed.
screenshot.key string Unique string key, if any, identifying this image.
screenshot.mime_type string Mime type of image data (e.g. "image/jpeg").
screenshot.data bytes Image data base64 encoded.
screenshot.width integer Width of screenshot in pixels.
screenshot.height integer Height of screenshot in pixels.
screenshot.page_rect object
screenshot.page_rect.left integer
screenshot.page_rect.top integer
screenshot.page_rect.width integer
screenshot.page_rect.height integer
snapshots[] list Additional base64-encoded screenshots of the page, in various partial render states.
snapshots[].key string Unique string key, if any, identifying this image.
snapshots[].mime_type string Mime type of image data (e.g. "image/jpeg").
snapshots[].data bytes Image data base64 encoded.
snapshots[].width integer Width of screenshot in pixels.
snapshots[].height integer Height of screenshot in pixels.
snapshots[].page_rect object
snapshots[].page_rect.left integer
snapshots[].page_rect.top integer
snapshots[].page_rect.width integer
snapshots[].page_rect.height integer
loadingExperience.metrics.(key).category string

Acceptable values are:
  • "AVERAGE"
  • "FAST"
  • "NONE"
  • "SLOW"
loadingExperience.overall_category string

Acceptable values are:
  • "AVERAGE"
  • "FAST"
  • "NONE"
  • "SLOW"
loadingExperience.initial_url string

Try it!

Use the APIs Explorer below to call this method on live data and see the response.