Pagespeedapi: runpagespeed

對指定網址的網頁執行 PageSpeed 分析,並傳回 PageSpeed 分數、可加快網頁速度的建議清單和其他資訊。 立即試用

要求

HTTP 要求

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

參數

參數名稱 說明
必要查詢參數
url string 要擷取及分析的網址
選用查詢參數
category string 要執行的 Lighthouse 類別;如果未提供任何類別,系統只會執行「效能」類別

可接受的值如下:
  • accessibility
  • best-practices
  • performance
  • seo
locale string 用於本地化格式化結果的語言代碼
strategy string 要使用的分析策略 (電腦或行動裝置),預設為電腦

可接受的值包括:
  • desktop」:擷取並分析電腦版瀏覽器的網址
  • mobile」:擷取並分析行動裝置的網址
utm_campaign string 用於 Analytics 的廣告活動名稱。
utm_source string 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 驗證碼驗證結果

可接受的值如下:
  • 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 這項分析的世界標準時間戳記。
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 模擬功能應使用的板型規格

可接受的值如下:
  • 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 類別的字串 ID。
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,針對即時資料呼叫這個方法,然後查看回應。