Pagespeedapi: runpagespeed

对位于指定网址的网页运行 PageSpeed 分析,并返回 PageSpeed 得分、提升网页加载速度的建议列表以及其他信息。 立即尝试

请求

HTTP 请求

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

参数

参数名称 说明
必需的查询参数
url string 要提取和分析的网址
可选的查询参数
category string 要运行的 Lighthouse 类别;如果未指定任何类别,系统将仅运行“Performance”类别

可接受的值为:
  • accessibility
  • best-practices
  • performance
  • pwa
  • seo
locale string 用于本地化格式化结果的语言区域
strategy string 要使用的分析策略(桌面设备或移动设备),默认值为桌面设备

可接受的值为:
  • desktop”:提取并分析适用于桌面浏览器的网址
  • mobile”:提取并分析移动设备的网址
utm_campaign string 用于分析的广告系列名称。
utm_source string 用于分析的广告系列来源。

请求正文

使用此方法时请勿提供请求正文。

响应

如果成功,此方法将返回采用以下结构的响应正文:

{
  "captchaResult": string,
  "kind": "pagespeedonline#result",
  "id": string,
  "loadingExperience": {
    "id": string,
    "metrics": {
      (key): {
        "percentile": integer,
        "distributions": [
          {
            "min": integer,
            "max": integer,
            "proportion": double
          }
        ],
        "category": string
      }
    },
    "overall_category": string,
    "initial_url": string
  },
  "originLoadingExperience": {
    "id": string,
    "metrics": {
      (key): {
        "percentile": integer,
        "distributions": [
          {
            "min": integer,
            "max": integer,
            "proportion": double
          }
        ],
        "category": string
      }
    },
    "overall_category": string,
    "initial_url": string
  },
  "lighthouseResult": {
    "requestedUrl": string,
    "finalUrl": string,
    "lighthouseVersion": string,
    "userAgent": string,
    "fetchTime": string,
    "environment": {
      "networkUserAgent": string,
      "hostUserAgent": string,
      "benchmarkIndex": double
    },
    "runWarnings": [
      (value)
    ],
    "configSettings": {
      "emulatedFormFactor": string,
      "locale": string,
      "onlyCategories": (value),
      "onlyCategories": (value)
    },
    "audits": {
      (key): {
        "id": string,
        "title": string,
        "description": string,
        "score": (value),
        "score": (value),
        "scoreDisplayMode": string,
        "displayValue": string,
        "explanation": string,
        "errorMessage": string,
        "warnings": (value),
        "warnings": (value),
        "details": {
          (key): (value)
        }
      }
    },
    "categories": {
      (key): {
        "id": string,
        "title": string,
        "description": string,
        "score": (value),
        "score": (value),
        "manualDescription": string,
        "auditRefs": [
          {
            "id": string,
            "weight": double,
            "group": string
          }
        ]
      }
    },
    "categoryGroups": {
      (key): {
        "title": string,
        "description": string
      }
    },
    "runtimeError": {
      "code": string,
      "message": string
    },
    "timing": {
      "total": double
    },
    "i18n": {
      "rendererFormattedStrings": {
        "varianceDisclaimer": string,
        "opportunityResourceColumnLabel": string,
        "opportunitySavingsColumnLabel": string,
        "errorMissingAuditInfo": string,
        "errorLabel": string,
        "warningHeader": string,
        "auditGroupExpandTooltip": string,
        "passedAuditsGroupTitle": string,
        "notApplicableAuditsGroupTitle": string,
        "manualAuditsGroupTitle": string,
        "toplevelWarningsMessage": string,
        "scorescaleLabel": string,
        "crcLongestDurationLabel": string,
        "crcInitialNavigation": string,
        "lsPerformanceCategoryDescription": string,
        "labDataTitle": string
      }
    }
  },
  "analysisUTCTimestamp": string,
  "version": {
    "major": integer,
    "minor": integer
  }
}
属性名称 说明 备注
captchaResult string 人机识别系统验证结果

可接受的值为:
  • "CAPTCHA_BLOCKING"
  • "CAPTCHA_MATCHED"
  • "CAPTCHA_NEEDED"
  • "CAPTCHA_NOT_NEEDED"
  • "CAPTCHA_UNMATCHED"
