对指定网址上的网页运行 PageSpeed 分析,并返回 PageSpeed 得分、加快该网页速度的建议列表和其他信息。 立即试用。
请求
HTTP 请求
GET https://www.googleapis.com/pagespeedonline/v5/runPagespeed
参数
| 参数名称 | 值 | 说明 |
|---|---|---|
| 必需的查询参数 | ||
url | string | 要提取和分析的网址 |
| 可选的查询参数 | ||
category | string | 要运行的 Lighthouse 类别;如果未指定任何类别,则仅运行“性能”类别 可接受的值:
|
locale | string | 用于本地化格式化结果的语言区域 |
strategy | string | 要使用的分析策略(桌面设备或移动设备),默认值为桌面设备 可接受的值:
|
utm_campaign | string | 用于分析的广告系列名称。 |
utm_source | string | Google Analytics 的宣传活动来源。 |
请求正文
使用此方法时请勿提供请求正文。
响应
如果成功,此方法将返回采用以下结构的响应正文:
{ "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 | 验证码验证结果 可接受的值:
| |
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 | 可接受的值包括:
| |
loadingExperience.overall_category | string | 可接受的值包括:
| |
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 | 可接受的值包括:
| |
originLoadingExperience.overall_category | string | 可接受的值包括:
| |
originLoadingExperience.initial_url | string | ||
analysisUTCTimestamp | string | 相应分析的 UTC 时间戳。 | |
lighthouseResult | nested object | 审核网址的 Lighthouse 响应(以对象形式)。 | |
lighthouseResult.requestedUrl | string | 原始请求的网址。 | |
lighthouseResult.finalUrl | string | 经过审核的最终解析网址。 | |
lighthouseResult.lighthouseVersion | string | 用于生成此 LHR 的 Lighthouse 版本。 | |
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 | 模拟应使用的设备规格 可接受的值包括:
| |
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 | 枚举的分数显示模式。 可接受的值包括:
| |
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 | 包含任何抛出的运行时错误的 code + message 的对象。 | |
lighthouseResult.runtimeError.code | string | 可接受的值包括:
| |
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 对实际数据调用此方法,然后查看响应。