主题
设置 Trustpilot 商家评论任务
POST /v3/business_data/trustpilot/reviews/task_post
本接口用于创建 Trustpilot 商家评论采集任务,获取 domain 指定商家的评论数据。
POST /v3/business_data/trustpilot/reviews/task_post
domain须对应 Trustpilot 上已存在的商家。该值通常位于商家页面 URL 的 /review/ 后方,例如:
text
https://www.trustpilot.com/review/www.thepearlsource.com对应的 domain 为:
text
www.thepearlsource.com每返回最多 20 条评论计费一次。例如,设置 "depth": 21 时,系统将按 40 条评论计费。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求说明
- 请求方法:
POST - 请求路径:
/v3/business_data/trustpilot/reviews/task_post - 请求格式:JSON,UTF-8 编码
- 请求体:JSON 数组
- 单次请求最多 100 个任务
- 每分钟最多提交 30 次请求
- 单次请求 100 个任务时,出部分将返回错误码
40006 - 创建任务后,可通过返回的任务
id查询结果 - 也可以通过
postback_url或pingback_url接收任务完成通知
如果回调服务器在 10 秒未响应,连接将因时中断,任务会转任务就绪列表。错误码和错误信息取决于回调服务器的。
计费说明
系统会根据以下两项计费:
- 创建任务;
items数组中返回的评论数量,按每 20 条评论为一个计费单位。
设置 priority: 2 的高优级任务会产生额外费用。人民币扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
请求体中的每个数组代表一个任务。
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
domain | string | 是 | Trustpilot 商家域名。可从商家页面 URL 中获取,例如 www.thepearlsource.com。 |
sort_by | string | 否 | 评论排序方式。可选值:recency:按最新评论优;relevance:按性排序。默认值为 relevance。 |
priority | integer | 否 | 任务优级。1:普通优级,默认值;2:高优级,处理速度更快但会产生额外费用。 |
depth | integer | 否 | 请求返回的评论数量。默认值为 20,最大值为 200。建议设置为 20 的倍数,因为系统按每批 20 条评论处理。 |
tag | string | 否 | 用户自定义任务标识,最长 255 个字符。该值会原样返回在响应的 data 对象中。 |
postback_url | string | 否 | 任务完成后接收结果的回调地址。本平台会向该地址发送任务结果的 gzip 压缩 POST 请求。 |
pingback_url | string | 否 | 任务完成通知地址。任务完成后,本平台会向该地址发送 GET 请求。 |
depth 计费规则
系统按每 20 条评论为一个计费单位:
depth: 20:最多按 20 条评论计费;depth: 40:最多按 40 条评论计费;depth: 21:将按 40 条评论计费。
最终返回数量取决于商家页面可获取的评论数量。
回调地址变量
postback_url 和 pingback_url 支持以下变量:
$id:任务唯一 ID;$tag:经过 URL 编码的任务标签。
例如:
text
https://your-server.com/postbackscript?id=$id&tag=$tag任务完成后,变量会被替换为值。
回调地址中的特殊字符会进行 URL 编码。例如,# 会被编码为 %23。
请求示例
cURL
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/business_data/trustpilot/reviews/task_post" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"domain": "www.thepearlsource.com"
},
{
"domain": "www.thepearlsource.com",
"depth": 40,
"priority": 2,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
},
{
"domain": "www.thepearlsource.com",
"postback_url": "https://your-server.com/postbackscript"
}
]'PHP
php
<?php
$apiUrl = 'https://api.seermartech.cn';
$postArray = [
// 简单创建任务
[
'domain' => 'www.thepearlsource.com'
],
// 使用附加参数创建任务
[
'domain' => 'www.thepearlsource.com',
'depth' => 40,
'priority' => 2,
'tag' => 'some_string_123',
'pingback_url' => 'https://your-server.com/pingscript?id=$id&tag=$tag'
],
// 使用 postback_url 接收任务结果
[
'domain' => 'www.thepearlsource.com',
'postback_url' => 'https://your-server.com/postbackscript'
]
];
$ch = curl_init($apiUrl . '/v3/business_data/trustpilot/reviews/task_post');
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($postArray, JSON_UNESCAPED_SLASHES)
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);TypeScript
typescript
import axios from "axios";
const postArray = [
{
domain: "www.thepearlsource.com",
},
{
domain: "www.thepearlsource.com",
depth: 40,
priority: 2,
tag: "some_string_123",
pingback_url:
"https://your-server.com/pingscript?id=$id&tag=$tag",
},
{
domain: "www.thepearlsource.com",
postback_url: "https://your-server.com/postbackscript",
},
];
axios
.post(
"https://api.seermartech.cn/v3/business_data/trustpilot/reviews/task_post",
postArray,
{
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/business_data/trustpilot/reviews/task_post"
post_data = [
# 简单创建任务
{
"domain": "www.thepearlsource.com"
},
# 使用优级、标签和 pingback_url
{
"domain": "www.thepearlsource.com",
"depth": 40,
"priority": 2,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
},
# 使用 postback_url 接收任务结果
{
"domain": "www.thepearlsource.com",
"postback_url": "https://your-server.com/postbackscript"
}
]
response = requests.post(
url,
json=post_data,
headers={
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"错误。状态码:%s,信息:%s"
% (result.get("status_code"), result.get("status_message"))
)响应说明
接口返回 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 数组中的数量。创建任务接口通常为 0。 |
path | array | 请求路径信息。 |
data | object | 创建任务时提交的参数。 |
result | array | null | 任务结果。创建任务成功后通常为 null,需通过任务 ID 查询结果。 |
响应示例
json
{
"version": "0.1.20210917",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0676 sec.",
"cost": 0.00075,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0450 sec.",
"cost": 0.00075,
"result_count": 0,
"path": [
"v3",
"business_data",
"trustpilot",
"reviews",
"task_post"
],
"data": {
"api": "business_data",
"function": "reviews",
"se": "trustpilot",
"domain": "www.thepearlsource.com",
"language_name": "English",
"language_code": "en",
"location_name": "United States",
"device": "desktop",
"os": "windows"
},
"result": null
}
]
}错误处理
建议根据请求级和任务级状态码分别处理异常:
status_code = 20000:请求或任务处理成功;tasks_error > 0:至少有一个任务执行失败;40006:单次请求提交的任务数 100 个。
错误码和状态信息请参考 /v3/appendix/errors。
实用场景
- 采集竞品商家的 Trustpilot 评论:批量获取竞品评论和评价排序,为口碑分析、竞品研究和产品改进提供依据。
- 监测品牌评论变化:定期提交商家评论任务,跟踪最新评论和整体评价趋势,及时发现声誉风险。
- 构建本地商家口碑数据库:按商家域名批量采集评论,沉淀可用于 SEO 页面、门店分析和客户洞察的数据资产。
- 筛选最新评论或高评论:通过
sort_by控制返回顺序,优获取最新反馈或与商家度更高的评论。 - 自动化接收评论采集结果:
postback_url或pingback_url,在任务完成后自动触发数据库、告警或分析流程。