对位于指定网址的网页运行 PageSpeed 分析,并返回 PageSpeed 得分、提高网页速度的建议列表以及其他信息。 立即试用。
请求
HTTP 请求
GET https://www.googleapis.com/pagespeedonline/v5/runPagespeed
参数
| 参数名称 | 值 | 说明 |
|---|---|---|
| 必需的查询参数 | ||
url |
string |
要提取和分析的网址 |
| 可选的查询参数 | ||
category |
string |
要运行的 Lighthouse 类别;如果未指定,则仅运行效果类别
可接受的值包括: <ph type="x-smartling-placeholder">
|
locale |
string |
用于对格式化结果进行本地化的语言区域 |
strategy |
string |
要使用的分析策略(桌面设备或移动设备),桌面设备是默认选项
可接受的值包括: <ph type="x-smartling-placeholder">
|
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 |
人机识别系统验证结果
可接受的值包括: <ph type="x-smartling-placeholder">
|
|
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 |
用于生成这些结果的 Page Speed 的版本。 | |
version.major |
integer |
用于生成这些结果的 Page Speed 的主要版本号。 | |
version.minor |
integer |
用于生成这些结果的 Page Speed 的次要版本号。 | |
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 的灯塔版本。 | |
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 |
模拟应使用的外形规格
可接受的值包括: <ph type="x-smartling-placeholder">
|
|
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 |
该对象包含任何抛出的运行时错误的代码和消息。 | |
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 对实际数据调用此方法,然后查看响应。