kind string 结果的种类。
id string 经过网页重定向(如有)后的规范化和最终到达网址。
loadingExperience nested object 最终用户的网页加载体验指标。
loadingExperience.id string 指标所在的网址、格式或来源。
loadingExperience.metrics object
loadingExperience.metrics.(key) object 指标的类型。
loadingExperience.metrics.(key).distributions[] list
loadingExperience.metrics.(key).distributions[].min integer
loadingExperience.metrics.(key).distributions[].max integer
loadingExperience.metrics.(key).distributions[].proportion double
version object 生成这些结果时所用的 PageSpeed 版本。
version.major integer 生成这些结果时所使用的 PageSpeed 的主要版本号。
version.minor integer 生成这些结果所用的 PageSpeed 的次要版本号。
loadingExperience.metrics.(key).category string

可接受的值:
  • "AVERAGE"
  • "FAST"
  • "NONE"
  • "SLOW"
loadingExperience.overall_category string

可接受的值:
  • "AVERAGE"
  • "FAST"
  • "NONE"
  • "SLOW"
loadingExperience.initial_url string
loadingExperience.metrics.(key).percentile integer
originLoadingExperience nested object 来源的汇总网页加载体验指标
originLoadingExperience.id string 指标所在的网址、格式或来源。
originLoadingExperience.metrics object
originLoadingExperience.metrics.(key) object 指标的类型。
originLoadingExperience.metrics.(key).percentile integer
originLoadingExperience.metrics.(key).distributions[] list
originLoadingExperience.metrics.(key).distributions[].min integer
originLoadingExperience.metrics.(key).distributions[].max integer
originLoadingExperience.metrics.(key).distributions[].proportion double
originLoadingExperience.metrics.(key).category string

可接受的值:
  • "AVERAGE"
  • "FAST"
  • "NONE"
  • "SLOW"
originLoadingExperience.overall_category string

可接受的值:
  • "AVERAGE"
  • "FAST"
  • "NONE"
  • "SLOW"
originLoadingExperience.initial_url string
analysisUTCTimestamp string 此分析的世界协调时间 (UTC) 时间戳。
lighthouseResult nested object 将审核网址作为对象的 Lighthouse 响应。
lighthouseResult.requestedUrl string 请求的原始网址。
lighthouseResult.finalUrl string 经审核的最终已解析网址。
lighthouseResult.lighthouseVersion string 用于生成此 LHR 的灯塔版本。
lighthouseResult.userAgent string 用于运行此 LHR 的用户代理。
lighthouseResult.fetchTime string 提取此运行作业的时间。
lighthouseResult.environment object 生成此 LHR 时使用的环境设置。
lighthouseResult.environment.networkUserAgent string
lighthouseResult.environment.hostUserAgent string
lighthouseResult.environment.benchmarkIndex double
lighthouseResult.runWarnings[] list LHR 中所有运行警告的列表。将始终输出到至少 `[]`。
lighthouseResult.configSettings object 此 LHR 的配置设置。
lighthouseResult.configSettings.emulatedFormFactor string 模拟应使用的外形规格

可接受的值包括:
  • "UNKNOWN_FORM_FACTOR"
  • "desktop"
  • "mobile"
  • "none"
lighthouseResult.configSettings.locale string 语言区域设置
lighthouseResult.configSettings.onlyCategories nested object
lighthouseResult.audits object LHR 中的审计地图。
lighthouseResult.audits.(key) nested object
lighthouseResult.audits.(key).id string 审核 ID。
lighthouseResult.audits.(key).title string 直观易懂的标题。
lighthouseResult.audits.(key).description string 审核的说明。
lighthouseResult.audits.(key).score nested object
lighthouseResult.audits.(key).scoreDisplayMode string 枚举得分显示模式。

可接受的值:
  • "SCORE_DISPLAY_MODE_UNSPECIFIED"
  • "binary"
  • "error"
  • "informative"
  • "manual"
  • "not_applicable"
  • "numeric"
