主题
OnPage API 错误任务查询
POST /v3/on_page/errors
本接口使用 POST /v3/on_page/errors,用于查询过去 7 天返回错误的 OnPage API 任务。
如果任务了 webhook( pingback 和 postback),但由于服务器错误未能成功接收回调,可通过本接口获取对应的任务 ID,再使用 Webhook 重发接口重新发送。若某个任务未出现在结果中,通常表示该任务未返回错误,或任务尚未完成。
计费说明
本接口不收取调用费用,响应中的 cost 通常为 0。
请求说明
- 请求方法:
POST - 请求路径:
/v3/on_page/errors - 完整 URL:
https://api.seermartech.cn/v3/on_page/errors - Content-Type:
application/json - **请求体格式:**JSON 数组,数组中的每个对象表示一组查询参数。
- **时间范围:**支持查询最近 7 天的错误记录。
请求参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
limit | integer | 否 | 返回的错误任务最大数量。默认值为 1000,最大值为 1000。 |
offset | integer | 否 | 结果偏移量,默认值为 0。例如设置为 10 时,将跳过前 10 条记录并返回后续任务。 |
filtered_function | string | 否 | 按 API 函数筛选错误任务。可使用响应中 function 字段的值,例如 on_page/task_post、postback_url、pingback_url。 |
datetime_from | string | 否 | 错误记录的起始时间。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 12:57:46 +00:00。 |
datetime_to | string | 否 | 错误记录的结束时间。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 13:57:46 +00:00。 |
请求示例
json
[
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
]响应字段
顶层响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
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 | 请求 URL 路径。 |
data | array | 创建任务时提交的参数,与 POST 请求中的参数一致。 |
result | array | 错误记录数组。 |
result 数组中的错误记录字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 发生错误的任务 ID。 |
datetime | string | 错误发生时间,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
function | string | 对应的 API 函数,例如 pingback_url 或 postback_url。 |
error_code | integer | 错误码。 |
error_message | string | 错误信息,或触发错误的 URL。 |
http_url | string | 触发错误的 URL,可以是 API 请求 URL,也可以是 pingback/postback URL。 |
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/on_page/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/on_page/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/on_page/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,
)
result = response.json()
if result.get("status_code") == 20000:
# 处理错误任务列表
print(result)
else:
print(
"请求失败,状态码:{},信息:{}".format(
result.get("status_code"),
result.get("status_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": "11111111-2222-3333-4444-555555555555",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1200 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"on_page",
"errors"
],
"data": {
"api": "on_page",
"function": "errors",
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
},
"result": [
{
"id": "66666666-7777-8888-9999-000000000000",
"datetime": "2021-11-15 13:20:46 +00:00",
"function": "pingback_url",
"error_code": 50000,
"error_message": "HTTP request failed",
"http_url": "https://example.com/pingback",
"http_method": "POST",
"http_code": 500,
"http_time": 2.341,
"http_response": "Internal Server Error"
}
]
}
]
}实用场景
- 排查未收到的 webhook 回调:筛选
pingback_url或postback_url错误,定位漏接任务并进行重发,减少异步任务结果丢失。 - 监控 OnPage 任务失败:按时间范围定期拉取错误记录,及时发现批量任务异常并触发告警。
- 定位回调服务器障:结合
http_code、http_time和http_response分析回调接口的时、5xx 或响应格式问题。 - 按 API 函数统计错误:使用
filtered_function区分任务提交、pingback 和 postback 等错误来源,评估系统稳定性。 - 补偿失败任务处理流程:提取错误记录中的任务 ID,与 Webhook 重发或补偿队列结合,人工逐条排查。