0

我正在寻找使用谷歌页面速度 API 获取 FCP、FID、LCP 和 CLS 的字段数据百分比

在此处输入图像描述

我正在使用以下 API 来获取详细信息。

获取https://pagespeedonline.googleapis.com/pagespeedonline/v5/runPagespeed?url=https%3A%2F%2Fstackoverflow.com%2F&category=PERFORMANCE&strategy=DESKTOP&prettyPrint=true&fields=loadingExperience&key=[YOUR_API_KEY] HTTP/1.1

授权:承载 [YOUR_ACCESS_TOKEN]

接受:应用程序/json

但它返回百分位响应。如何获得百分比值?还是我们需要应用外部计算?

{
  "loadingExperience": {
    "id": "https://stackoverflow.com/",
    "metrics": {
      "CUMULATIVE_LAYOUT_SHIFT_SCORE": {
        "percentile": 0,
        "distributions": [
          {
            "min": 0,
            "max": 10,
            "proportion": 0.99741968778222245
          },
          {
            "min": 10,
            "max": 25,
            "proportion": 0.001935234163333765
          },
          {
            "min": 25,
            "proportion": 0.00064507805444458848
          }
        ],
        "category": "FAST"
      },
      "FIRST_CONTENTFUL_PAINT_MS": {
        "percentile": 771,
        "distributions": [
          {
            "min": 0,
            "max": 1800,
            "proportion": 0.93900089893413219
          },
          {
            "min": 1800,
            "max": 3000,
            "proportion": 0.035058430717863527
          },
          {
            "min": 3000,
            "proportion": 0.025940670348016285
          }
        ],
        "category": "FAST"
      },
      "FIRST_INPUT_DELAY_MS": {
        "percentile": 3,
        "distributions": [
          {
            "min": 0,
            "max": 100,
            "proportion": 0.9860482193122
          },
          {
            "min": 100,
            "max": 300,
            "proportion": 0.010402643495288195
          },
          {
            "min": 300,
            "proportion": 0.0035491371925100721
          }
        ],
        "category": "FAST"
      },
      "LARGEST_CONTENTFUL_PAINT_MS": {
        "percentile": 1036,
        "distributions": [
          {
            "min": 0,
            "max": 2500,
            "proportion": 0.94559352517986284
          },
          {
            "min": 2500,
            "max": 4000,
            "proportion": 0.032181397738951942
          },
          {
            "min": 4000,
            "proportion": 0.022225077081192358
          }
        ],
        "category": "FAST"
      }
    },
    "overall_category": "FAST",
    "initial_url": "https://stackoverflow.com/"
  }
}
4

0 回答 0