Skip to content

获取 Google 商家问答已完成任务列表

GET /v3/business_data/google/questions_and_answers/tasks_ready

本接口用于获取尚未领取结果的 Google 商家问答已完成任务列表。

HTTP 方法与路径:

http
GET https://api.seermartech.cn/v3/business_data/google/questions_and_answers/tasks_ready

如果未设置 postback_url,可以通过本接口获取所有已完成任务的 id,然后使用「Task GET」接口获取对应任务结果。

接口路径

针对 Google 问答数据,可使用以下路径:

http
GET /v3/business_data/google/questions_and_answers/tasks_ready

也可以使用通用路径:

http
GET /v3/business_data/wp/questions_and_answers/tasks_ready
GET /v3/business_data/$se/tasks_ready
GET /v3/business_data/tasks_ready

$se 为搜索引擎名称。Google 问答数据的 se 固定为 google

> 已完成任务队列可能存在少量更新延迟。对于每分钟需要领取 1000 个任务的高并发场景,建议优使用 pingback 或 postback 机制。本接口可用于补获取 postback 失败任务的 ID。

计费与调用限制

  • 获取已完成任务列表不产生费用。
  • 每个任务会一直保留在列表中,直到被领取。
  • 每分钟最多调用本接口 20 次。
  • 每次调用最多返回过去 3 天完成的 1000 个任务。
  • 已经领取过的任务不会再次出现在列表中。
  • 完成后 3 天仍未领取的任务将从列表中移除。
  • 如果创建任务时设置了 postback_url,任务通常不会出现在已完成任务列表中。
  • 只有当平台向您的服务器推送失败,且服务器返回小于 200 或大于 300 的 HTTP 状态码时,该任务才可能出现在列表中。

本接口本身不产生任务费用;任务接口的扣费以响应头 X-SeerMarTech-Charge-CNY 为准。

请求参数

本接口无需请求参数。

请求示例

cURL

bash
curl --location --request GET \
  "https://api.seermartech.cn/v3/business_data/google/questions_and_answers/tasks_ready" \
  --header "Authorization: Bearer smt_live_YOUR_KEY" \
  --header "Content-Type: application/json"

PHP

php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => 'https://api.seermartech.cn/v3/business_data/google/questions_and_answers/tasks_ready',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer smt_live_YOUR_KEY',
        'Content-Type: application/json',
    ],
]);

$response = curl_exec($curl);

if ($response === false) {
    echo '请求失败:' . curl_error($curl);
} else {
    $result = json_decode($response, true);

    if (($result['status_code'] ?? 0) === 20000) {
        print_r($result);
    } else {
        echo '错误码:' . ($result['status_code'] ?? '') . PHP_EOL;
        echo '错误信息:' . ($result['status_message'] ?? '') . PHP_EOL;
    }
}

curl_close($curl);

Node.js

javascript
const request = require('request');

const options = {
  method: 'GET',
  url: 'https://api.seermartech.cn/v3/business_data/google/questions_and_answers/tasks_ready',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer smt_live_YOUR_KEY'
  }
};

request(options, (error, response) => {
  if (error) {
    throw new Error(error);
  }

  console.log(response.body);
});

Python

python
import requests

url = "https://api.seermartech.cn/v3/business_data/google/questions_and_answers/tasks_ready"

headers = {
    "Authorization": "Bearer smt_live_YOUR_KEY",
    "Content-Type": "application/json",
}

response = requests.get(url, headers=headers)

if response.ok:
    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 请求失败:", response.status_code, response.text)

C#

csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

public static class BusinessDataDemos
{
    public static async Task GetQuestionsAndAnswersTasksReady()
    {
        using var httpClient = new HttpClient();

        httpClient.DefaultRequestHeaders.Authorization =
            new AuthenticationHeaderValue("Bearer", "smt_live_YOUR_KEY");

        var response = await httpClient.GetAsync(
            "https://api.seermartech.cn/v3/business_data/google/questions_and_answers/tasks_ready"
        );

        var result = await response.Content.ReadAsStringAsync();

        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine(result);
        }
        else
        {
            Console.WriteLine($"HTTP 错误:{response.StatusCode}");
            Console.WriteLine(result);
        }
    }
}

响应说明

接口返回 JSON 对象 tasks 数组已完成但尚未领取的任务信息。

顶层字段

字段名类型说明
versionstring当前 API 版本
status_codeinteger响应状态码。完整状态码列表请参考错误码文档
status_messagestring响应状态说明
timestring请求执行耗时,单位为秒
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
tasks_countintegertasks 数组中的任务数量
tasks_errorintegertasks 数组中返回错误的任务数量
tasksarray已完成任务列表

tasks 数组字段

字段名类型说明
idstring任务唯一标识符,采用 UUID 格式
status_codeinteger任务状态码,通常位于 10000-60000 范围
status_messagestring任务状态说明
timestring任务执行耗时,单位为秒
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
result_countintegerresult 数组中的结果数量
patharray任务结果获取路径
dataobject创建任务时传的请求参数
resultarray任务结果数组

result 数组字段

字段名类型说明
idstring已完成任务的唯一标识符,采用 UUID 格式
se_typestring搜索引擎数据类型,Google 问答数据为 questions_and_answers
sestring创建任务时指定的搜索引擎,取值为 google
date_postedstring任务提交时间,采用 UTC 时间格式
tagstring用户自定义任务标识
endpointstring用于获取任务结果的 URL

响应示例

json
{
  "version": "0.1.20240422",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "0.1646 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "0.1200 sec.",
      "cost": 0,
      "result_count": 1,
      "path": [
        "v3",
        "business_data",
        "google",
        "questions_and_answers",
        "task_get",
        "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
      ],
      "data": {
        "se_type": "questions_and_answers",
        "se": "google",
        "api": "business_data",
        "function": "questions_and_answers"
      },
      "result": [
        {
          "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
          "se_type": "questions_and_answers",
          "se": "google",
          "date_posted": "2024-04-22 12:00:00 +00:00",
          "tag": "example-task",
          "endpoint": "/v3/business_data/google/questions_and_answers/task_get/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        }
      ]
    }
  ]
}

> 上述 id 和任务为示例。响应中的任务 ID、时间及结果数量会根据任务状态变化。

获取任务 ID 后,可通过以下接口领取任务结果:

http
GET /v3/business_data/google/questions_and_answers/task_get/{id}

{id} 替换为 tasks 数组中返回的任务 ID 或结果中的任务 ID。

错误处理

建议客户端根据顶层 status_codestatus_message 以及单个任务的 status_code 判断处理结果:

  • 20000:请求成功。
  • 状态码:表示请求或任务处理异常。
  • tasks_error 大于 0 时,说明部分任务返回了错误,应进一步检查对应任务的状态码和状态信息。

实用场景

  • 轮询已完成任务:定期获取尚未领取的任务 ID,确保异步采集结果不会遗漏。
  • 补偿 postback 失败任务:筛选推送失败的任务并重新获取结果,降低业务数据丢失风险。
  • 批量领取问答数据:按批次获取 Google 商家问答任务结果,为本地分析或数据仓库库提供稳定的数据来源。
  • 监控异步任务状态:结合 tasks_counttasks_error 和任务状态码监测采集链路健康度。
  • 构建任务调度队列:将已完成任务 ID 加后续处理队列,自动触发问答洗、分类和 SEO 分析。

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