Skip to content

OnPage 错误任务查询

接口说明

调用本接口可获取最近 7 天执行失败的 OnPage API 任务信息。

型场景:如果你为任务了 webhook(如 pingback 或 postback),但由于服务器异常未收到回调,可通过本接口获取失败任务的 ID 列表,再结合 /v3/appendix/webhook_resend/ 触发 webhook 重发。

如果某个任务未出现在返回列表中,通常表示以下之一:

  • 该任务未发生错误;
  • 该任务尚未执行完成。

计费说明

调用本接口不收费

扣费以响应头 X-SeerMarTech-Charge-CNY 为准。

请求地址

POST https://api.seermartech.cn/v3/on_page/errors

请求格式

所有 POST 数据均需使用 JSON(UTF-8 编码)提交。

请求体需为 JSON 数组格式:

json
[
 {
 "limit": 10,
 "offset": 0,
 "filtered_function": "pingback_url"
 }
]

请求参数

字段名类型说明
limitinteger返回的错误任务最大数量。可选;默认值:1000;最大值:1000
offsetinteger返回结果的偏移量。可选;默认值:0。例如设置为 10 时,将跳过前 10 条任务,返回后续数据
filtered_functionstring按指定功能过滤错误任务。可用于返回某一类错误任务。过滤值可使用接口响应中 function 字段返回的值,例如:on_page/task_postpostback_urlpingback_url
datetime_fromstring结果过滤开始时间。可选;按 datetime 字段筛选最近 7 天的数据。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 12:57:46 +00:00
datetime_tostring结果过滤结束时间。可选;按 datetime 字段筛选最近 7 天的数据。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 13:57:46 +00:00

响应结构

接口返回 JSON 数据 tasks 数组。

顶层字段

字段名类型说明
versionstring当前 API 版本
status_codeinteger接口总体状态码,可参考 /v3/appendix/errors
status_messagestring接口总体状态信息,可参考 /v3/appendix/errors
timestring总执行时间,单位秒
costfloat本次请求总费用,单位 USD
tasks_countintegertasks 数组中的任务数量
tasks_errorintegertasks 数组中返回错误的任务数量
tasksarray任务结果数组

tasks[] 字段

字段名类型说明
idstring任务唯一标识,UUID 格式
status_codeinteger任务状态码,范围通常为 10000–60000,可参考 /v3/appendix/errors
status_messagestring任务状态说明,可参考 /v3/appendix/errors
timestring任务执行时间,单位秒
costfloat单任务费用,单位 USD
result_countintegerresult 数组中的数量
patharray请求路径
dataarray与提交请求时一致的参数
resultarray错误结果数组

tasks[].result[] 字段

字段名类型说明
idstring任务 ID
datetimestring错误发生时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2019-11-15 12:57:46 +00:00
functionstring对应的 API 功能名称
error_codeinteger错误码
error_messagestring错误信息或导致错误的 URL。错误信息完整列表可参考 /v3/appendix/errors/
http_urlstring导致错误的 URL;可能是你调用 API 使用的 URL,也可能是 pingback/postback 回调地址
http_methodstringHTTP 方法
http_codeintegerHTTP 状态码
http_timefloatHTTP 请求耗时。对于了 pingback/postback 的任务,该字段表示你的服务器响应回调所耗费的时间
http_responsestring服务器响应

调用示例

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"
 }
]'

Python

python
import requests

url = "https://api.seermartech.cn/v3/on_page/errors"
headers = {
 "Authorization": "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json"
}
data = [
 {
 "limit": 10,
 "offset": 0,
 "filtered_function": "pingback_url"
 }
]

response = requests.post(url, headers=headers, json=data)
result = response.json

if result.get("status_code") == 20000:
 print(result)
else:
 print(f'error. Code: {result.get("status_code")} Message: {result.get("status_message")}')

TypeScript

typescript
import axios from "axios";

const postArray = [
 {
 limit: 10,
 offset: 0,
 filtered_function: "pingback_url",
 },
];

axios({
 method: "post",
 url: "https://api.seermartech.cn/v3/on_page/errors",
 headers: {
 Authorization: "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json",
 },
 data: postArray,
})
 .then((response) => {
 // 返回结果
 console.log(response.data);
 })
 .catch((error) => {
 console.error(error);
 });

响应示例

json
{
 "version": "0.1.20220321",
 "status_code": 20000,
 "status_message": "Ok.",
 "time": "0.1538 sec.",
 "cost": 0,
 "tasks_count": 1,
 "tasks_error": 0,
 "tasks": [
 {
 "data": {
 "api": "on_page",
 "function": "errors",
 "limit": 10,
 "offset": 0,
 "filtered_function": "pingback_url"
 },
 "result": []
 }
 ]
}

状态码与错误处理

  • 顶层 status_code / status_message 表示本次接口请求整体状态;
  • tasks[].status_code / tasks[].status_message 表示单个任务的处理状态;
  • result[].error_code / result[].error_message 用于描述失败原因;
  • 完整状态码与错误信息可参考 /v3/appendix/errors

排查建议:

  1. 检查顶层 status_code 是否为 20000
  2. 若接口调用成功,再检查 tasks[].result 是否错误记录;
  3. 若错误与 webhook 有,重点查看:
  • function
  • http_url
  • http_code
  • http_time
  • http_response
  1. 如需重试 webhook,可结合 /v3/appendix/webhook_resend/ 使用返回的任务 ID 进行补发。

使用说明

  • 支持查询最近 7 天的错误任务;
  • 建议在首次不加过滤条件查询后,根据返回结果中的 function 值,再使用 filtered_function 精确筛选;
  • datetime_fromdatetime_to须使用 UTC 时间格式,否则可能无法正确过滤结果;
  • 若返回为空,通常表示最近 7 天没有符合条件的错误记录,或对应任务尚未完成。

实用场景

  • 排查回调失败任务:查询 pingback_urlpostback_url 错误,快速定位未成功回调的任务,减少任务结果丢失风险。
  • 补发 webhook:筛出失败任务 ID,再调用 /v3/appendix/webhook_resend/ 进行重发,提升任务通知链路稳定性。
  • 监控接口异常趋势:按时间范围提取最近 7 天错误记录,识别某一时段的集中失败问题,便于排查服务波动或网络异常。
  • 定位特定功能障:使用 filtered_function 聚焦某个 API 功能的异常任务,缩短技术排障时间。
  • 审计服务端响应问题:结合 http_codehttp_timehttp_response 检查回调接收端表现,帮助优化 webhook 接收服务的可用性。

统一入口:官网 · LLM API · 控制台