# OnPage Lighthouse 即時 JSON

**API:** Data API

**Endpoint:** `POST /v1/beta/dataforseo/on_page/lighthouse/live/json`

**Tags:** DataForSEO

對某個 `url` 執行 Google Lighthouse 稽核並傳回完整報告：`lighthouseVersion`、`requestedUrl`、`finalUrl`、`fetchTime`、`gatherMode`、`runWarnings`，以及每項稽核與類別的分數。`for_mobile` 切換模擬裝置，`categories` 和 `audits` 縮小執行範圍。傳入 `categories` 或 `audits` 可精簡報告；如果問題只是頁面為什麼慢，請優先使用 `post_dataforseo_on_page_waterfall`。採用 DataForSEO 的信封結構：資料位於 `tasks[0].result`，結果狀態位於 `tasks[0].status_code`——被拒絕的請求仍會回傳 HTTP 200。

### 計費參考

- 計量方式：依回報的回應成本計量。
- 參考請求估算：0.005 美元。
- 參考客戶倍率：1.0。不得對已結算的客戶金額再次套用。

僅供參考的中繼資料，並非帳戶報價、保證價格或消費上限。資源額度並非 Felo 額度。最終費用依 Felo 計費記錄為準。

## Base URL

- `https://openapi.felo.ai`

## Authentication

- `FeloBearerAuth` (http bearer, bearer format Felo API Key)
- `FeloApiKey` (apiKey in header `X-API-Key`)

## Request body

Required: **no**

### application/json

Schema:

