主题
获取 Google Shopping Products 已完成任务列表
接口说明
Tasks Ready 接口用于获取已执行完成但尚未被获取结果的任务列表。
如果你使用标准投递方式创建任务,且没有设置 postback_url,即可通过本接口获取所有已完成任务的 id,再结合对应的 Task GET 结果接口拉取详细数据。
如需按搜索引擎维度获取已完成任务,也可以使用容路径:
GET /v3/merchant/google/products/tasks_readyGET /v3/merchant/$se/tasks_readyGET /v3/merchant/tasks_ready
当前页面对应的接口为:
GET https://api.seermartech.cn/v3/merchant/google/products/tasks_ready
使用说明
由于平台架构特性,已完成任务队列会有轻微延迟。如果你的系统需要每分钟采集 1000 个任务,建议优使用 pingback/postback 机制在以下场景使用 Tasks Ready 接口:
- 获取未创建
postback_url的已完成任务 ID - 排查 postback 投递失败的任务
- 补拉未及时消费的任务结果
如果任务设置了 postback_url,该任务通常不会出现在已完成任务列表中。只有当回调请求发送失败,且你的服务端返回的 HTTP 状态码小于 200 或大于 300 时,该任务才可能重新出现在列表中。
计费与限制
- 获取已完成任务列表不收费
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准 - 每分钟最多 20 次 API 调用
- 每次调用最多返回1000 个任务
- 返回最近 3 天完成且尚未被拉取的任务
- 已经成功拉取的任务,以及完成后 3 天未拉取的任务,不会出现在列表中
请求
HTTP 方法
GET
接口地址
text
https://api.seermartech.cn/v3/merchant/google/products/tasks_ready请求头
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
| Authorization | string | 是 | 认证信息,格式:Bearer smt_live_YOUR_KEY |
| Content-Type | string | 否 | 建议填写 application/json |
响应结构
接口返回 JSON 数据,顶层 tasks 数组,每个表示一次接口执行任务。
顶层字段
| 字段名 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本 |
status_code | integer | 通用状态码,完整列表见 /v3/appendix/errors |
status_message | string | 通用状态信息,完整列表见 /v3/appendix/errors |
time | string | 执行耗时,单位秒 |
cost | float | 本次请求总成本,单位 USD;本接口通常为 0 |
tasks_count | integer | tasks 数组中的任务数量 |
tasks_error | integer | tasks 数组中返回错误的任务数量 |
tasks | array | 任务数组 |
tasks[] 字段
| 字段名 | 类型 | 说明 |
|---|---|---|
id | string | 当前请求任务 ID,UUID 格式 |
status_code | integer | 任务状态码,取值范围通常为 10000-60000,完整列表见 /v3/appendix/errors |
status_message | string | 任务状态说明 |
time | string | 任务执行耗时,单位秒 |
cost | float | 当前任务成本,单位 USD |
result_count | integer | result 数组中的数量 |
path | array | URL 路径 |
data | object | 请求 URL 中传的参数信息 |
result | array | 已完成任务列表 |
tasks[].result[] 字段
| 字段名 | 类型 | 说明 |
|---|---|---|
id | string | 已完成任务的任务 ID,UUID 格式 |
se | string | 创建任务时指定的搜索引擎 |
se_type | string | 搜索引擎类型,例如 products |
date_posted | string | 任务提交时间,UTC 格式 |
tag | string | 用户自定义任务标识 |
endpoint_advanced | string | 获取 Google Shopping Products Advanced 结果的接口地址 |
endpoint_html | string | 获取 Google Shopping Products HTML 结果的接口地址 |
示例请求
cURL
bash
curl --location --request GET "https://api.seermartech.cn/v3/merchant/google/products/tasks_ready" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python
python
import requests
url = "https://api.seermartech.cn/v3/merchant/google/products/tasks_ready"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
# 获取已完成但尚未拉取的任务列表
response = requests.get(url, headers=headers)
data = response.json
if data.get("status_code") == 20000:
print(data)
else:
print(f"error. Code: {data.get('status_code')} Message: {data.get('status_message')}")TypeScript
typescript
import axios from "axios";
axios({
method: "get",
url: "https://api.seermartech.cn/v3/merchant/google/products/tasks_ready",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}).then((response) => {
// 返回结果数据
console.log(response.data);
}).catch((error) => {
console.error(error);
});示例响应
json
{
"version": "0.1.20200416",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.2543 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"data": {
"se_type": "shopping",
"api": "merchant",
"function": "products",
"se": "google"
},
"result": []
}
]
}状态码与异常处理
20000:请求成功- 状态码:表示请求参数、认证、额度或任务处理存在异常
完整错误码与状态说明请参考容错误码文档路径:
/v3/appendix/errors
建议在接时做好以下处理:
- 对非
20000的响应统一记录日志 - 针对空
result做无任务可拉取处理 - 针对高并发场景控制调用频率,每分钟 20 次限制
- 对 postback 失败任务建立补偿拉取机制
结果拉取建议
该接口只返回已完成任务的标识与结果地址,不直接返回完整商品结果数据。常见处理流程如下:
- 通过
GET /v3/merchant/google/products/tasks_ready获取已完成任务列表 - 从
result中提取任务id - 根据
endpoint_advanced或endpoint_html调用对应结果接口 - 成功获取结果后,将任务标记为已消费
实用场景
- 轮询已完成任务:在未回调通知时,定时获取已完成任务 ID,确保商品抓取结果能够被及时消费
- 补拉失败回调任务:当业务系统未成功接收 postback 时,通过本接口找回遗漏任务,数据丢失
- 构建结果消费队列:集中获取可用任务单,再异步调用结果接口,提升大批量商品数据处理效率
- 监控任务完成率:按时间窗口统计已完成任务数量,评估 Google Shopping 商品采集链路是否稳定
- 按标签追踪批次任务:结合
tag字段识别业务批次,便于区分不同国家站点、品类或项目的采集结果