主题
API 错误查询
POST /v3/serp/errors
本接口用于查询指定 API 在过去 7 天返回错误的任务。HTTP 方法与路径为:
POST /v3/$path/errors
,$path 表示目标 API 的路径标识,例如 serp、keywords_data 或 dataforseo_labs。
如果任务了 webhook( pingback 和 postback),但由于服务器错误未收到回调,可通过本接口获取发生错误的任务 ID,再调用 webhook 重发接口重新发送回调。
如果某个任务未出现在结果中,通常表示该任务未返回错误,或任务尚未完成。
计费说明
本接口不收取调用费用。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
支持的 API 路径
动态字段 $path 可使用以下值:
| 值 | 说明 |
|---|---|
serp | SERP 数据接口 |
ai_optimization | AI 优化接口 |
keywords_data | 数据接口 |
domain_analytics | 域名分析接口 |
dataforseo_labs | SEO Labs 数据接口 |
backlinks | 外链数据接口 |
on_page | 页面分析接口 |
content_analysis | 分析接口 |
merchant | 商业数据接口 |
app_data | 应用数据接口 |
business_data | 商业地点数据接口 |
例如,查询 SERP API 的错误任务:
POST https://api.seermartech.cn/v3/serp/errors
请求参数
请求体使用 UTF-8 编码的 JSON 数组格式:
json
[
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
]| 参数 | 类型 | 说明 |
|---|---|---|
limit | integer | 返回的错误任务最大数量。可选,默认值为 1000,取值范围为 1-1000。 |
offset | integer | 结果数组偏移量。可选,默认值和最小值为 0,最大值为 100000000。例如设置为 10 时,将跳过前 10 条结果并返回后续任务。 |
filtered_function | string | 按指定函数筛选错误任务。可使用 API 响应中 function 字段的值进行筛选,也可以使用请求中的 pingback_url 或 postback_url。例如:serp/task_get/advanced。 |
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响应字段
接口返回 JSON 数据 tasks 数组查询结果。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求级状态码。完整状态码请参考错误码附录。 |
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 | 任务对应的 URL 路径。 |
data | array | 创建任务时提交的参数。 |
result | array | 错误明细数组。 |
result 字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 发生错误的任务 ID。 |
datetime | string | 错误发生时间,使用 UTC 格式 yyyy-mm-dd hh-mm-ss +00:00。 |
function | string | 对应的 API 函数。 |
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 服务端响应。 |
请求示例
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"
}
]'将路径中的 serp 替换为支持的 $path 值,即可查询对应 API 的错误任务。
Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/errors"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
payload = [
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url",
}
]
response = requests.post(url, headers=headers, json=payload)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败,状态码:{},信息:{}".format(
result.get("status_code"),
result.get("status_message"),
)
)TypeScript
typescript
import axios from "axios";
const payload = [
{
limit: 10,
offset: 0,
filtered_function: "pingback_url",
},
];
axios
.post("https://api.seermartech.cn/v3/serp/errors", payload, {
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);
});响应示例
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": "01234567-89ab-cdef-0123-456789abcdef",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1200 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"serp",
"errors"
],
"data": [
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
],
"result": [
{
"id": "abcdef12-3456-7890-abcd-ef1234567890",
"datetime": "2019-11-15 12:57:46 +00:00",
"function": "pingback_url",
"error_code": 50000,
"error_message": "Callback server returned an error",
"http_url": "https://example.com/pingback",
"http_method": "POST",
"http_code": 500,
"http_time": 1.234,
"http_response": "Internal Server Error"
}
]
}
]
}实用场景
- 检索过去 7 天失败的任务,定位 API 请求错误并安排自动重试,减少批量 SEO 数据采集中的数据缺口。
- 筛选
pingback_url或postback_url错误,找出未成功接收回调的任务,及时补发 webhook 结果。 - 按 API 函数过滤错误,集中排查某个、排名或外链接口的异常,缩短障定位时间。
- 按 UTC 时间范围查询错误,分析特定发布窗口或定时任务周期的失败率,为调度策略和服务稳定性优化提供依据。
- 读取
http_code、http_response和http_time,区分接口错误与客户回调服务器错误,明确责任边界并指导运维处理。