```json
{
  "type": "array",
  "items": {
    "type": [
      "object",
      "null"
    ],
    "oneOf": [
      {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "<em>目標 URL</em><br><strong>必填欄位</strong><br>目標頁面應使用絕對 URL 指定（包含 http:// 或 https://）<br>範例：<br><code>https://dataforseo.com/</code>"
          },
          "for_mobile": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "<em>套用行動裝置模擬</em><br>選填欄位<br>如果設為 <code>true</code>，Lighthouse 將使用行動裝置與螢幕模擬，以行動環境測試頁面<br>如果設為 <code>false</code>，將提供桌面版的結果<br>預設值：<code>false</code>"
          },
          "categories": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "<em>Lighthouse 稽核類別</em><br>選填欄位<br>每個類別是稽核與稽核群組的集合，會對該區段套用加權與評分（<a href=\"https://github.com/GoogleChrome/lighthouse/blob/master/docs/architecture.md#auditreport-terminology\" rel=\"noopener noreferrer\" target=\"_blank\">參閱官方定義</a>）<p><strong>如果忽略此欄位，我們將傳回所有類別的資料，除非你指定 <code>audits</code></strong><br>使用此欄位可取得你在此處指定的特定類別資料<p>可能的值：<br><code>seo</code>、<code>performance</code>、<code>best_practices</code>、<code>accessibility</code>"
          },
          "audits": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "<em>Lighthouse 稽核</em><br>選填欄位<br>稽核是 Lighthouse 針對每個特定功能/最佳化/指標所執行的個別測試，用於產生數值分數（<a href=\"https://github.com/GoogleChrome/lighthouse/blob/master/docs/architecture.md#components--terminology\" rel=\"noopener noreferrer\" target=\"_blank\">參閱官方定義</a>）；  <p><strong>如果忽略此欄位，我們將傳回所有稽核的資料</strong>；<br>使用此欄位可取得你在此處指定的特定稽核資料；<p><strong>注意：</strong>部分稽核不屬於特定類別，是獨立的頁面品質衡量指標；<p>一般而言，可能有下列幾種使用情境：<p>1. 如果忽略 <code>categories</code>，你可以使用此欄位僅取得指定稽核的資料<br>例如，如果忽略 <code>\"categories\"</code> 並指定 <code>\"audits\": [\"metrics/cumulative-layout-shift\",\"metrics/largest-contentful-paint\",\"metrics/total-blocking-time\"]</code>，你將僅取得這些稽核的資料<p>2. 如果指定類別，你可以使用此欄位額外接收不屬於你所指定類別的稽核<br>例如，如果指定 <code>\"categories\": [\"seo\"]</code> 和 <code>\"audits\": [\"metrics/cumulative-layout-shift\",\"metrics/largest-contentful-paint\",\"metrics/total-blocking-time\"]</code>，你將僅取得 \"performance\" 下的這些稽核，以及 \"seo\" 下的所有稽核<p>你可以<a href=\"/v3/on_page/lighthouse/audits/\">在此處取得所有可能的稽核清單</a>"
          },
          "version": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>Lighthouse 版本</em><br>選填欄位<br>指定版本號碼即可取得特定 Lighthouse 版本的結果<br>可用版本清單可透過 <a href=\"/v3/on_page/lighthouse/versions/\" rel=\"noopener noreferrer\" target=\"_blank\">Lighthouse Versions 端點</a>取得"
          },
          "language_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>Lighthouse 語言名稱</em><br>選填欄位<br>你可以個別向 <code>https://api.dataforseo.com/v3/on_page/lighthouse/languages</code> 發出請求，取得搜尋引擎可用語言及其 <code>language_name</code> 的清單<br>預設值：<br><code class=\"long-string\">English</code>"
          },
          "language_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>Lighthouse 語言代碼</em><br>選填欄位<br>你可以個別向 <code>https://api.dataforseo.com/v3/on_page/lighthouse/languages</code> 發出請求，取得搜尋引擎可用語言及其 <code>language_code</code> 的清單<br>預設值：<br><code class=\"long-string\">en</code>"
          },
          "custom_user_agent": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>自訂使用者代理</em><br>選填欄位<br>指定瀏覽器在執行 Lighthouse 稽核時使用的自訂使用者代理；<br>最多可指定 254 個字元；"
          },
          "browser_screen_width": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<em>瀏覽器螢幕寬度</em><br>選填欄位<br>設定用於 Lighthouse 稽核的瀏覽器螢幕寬度，以模擬特定裝置；<br>可在下列範圍內指定：<code>240–9999</code>；",
            "format": "int64"
          },
          "browser_screen_height": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<em>瀏覽器螢幕高度</em><br>選填欄位<br>設定用於 Lighthouse 稽核的瀏覽器螢幕高度，以模擬特定裝置；<br>可在下列範圍內指定：<code>240–9999</code>；"
          },
          "browser_screen_scale_factor": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>瀏覽器螢幕縮放比例</em><br>選填欄位<br>設定用於 Lighthouse 稽核的瀏覽器裝置像素比；<br>可在下列範圍內指定：<code>0.5–3</code>；"
          },
          "browser_network_throttling_method": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>瀏覽器網路節流方法</em><br>選填欄位<br>定義 Lighthouse 稽核期間套用節流的方法；<br>可能的值：<br><code>simulate</code> - 在不套用明確節流的情況下計算預估效能指標；<br><code>devtools</code> - 套用 <code>browser_network_throttling</code> 和 <code>browser_cpu_throttling_multiplier</code> 中指定的節流設定；<br><code>provided</code> - 使用檢索環境的網路狀況；"
          },
          "browser_cpu_throttling_multiplier": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>瀏覽器 CPU 節流倍數</em><br><strong>當 <code>browser_network_throttling_method</code> 設為 <code>devtools</code> 時為必填；</strong><br>設定 CPU 節流倍數，以在 Lighthouse 稽核期間模擬裝置效能狀況；<br>可在下列範圍內指定：<code>1–4</code>；<br><strong>注意：</strong>僅當 <code>browser_network_throttling_method</code> 設為 <code>devtools</code> 時才會套用此參數；"
          },
          "browser_network_throttling": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>瀏覽器網路節流</em><br><strong>當 <code>browser_network_throttling_method</code> 設為 <code>devtools</code> 時為必填；</strong><br>設定網路節流設定檔，以在 Lighthouse 稽核期間模擬連線速度狀況；<br>可能的值：<code>no_throttling</code>、<code>fast_4g</code>、<code>slow_4g</code>、<code>regular_3g</code>、<code>pc</code>；<br><strong>注意：</strong>僅當 <code>browser_network_throttling_method</code> 設為 <code>devtools</code> 時才會套用此參數；"
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>使用者自訂任務識別碼</em><br>選填欄位<br><em>字元數上限為 255</em><br>可使用此參數識別任務，並將其與結果對應<br>可在回應的 <code>data</code> 物件中找到指定的 <code>tag</code> 值"
          }
        },
        "example": [
          {
            "url": "https://dataforseo.com",
            "for_mobile": true,
            "tag": "some_string_123"
          }
        ]
      }
    ]
  },
  "example": [
    {
      "url": "https://dataforseo.com",
      "for_mobile": true,
      "tag": "some_string_123"
    }
  ]
}
```

