curl --request POST \
--url https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"url": "https://example.com",
"categories": [
"seo"
]
}
]
'import requests
url = "https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json"
payload = [
{
"url": "https://example.com",
"categories": ["seo"]
}
]
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([{url: 'https://example.com', categories: ['seo']}])
};
fetch('https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'url' => 'https://example.com',
'categories' => [
'seo'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json"
payload := strings.NewReader("[\n {\n \"url\": \"https://example.com\",\n \"categories\": [\n \"seo\"\n ]\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {\n \"url\": \"https://example.com\",\n \"categories\": [\n \"seo\"\n ]\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"url\": \"https://example.com\",\n \"categories\": [\n \"seo\"\n ]\n }\n]"
response = http.request(request)
puts response.read_body{
"version": "<string>",
"status_code": 123,
"status_message": "<string>",
"time": "<string>",
"cost": 123,
"tasks_count": 123,
"tasks_error": 123,
"tasks": [
"<string>"
],
"tasks.id": "<string>",
"tasks.status_code": 123,
"tasks.status_message": "<string>",
"tasks.time": "<string>",
"tasks.cost": 123,
"tasks.result_count": 123,
"tasks.path": [
"<string>"
],
"tasks.data": {},
"tasks.result": [
"<string>"
]
}实时 OnPage Lighthouse JSON
对某个 url 跑一次 Google Lighthouse 审计并返回完整报告:lighthouseVersion、requestedUrl、finalUrl、fetchTime、gatherMode、runWarnings,以及全部审计项与分类得分。
curl --request POST \
--url https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
[
{
"url": "https://example.com",
"categories": [
"seo"
]
}
]
'import requests
url = "https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json"
payload = [
{
"url": "https://example.com",
"categories": ["seo"]
}
]
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify([{url: 'https://example.com', categories: ['seo']}])
};
fetch('https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
[
'url' => 'https://example.com',
'categories' => [
'seo'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json"
payload := strings.NewReader("[\n {\n \"url\": \"https://example.com\",\n \"categories\": [\n \"seo\"\n ]\n }\n]")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("[\n {\n \"url\": \"https://example.com\",\n \"categories\": [\n \"seo\"\n ]\n }\n]")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "[\n {\n \"url\": \"https://example.com\",\n \"categories\": [\n \"seo\"\n ]\n }\n]"
response = http.request(request)
puts response.read_body{
"version": "<string>",
"status_code": 123,
"status_message": "<string>",
"time": "<string>",
"cost": 123,
"tasks_count": 123,
"tasks_error": 123,
"tasks": [
"<string>"
],
"tasks.id": "<string>",
"tasks.status_code": 123,
"tasks.status_message": "<string>",
"tasks.time": "<string>",
"tasks.cost": 123,
"tasks.result_count": 123,
"tasks.path": [
"<string>"
],
"tasks.data": {},
"tasks.result": [
"<string>"
]
}url 跑一次 Google Lighthouse 审计并返回完整报告:lighthouseVersion、requestedUrl、finalUrl、fetchTime、gatherMode、runWarnings,以及全部审计项与分类得分。for_mobile 切换模拟设备,categories 和 audits 收窄范围。实测 $0.005。🔴 example.com 一次审计实测 245 KB,是整个 provider 里最大的响应——完整 Lighthouse 报告是一份JSON 文档而不是一个指标,会主导 agent 的上下文。传 categories 或 audits 压缩它;问题只是「页面为什么慢」时,用 post_dataforseo_on_page_waterfall。响应包在信封里:数据在 tasks[0].result,成败在 tasks[0].status_code——请求被拒时 HTTP 仍是 200。
示例
curl -X POST "https://api.aisa.one/apis/v1/dataforseo/on_page/lighthouse/live/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '[{"url": "...", "for_mobile": "...", "categories": "..."}]'
授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
目标 URL 必填字段;应使用绝对 URL(包括 http:// 或 https://)指定目标页面;示例:https://dataforseo.com/
应用移动设备模拟;可选字段。如果设置为 true,Lighthouse 将使用移动设备和屏幕模拟,在移动环境下测试页面;如果设置为 false,将提供桌面端结果。默认值:false。
Lighthouse 审核类别。可选字段。每个类别都是审核和审核组的集合,会对相应部分应用权重和评分(请参阅官方定义)。如果忽略此字段,我们将返回所有类别的数据,除非您指定 audits。使用此字段可获取您在此处指定的特定类别的数据。可选值:seo、performance、best_practices、accessibility
Lighthouse 审核 可选字段 audits 是 Lighthouse 针对每项特定功能/优化/指标运行的独立测试,用于生成数值分数(参阅官方定义);如果忽略此字段,我们将返回所有审核的数据;使用此字段可获取您在此处指定的特定审核的数据;注意:某些审核不属于特定类别,而是独立的页面质量衡量指标;通常有以下几种使用场景:1. 如果忽略 categories,可以使用此字段仅获取指定审核的数据,例如,如果忽略 "categories" 并指定 "audits": ["metrics/cumulative-layout-shift","metrics/largest-contentful-paint","metrics/total-blocking-time"],则仅会获得这些审核的数据 2. 如果指定某个类别,可以使用此字段额外接收不属于所指定类别的审核,例如,如果指定 "categories": ["seo"] 和 "audits": ["metrics/cumulative-layout-shift","metrics/largest-contentful-paint","metrics/total-blocking-time"],则会获得 “performance” 下的这些审核以及 “seo” 下的所有审核 您可以在此处获取所有可用审核的完整列表
Lighthouse 版本;可选字段;通过指定版本号,您可以获取特定 Lighthouse 版本的结果;可用版本列表可通过 Lighthouse Versions 端点获取
Lighthouse 语言名称;可选字段;可通过向 https://api.dataforseo.com/v3/on_page/lighthouse/languages 单独发起请求,获取搜索引擎的可用语言及其 language_name 列表;默认值:English
Lighthouse 语言代码,可选字段。您可以通过向 https://api.dataforseo.com/v3/on_page/lighthouse/languages 单独发送请求,获取搜索引擎可用语言及其 language_code 的列表。默认值:en
用户定义的任务标识符。可选字段。字符数限制为 255。您可以使用此参数标识任务并将其与结果匹配;您将在响应的 data 对象中找到指定的 tag 值
响应
成功响应
API 的当前版本
通用状态码;您可以在此处查看完整的响应码列表。注意:我们强烈建议设计必要的系统来处理相关异常或错误情况
常规信息消息;可在此处查看常规信息消息的完整列表
执行时间(秒)
任务总成本(美元)
tasks 数组中的任务数量
返回错误的 tasks 数组中的任务数量
任务数组
任务标识符,系统中采用 UUID 格式的唯一任务标识符
DataForSEO 生成的任务状态码;范围为:10000-60000;完整响应代码列表可在此处查看
任务的信息性消息,你可以在此处查看通用信息性消息的完整列表
执行时间(秒)
任务成本(美元)
结果数组中的元素数量
URL 路径
包含设置任务时指定的相同参数
Lighthouse 审核结果 此数组将包含根据您设置任务时指定的参数生成的数据;所有字段及其说明均可通过此链接在官方文档中查看。