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/v2/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)
strategy string The analysis strategy to use

Acceptable values are:
  • "desktop": Fetch and analyze the URL for desktop browsers
  • "mobile": Fetch and analyze the URL for mobile devices

Request body

Do not supply a request body with this method.

Response

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

{
  "kind": "pagespeedonline#result",
  "id": string,
  "responseCode": integer,
  "title": string,
  "ruleGroups": {
    (key): {
      "score": integer
    }
  },
  "pageStats": {
    "numberResources": integer,
    "numberHosts": integer,
    "totalRequestBytes": long,
    "numberStaticResources": integer,
    "htmlResponseBytes": long,
    "textResponseBytes": long,
    "cssResponseBytes": long,
    "imageResponseBytes": long,
    "javascriptResponseBytes": long,
    "flashResponseBytes": long,
    "otherResponseBytes": long,
    "numberJsResources": integer,
    "numberCssResources": integer
  },
  "formattedResults": {
    "locale": string,
    "ruleResults": {
      (key): {
        "localizedRuleName": string,
        "ruleImpact": double,
        "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
    }
  }
}
Property name Value Description Notes
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" or "USABILITY".
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). A high score indicates little room for improvement, while a lower score indicates more room for improvement.
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.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.
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).groups[] list List of rule groups that this rule belongs to. Each entry in the list is one of "SPEED" or "USABILITY".
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 The left coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).summary.args[].rects[].top integer The top coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).summary.args[].rects[].width integer The width of the rect.
formattedResults.ruleResults.(key).summary.args[].rects[].height integer The height of the rect.
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 The left coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).summary.args[].secondary_rects[].top integer The top coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).summary.args[].secondary_rects[].width integer The width of the rect.
formattedResults.ruleResults.(key).summary.args[].secondary_rects[].height integer The height of the rect.
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 The left coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].rects[].top integer The top coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].rects[].width integer The width of the rect.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].rects[].height integer The height of the rect.
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 The left coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].secondary_rects[].top integer The top coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].secondary_rects[].width integer The width of the rect.
formattedResults.ruleResults.(key).urlBlocks[].header.args[].secondary_rects[].height integer The height of the rect.
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 The left coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].rects[].top integer The top coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].rects[].width integer The width of the rect.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].rects[].height integer The height of the rect.
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 The left coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].secondary_rects[].top integer The top coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].secondary_rects[].width integer The width of the rect.
formattedResults.ruleResults.(key).urlBlocks[].urls[].result.args[].secondary_rects[].height integer The height of the rect.
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 The left coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].rects[].top integer The top coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].rects[].width integer The width of the rect.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].rects[].height integer The height of the rect.
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 The left coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].secondary_rects[].top integer The top coordinate of the rect, in page coordinates.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].secondary_rects[].width integer The width of the rect.
formattedResults.ruleResults.(key).urlBlocks[].urls[].details[].args[].secondary_rects[].height integer The height of the rect.
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. Uses '-' instead of '+' and '_' instead of '/' so it's safe to include unescaped in URLs and cookies. To convert to standard base64 for display as an inline image in the browser, use screenshot.data.replace(/_/g,'/').replace(/-/g,'+').
screenshot.width integer Width of screenshot in pixels.
screenshot.height integer Height of screenshot in pixels.
screenshot.page_rect object The region of the page that is captured by this image, with dimensions measured in CSS pixels.
screenshot.page_rect.left integer The left coordinate of the rect, in page coordinates.
screenshot.page_rect.top integer The top coordinate of the rect, in page coordinates.
screenshot.page_rect.width integer The width of the rect.
screenshot.page_rect.height integer The height of the rect.

Try it!

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