## Responses

### 200 — 操作成功

Headers:
- `X-Request-Id` (string) — 聯絡 Felo 支援時需提供的請求識別碼。

**application/json**

Schema: object | null

```json
{
  "type": [
    "object",
    "null"
  ],
  "oneOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_OnPageLighthouseLiveJsonResponseInfo"
    }
  ]
}
```

### 400 — 無法處理該要求。請檢查請求參數。

### 401 — 需要有效的 Felo API 金鑰。

### 402 — 由於未符合計費要求，要求無法繼續。

### 403 — 該帳戶無權執行此操作。

### 429 — 已達到要求或支出上限。

### 502 — 服務無法完成該要求。

### 503 — API 或計費服務暫時無法使用。

### 504 — 服務在處理要求時逾時。

### default — 錯誤回應；上游透傳回應可能採用供應商格式

**application/json**

Schema:

```json
{}
```

## Schema definitions

### Response36Afe1097B20_BaseResponseInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseInfo`

```json
{
  "properties": {
    "version": {
      "type": [
        "string",
        "null"
      ],
      "description": "API 的目前版本"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "一般狀態碼\n完整回應碼清單請見此處"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "一般資訊訊息\n完整的一般資訊訊息清單請見此處"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "總執行時間，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任務總費用，美元",
      "format": "double"
    },
    "tasks_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 陣列中的任務數",
      "format": "int64"
    },
    "tasks_error": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 陣列中傳回錯誤的任務數",
      "format": "int64"
    }
  }
}
```

### Response36Afe1097B20_BaseResponseTaskInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo`

```json
{
  "properties": {
    "id": {
      "type": [
        "string",
        "null"
      ],
      "description": "任務識別碼\n我們系統中 UUID 格式的唯一任務識別碼"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "任務的狀態碼\n由 DataForSEO 產生，範圍如下：10000-60000\n完整回應碼清單請見此處"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "任務的資訊訊息\n完整的一般資訊訊息清單請見此處"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "執行時間，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任務總費用，美元",
      "format": "double"
    },
    "result_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "result 陣列中的元素數",
      "format": "int64"
    },
    "path": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "URL 路徑"
    },
    "data": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": [
          "object",
          "null"
        ]
      },
      "description": "包含你在 POST 請求中指定的相同參數"
    }
  }
}
```

### Response36Afe1097B20_OnPageLighthouseLiveJsonResponseInfo

`#/components/schemas/Response36Afe1097B20_OnPageLighthouseLiveJsonResponseInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseInfo"
    },
    {
      "type": "object",
      "properties": {
        "tasks": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_OnPageLighthouseLiveJsonTaskInfo"
              }
            ]
          },
          "description": "<em>任務陣列</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_OnPageLighthouseLiveJsonTaskInfo

`#/components/schemas/Response36Afe1097B20_OnPageLighthouseLiveJsonTaskInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo"
    },
    {
      "type": "object",
      "properties": {
        "result": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {
              "type": [
                "object",
                "null"
              ]
            }
          },
          "description": "<em>Lighthouse 稽核結果</em><br>此陣列會包含依設定任務時指定參數產生的資料<p>所有欄位及其說明均可在官方文件中透過<a href=\"https://github.com/GoogleChrome/lighthouse/blob/master/readme.md\">此連結</a>取得。"
        }
      }
    }
  ]
}
```