lighthouseResult.audits.(key).displayValue string 应针对此项审核的界面显示的值。
lighthouseResult.audits.(key).explanation string 审核中错误的说明。
lighthouseResult.audits.(key).errorMessage string 审核过程中抛出的错误导致的错误消息。
lighthouseResult.audits.(key).warnings nested object
lighthouseResult.audits.(key).details object 审计作业的“自由格式详细信息”部分。
lighthouseResult.audits.(key).details.(key) any value
lighthouseResult.categories object LHR 中类别的地图。
lighthouseResult.categories.(key) nested object
lighthouseResult.categories.(key).id string 类别的字符串标识符。
lighthouseResult.categories.(key).title string 直观易懂的类别名称
lighthouseResult.categories.(key).description string 对类别及其重要性的进一步说明。
lighthouseResult.categories.(key).score nested object
lighthouseResult.categories.(key).manualDescription string 对该类别中的手动审核的说明。
lighthouseResult.categories.(key).auditRefs[] list 一个数组,引用此类别的所有审核成员。
lighthouseResult.categories.(key).auditRefs[].id string 审核参考 ID。
lighthouseResult.categories.(key).auditRefs[].weight double 此项评估的得分在总体类别得分中所占的权重。
lighthouseResult.categories.(key).auditRefs[].group string 此审核所属的类别群组(可选)。
lighthouseResult.categoryGroups object LHR 中类别组的地图。
lighthouseResult.categoryGroups.(key) object
lighthouseResult.categoryGroups.(key).title string
lighthouseResult.categoryGroups.(key).description string
lighthouseResult.runtimeError object 该对象包含任何抛出的运行时错误的代码和消息。
lighthouseResult.runtimeError.code string

可接受的值:
  • "ERRORED_DOCUMENT_REQUEST"
  • "FAILED_DOCUMENT_REQUEST"
  • "INSECURE_DOCUMENT_REQUEST"
  • "INVALID_SPEEDLINE"
  • "NO_DCL"
  • "NO_DOCUMENT_REQUEST"
  • "NO_ERROR"
  • "NO_FCP"
  • "NO_NAVSTART"
  • "NO_SCREENSHOTS"
  • "NO_SPEEDLINE_FRAMES"
  • "NO_TRACING_STARTED"
  • "PARSING_PROBLEM"
  • "PROTOCOL_TIMEOUT"
  • "READ_FAILED"
  • "SPEEDINDEX_OF_ZERO"
  • "TRACING_ALREADY_STARTED"
  • "UNKNOWN_ERROR"
lighthouseResult.runtimeError.message string
lighthouseResult.timing object 此 LHR 的时间信息。
lighthouseResult.timing.total double Lighthouse 的运行总时长
lighthouseResult.i18n object 呈现 LHR 所需的国际化字符串。
lighthouseResult.i18n.rendererFormattedStrings object
lighthouseResult.i18n.rendererFormattedStrings.varianceDisclaimer string
lighthouseResult.i18n.rendererFormattedStrings.opportunityResourceColumnLabel string
lighthouseResult.i18n.rendererFormattedStrings.opportunitySavingsColumnLabel string
lighthouseResult.i18n.rendererFormattedStrings.errorMissingAuditInfo string
lighthouseResult.i18n.rendererFormattedStrings.errorLabel string
lighthouseResult.i18n.rendererFormattedStrings.warningHeader string
lighthouseResult.i18n.rendererFormattedStrings.auditGroupExpandTooltip string
lighthouseResult.i18n.rendererFormattedStrings.passedAuditsGroupTitle string
lighthouseResult.i18n.rendererFormattedStrings.notApplicableAuditsGroupTitle string
lighthouseResult.i18n.rendererFormattedStrings.manualAuditsGroupTitle string
lighthouseResult.i18n.rendererFormattedStrings.toplevelWarningsMessage string
lighthouseResult.i18n.rendererFormattedStrings.scorescaleLabel string
lighthouseResult.i18n.rendererFormattedStrings.crcLongestDurationLabel string
lighthouseResult.i18n.rendererFormattedStrings.crcInitialNavigation string
lighthouseResult.i18n.rendererFormattedStrings.lsPerformanceCategoryDescription string
lighthouseResult.i18n.rendererFormattedStrings.labDataTitle string

试试看!

请使用下面的 API Explorer 对实时数据调用此方法并查看响应。