主题
keywords_data/errors:数据 API 错误任务
POST /v3/keywords_data/errors
本接口用于查询过去 7 天返回错误的数据 API 任务。HTTP 方法与路径如下:
POST https://api.seermartech.cn/v3/keywords_data/errors
如果任务了 webhook(Pingback 或 Postback),但由于服务器错误未收到回调,可通过本接口获取任务 ID,并使用 webhook 重发接口重新发送回调。
如果某个任务未出现在结果列表中,表示该任务未返回错误,或任务尚未完成。
计费说明
调用本接口不收费。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求
所有 POST 数据使用 UTF-8 编码的 JSON 格式,并以 JSON 数组提交:
json
[
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
]请求参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
limit | integer | 否 | 最多返回的错误任务数量。默认值为 1000,最大值为 1000。 |
offset | integer | 否 | 结果数组的偏移量。默认值为 0。例如设置为 10,则跳过前 10 个任务,返回后续任务。 |
filtered_function | string | 否 | 按 API 函数筛选错误任务。可使用响应中 function 字段的值进行筛选,例如 keywords_data/keywords_for_site/task_post、postback_url 或 pingback_url。 |
datetime_from | string | 否 | 错误时间筛选起始时间支持过去 7 天的数据。使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2021-11-15 12:57:46 +00:00。 |
datetime_to | string | 否 | 错误时间筛选结束时间支持过去 7 天的数据。使用 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/keywords_data/errors" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
]'PHP
php
<?php
$apiUrl = 'https://api.seermartech.cn';
$postData = [
[
'limit' => 10,
'offset' => 0,
'filtered_function' => 'pingback_url'
]
];
$ch = curl_init($apiUrl . '/v3/keywords_data/errors');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer smt_live_YOUR_KEY',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode($postData, JSON_UNESCAPED_UNICODE)
]);
$response = curl_exec($ch);
if ($response === false) {
echo '请求失败:' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);TypeScript
typescript
import axios from "axios";
const postData = [
{
limit: 10,
offset: 0,
filtered_function: "pingback_url",
},
];
axios
.post(
"https://api.seermartech.cn/v3/keywords_data/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/keywords_data/errors"
post_data = [
{
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url",
}
]
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
response = requests.post(url, json=post_data, headers=headers)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败。错误码:%s,错误信息:%s"
% (result.get("status_code"), result.get("status_message"))
)C#
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
public class ErrorTaskDemo
{
public static async Task Main()
{
using var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", "smt_live_YOUR_KEY");
var postData = new[]
{
new
{
limit = 10,
offset = 0,
filtered_function = "pingback_url"
}
};
var content = new StringContent(
JsonConvert.SerializeObject(postData),
Encoding.UTF8,
"application/json"
);
var response = await httpClient.PostAsync(
"https://api.seermartech.cn/v3/keywords_data/errors",
content
);
var resultText = await response.Content.ReadAsStringAsync();
dynamic result = JsonConvert.DeserializeObject(resultText);
if ((int)result.status_code == 20000)
{
Console.WriteLine(resultText);
}
else
{
Console.WriteLine(
$"请求失败。错误码:{result.status_code},错误信息:{result.status_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 | 创建任务时提交的参数,与 POST 请求中的参数一致。 |
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 函数名称。 |
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 响应,即服务器返回的响应。 |
响应示例
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": "00000000-0000-0000-0000-000000000000",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1000 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"keywords_data",
"errors"
],
"data": [
{
"api": "keywords_data",
"function": "errors",
"limit": 10,
"offset": 0,
"filtered_function": "pingback_url"
}
],
"result": [
{
"id": "11111111-1111-1111-1111-111111111111",
"datetime": "2021-11-15 13:20:00 +00:00",
"function": "pingback_url",
"error_code": 50001,
"error_message": "回调服务器返回错误",
"http_url": "https://example.com/pingback",
"http_method": "POST",
"http_code": 500,
"http_time": 0.842,
"http_response": "Internal Server Error"
}
]
}
]
}实用场景
- 检索过去 7 天失败的数据任务,定位批量任务异常并及时恢复业务数据。
- 按
pingback_url或postback_url筛选错误任务,排查回调服务器障并补发 webhook。 - 按
datetime_from和datetime_to缩小错误时间范围,分析特定发布时间段的接口稳定性。 - 按
filtered_function定位 API 函数的失败任务,评估采集、站点分析等模块的运行质量。 - 读取
http_code、http_response和http_time,区分客户端接口错误、回调服务错误与网络时问题。