主题
business_data/errors
POST /v3/business_data/errors
本接口使用 POST 方法,请求路径为:
/v3/business_data/errors
用于查询过去 7 天返回错误的 Business Data API 任务。若任务了 webhook(pingback 或 postback),但因服务器错误未能正常接收回调,可通过本接口获取任务 ID,再调用 /v3/appendix/webhook_resend 重新发送 webhook。
如果某个任务未出现在结果中,表示该任务未返回错误,或尚未完成。
计费说明
调用本接口不收费,响应中的 cost 通常为 0。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求
请求地址
text
POST https://api.seermartech.cn/v3/business_data/errors请求体使用 UTF-8 编码的 JSON 数组格式:
json
[
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
]请求参数
| 参数 | 类型 | 说明 |
|---|---|---|
limit | integer | 最多返回的错误任务数量。可选,默认值为 1000,最大值为 1000。 |
offset | integer | 结果集偏移量。可选,默认值为 0。例如设置为 10 时,将跳过前 10 条结果并返回后续任务。 |
filtered_function | string | 按 API 函数筛选错误任务。可使用响应中 function 字段返回的值进行筛选,例如 hotel_searches/task_post、postback_url、pingback_url。 |
datetime_from | string | 错误时间筛选起始时间。可选支持过去 7 天范围的 datetime。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
datetime_to | string | 错误时间筛选结束时间。可选支持过去 7 天范围的 datetime。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
时间参数示例:
text
2021-11-15 12: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 函数,例如 pingback_url。 |
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/business_data/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/business_data/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.status_code == 200:
result = response.json()
if result.get("status_code") == 20000:
print(result)
# 在此处理错误任务列表
else:
print(
"错误。状态码:%s,说明:%s"
% (result.get("status_code"), result.get("status_message"))
)
else:
print("HTTP 请求失败:%s" % response.status_code)TypeScript
typescript
import axios from "axios";
const postData = [
{
limit: 10,
offset: 0,
filtered_function: "pingback_url",
},
];
axios({
method: "post",
url: "https://api.seermartech.cn/v3/business_data/errors",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
data: postData,
})
.then((response) => {
const result = response.data;
if (result.status_code === 20000) {
console.log(result);
// 在此处理错误任务列表
} else {
console.error(
`错误。状态码:${result.status_code},说明:${result.status_message}`
);
}
})
.catch((error) => {
console.error("请求失败:", 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": "7f7b7f2a-6c2a-4f7c-9f3a-123456789abc",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1200 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"business_data",
"errors"
],
"data": [
{
"api": "business_data",
"function": "errors",
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
],
"result": [
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"datetime": "2021-11-15 13:20:00 +00:00",
"function": "pingback_url",
"error_code": 500,
"error_message": "Server error",
"http_url": "https://example.com/pingback",
"http_method": "POST",
"http_code": 500,
"http_time": 0.842,
"http_response": "Internal Server Error"
}
]
}
]
}实用场景
- 排查 webhook 回调失败任务:筛选
pingback_url或postback_url错误,定位未成功接收回调的任务并进行补偿处理。 - 批量重发失败 webhook:获取错误任务 ID 后调用 webhook 重发接口,降低任务结果丢失对数据链路的影响。
- 按时间窗口监控接口异常:使用
datetime_from和datetime_to查询指定时间段的失败任务,定位短时服务障。 - 按业务函数分析错误分布:使用
filtered_function区分不同 API 函数的错误,识别最需要优化的业务链路。 - 构建任务失败告警机制:定时查询错误任务并结合
error_code、http_code和http_response触发告警,提升 SEO 数据采集任务的可用性。