主题
SERP 错误任务查询
POST /v3/serp/errors
本接口使用 POST 方法,路径为 /v3/serp/errors。用于查询过去 7 天返回错误的 SERP API 任务。
如果任务了 webhook( pingback 或 postback),但由于服务器错误未能收到回调,可以通过本接口获取发生错误的任务 ID,再使用 webhook 重发接口重新发送回调。若某个任务未出现在结果中,表示该任务未返回错误,或任务尚未完成。
请求信息
- 请求方法:
POST - 请求路径:
/v3/serp/errors - 完整 URL:
https://api.seermartech.cn/v3/serp/errors - Content-Type:
application/json - 认证方式:
Authorization: Bearer smt_live_YOUR_KEY - 请求体格式: JSON 数组
本接口不收取调用费用。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
请求体是 JSON 数组,每个数组代表一组查询条件。
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
limit | integer | 否 | 返回的错误任务最大数量。默认值为 1000,取值范围为 1-1000。 |
offset | integer | 否 | 结果偏移量。设置为 10 时,跳过前 10 条任务并返回后续结果。默认值和最小值为 0,最大值为 100000000。 |
filtered_function | string | 否 | 按函数筛选错误任务。可使用响应中 function 字段的值进行筛选,例如 serp/task_get/advanced。也可以使用 pingback_url 或 postback_url,用于筛选与回调地址的错误任务。 |
datetime_from | string | 否 | 错误时间筛选起点。支持过去 7 天的数据,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。最早不能早于当前时间往前 7 天,最晚不能晚于当前时间。 |
datetime_to | string | 否 | 错误时间筛选终点。支持过去 7 天的数据,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。如果同时传 datetime_from,该值晚于 datetime_from。 |
时间参数示例
text
datetime_from: 2021-11-15 12:57:46 +00:00
datetime_to: 2021-11-15 13:57:46 +00:00请求示例
cURL
bash
curl --location --request POST "https://api.seermartech.cn/v3/serp/errors" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
]'TypeScript
typescript
import axios from "axios";
const postData = [
{
limit: 10,
offset: 0,
filtered_function: "pingback_url",
},
];
axios
.post("https://api.seermartech.cn/v3/serp/errors", postData, {
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
})
.then((response) => {
// 处理响应数据
console.log(response.data);
})
.catch((error) => {
// 处理请求错误
console.error(error.response?.data || error.message);
});Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/errors"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
post_data = [
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url",
}
]
response = requests.post(url, headers=headers, json=post_data)
if response.ok:
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
f"错误。代码:{result.get('status_code')},"
f"消息:{result.get('status_message')}"
)
else:
print(f"HTTP 错误:{response.status_code},消息:{response.text}")响应结构
接口返回 JSON 数据 tasks 数组查询结果。
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求的通用状态码。20000 表示请求成功。 |
status_message | string | 请求的通用状态信息。 |
time | string | 请求总耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | tasks 数组中返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
tasks 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式。 |
status_code | integer | 任务状态码,通常位于 10000-60000 范围。 |
status_message | string | 任务状态说明。 |
time | string | 任务执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量。 |
path | array | 请求路径信息。 |
data | array | 创建任务时提交的参数。 |
result | array | 错误任务数组。 |
result 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 发生错误的任务 ID。 |
datetime | string | 错误发生时间,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
function | string | 对应的 API 函数,例如 serp/task_get/advanced。 |
error_code | integer | 任务错误码。 |
error_message | string | 错误信息,或导致错误的 URL。 |
http_url | string | 导致错误的 URL,可能是 API 请求地址,也可能是 pingback/postback 回调地址。 |
http_method | string | 发生错误的 HTTP 方法。 |
http_code | integer | HTTP 状态码。 |
http_time | float | HTTP 请求耗时。对于了 pingback/postback 的任务,该字段表示本平台服务器客户端服务器响应的时间。 |
http_response | string | HTTP 响应。 |
响应示例
json
{
"version": "0.1.20220321",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1538 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "710c3c5e-8f1f-4d9b-9c1d-123456789abc",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1538 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"serp",
"errors"
],
"data": [
{
"api": "serp",
"function": "errors",
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
],
"result": [
{
"id": "3f5b4a4c-6c17-4f77-8e9d-987654321abc",
"datetime": "2019-11-15 12:57:46 +00:00",
"function": "pingback_url",
"error_code": 50000,
"error_message": "回调服务器返回错误",
"http_url": "https://example.com/pingback",
"http_method": "POST",
"http_code": 500,
"http_time": 1.238,
"http_response": "Internal Server Error"
}
]
}
]
}状态码与错误处理
- 顶层
status_code用于表示本次查询请求是否成功。 tasks[].status_code用于表示任务级别的处理状态。result[].error_code用于表示错误任务的错误码。- 可结合
error_message、http_code、http_response和http_url定位 API 请求或 webhook 回调失败原因。 - 完整状态码和错误信息请参考错误码文档。
实用场景
- 检索失败的 webhook 任务:筛选
pingback_url或postback_url错误,找回未收到回调的任务 ID, SEO 数据处理链路中断。 - 重发失败回调:根据错误结果中的任务 ID 和回调地址,批量重试 webhook,补齐排名、SERP 结果等业务数据。
- 定位特定接口障:通过
filtered_function筛选某个 SERP 函数,快速判断问题集中在哪类任务,缩短障排查时间。 - 监控 API 错误趋势:结合
datetime_from和datetime_to按时间窗口查询错误任务,分析接口稳定性并发现异常时段。 - 核对任务执行状态:根据任务 ID、HTTP 状态码和响应复盘失败原因,提升 SEO 数据采集任务的重试和告警准确率。