主题
Backlinks API 错误查询
POST /v3/backlinks/errors
本接口使用 POST 方法,路径为:
POST https://api.seermartech.cn/v3/backlinks/errors
用于查询过去 7 天返回错误的 Backlinks API 任务。若某个任务未出现在结果中,表示该任务未返回错误,或任务尚未完成。
本接口不收取调用费用。请求体使用 UTF-8 编码的 JSON 数组格式,任务参数放置在数组中。
请求参数
| 参数 | 类型 | 说明 |
|---|---|---|
limit | integer | 返回的错误任务最大数量。可选,默认值为 1000,最大值为 1000。 |
offset | integer | 结果数组的偏移量。可选,默认值为 0。例如设置为 10 时,将跳过前 10 个任务并返回后续任务。 |
filtered_function | string | 按 API 功能筛选返回错误的任务。取值应使用 API 响应中 function 字段的值,例如 backlinks/live。建议查询未筛选结果,再根据返回的 function 值进行筛选。 |
datetime_from | string | 错误时间筛选起始时间。可选支持过去 7 天范围的 datetime。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 12:57:46 +00:00。 |
datetime_to | string | 错误时间筛选结束时间。可选支持过去 7 天范围的 datetime。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 13:57:46 +00:00。 |
请求示例
cURL
bash
curl --location --request POST "https://api.seermartech.cn/v3/backlinks/errors" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"limit": 10,
"offset": 0,
"filtered_function": "backlinks/content_duplicates"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/backlinks/errors"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
payload = [
{
"limit": 10,
"offset": 0,
"filtered_function": "backlinks/content_duplicates",
}
]
response = requests.post(url, headers=headers, json=payload)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败,错误码:%s,错误信息:%s"
% (result.get("status_code"), result.get("status_message"))
)TypeScript
typescript
import axios from "axios";
const payload = [
{
limit: 10,
offset: 0,
filtered_function: "backlinks/content_duplicates",
},
];
axios
.post("https://api.seermartech.cn/v3/backlinks/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 数据 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 | 请求 URL 路径信息。 |
data | array | 请求时提交的参数。 |
result | array | 错误记录数组。 |
result素字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 发生错误的任务 ID。 |
datetime | string | 错误发生时间,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2019-11-15 12:57:46 +00:00。 |
function | string | 对应的 API 功能,例如 backlinks/content_duplicates。 |
error_code | integer | 错误码。 |
error_message | string | 错误信息或导致错误的 URL。 |
http_url | string | 导致错误的请求 URL,即发起 API 调用时使用的 URL。 |
http_method | string | HTTP 请求方法。 |
http_code | integer | HTTP 状态码。 |
http_time | float | HTTP 请求耗时。 |
http_response | string | 平台服务器返回的 HTTP 响应。 |
响应示例
json
{
"version": "0.1.20220327",
"status_code": 20000,
"status_message": "Ok.",
"time": "5.2472 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1284 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"backlinks",
"errors"
],
"data": {
"api": "backlinks",
"function": "errors",
"limit": 10,
"offset": 0,
"filtered_function": "backlinks/content_duplicates"
},
"result": [
{
"id": "abcdef12-3456-7890-abcd-ef1234567890",
"datetime": "2021-11-15 13:20:10 +00:00",
"function": "backlinks/content_duplicates",
"error_code": 40501,
"error_message": "Request failed",
"http_url": "https://api.seermartech.cn/v3/backlinks/content_duplicates/task_post",
"http_method": "POST",
"http_code": 500,
"http_time": 1.2345,
"http_response": "Internal Server Error"
}
]
}
]
}状态码与错误处理
- 顶层
status_code用于表示本次接口请求的总体处理结果。 tasks_error表示返回错误记录的任务数量。tasks中的任务可能独立的status_code和status_message。result.error_code表示错误记录的错误码。- 当
http_code、http_response或error_message存在时,可结合这些字段定位失败原因。 - 实扣费以响应头
X-SeerMarTech-Charge-CNY为准;本接口按当前规则不收取调用费用。
实用场景
- 筛选特定功能的失败任务:按
filtered_function查询指定 Backlinks 功能的错误记录,快速定位某一数据流程的异常。 - 按时间范围排查障:使用
datetime_from和datetime_to缩小错误发生时间范围,分析定时任务或批量任务的障原因。 - 构建任务失败监控:周期性调用接口并统计
tasks_error、error_code和http_code,及时发现 Backlinks 数据采集异常。 - 实现失败任务审计:保存
id、function、http_url和http_response等信息,为问题复盘和技术支持提供完整上下文。 - 控制错误查询分页:结合
limit和offset分批获取近 7 天的错误任务,一次返回过多记录影响后台处理。