主题
提交 Google店信息任务
POST /v3/business_data/google/hotel_info/task_post
接口概述
POST https://api.seermartech.cn/v3/business_data/google/hotel_info/task_post
本接口用于提交 Google Hotels 平台的信息采集任务,返回指定的结构化数据服务描述、位置、评分、设施、评论、图片、价格等信息。
可通过以下任一方式指定:
- 使用唯一的
hotel_identifier。该标识可通过 Google SERP API 高级方法或 Business Data API 的搜索接口获取。 - 在
keyword中填写名称。
返回结果取决于指定的地点和语言。可用地点及语言分别参考:
计费与请求限制
提交任务会产生费用。参考价约 ¥0.0320 / 次;高优级任务会产生额外费用,启用 load_prices_by_dates=true 时按基础请求的 2 倍计费。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求使用 UTF-8 编码的 JSON 格式,整体请求体为 JSON 数组:
json
[
{
"location_code": 1023191,
"language_code": "en",
"hotel_identifier": "ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE"
}
]限制如下:
平台限流以认证说明中的 30/60/120 次/分钟规则为准。
- 每次请求最多 100 个任务。 -过 100 个任务的部分将返回错误码
40006。 - 可通过任务返回的
id查询任务结果。 - 也可以在提交时指定
postback_url或pingback_url,在任务完成后接收通知。 - 如果回调服务器在 10 秒未响应,连接将因时中断,任务会转“已就绪任务”列表。
请求参数
每个任务对象支持以下字段。
| 字段 | 类型 | 填 | 说明 |
|---|---|---|---|
hotel_identifier | string | 条件填 | Google 搜索中的实体唯一标识。指定此字段后无需填写 keyword。如果未指定 keyword,则此字段填。示例:ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE |
keyword | string | 条件填 | 店实体名称。指定此字段后无需填写 hotel_identifier。最多 700 个字符。所有 %## 编码会被解码,字符 + 会被解码为空格。如需在中使用百分号 %,请编码为 %25。如果同时指定 hotel_identifier 和 keyword,建议以 hotel_identifier 为准。 |
priority | integer | 否 | 任务优级。1:普通优级,默认值;2:高优级。高优级任务会产生额外费用。 |
location_name | string | 条件填 | 搜索地点的完整名称。未指定 location_code 和 location_coordinate 时填。指定后无需填写另外两个地点字段。示例:London,England,United Kingdom |
location_code | integer | 条件填 | 搜索地点编码。未指定 location_name 和 location_coordinate 时填。可通过 GET /v3/business_data/google/locations 获取。示例:2840 |
location_coordinate | string | 条件填 | GPS 坐标,格式为 纬度,经度,例如 53.476225,-2.243572。纬度和经度最多支持 7 位小数。使用坐标时,搜索将在距离该坐标最近的点执行。 |
language_name | string | 条件填 | 搜索语言的完整名称。未指定 language_code 时填。指定后无需填写 language_code。可通过 GET /v3/business_data/google/languages 获取。示例:English |
language_code | string | 条件填 | 搜索语言编码。未指定 language_name 时填。可通过 GET /v3/business_data/google/languages 获取。示例:en |
check_in | string | 否 | 住日期,格式为 yyyy-mm-dd。默认使用明天的日期,不能早于当天日期。示例:2019-01-15 |
check_out | string | 否 | 退房日期,格式为 yyyy-mm-dd。默认使用后天日期。不能早于或等于 check_in,且与退房日期的间隔不得 30 天。示例:2019-01-15 |
currency | string | 否 | 价格币种。示例:USD |
adults | integer | 否 | 成人数量,默认值为 2。示例:1 |
children | array | 否 | 儿童年龄数组。不指定时表示不儿童。例如,1 名 14 岁儿童:[14];1 名 13 岁和 1 名 8 岁儿童:[13, 8]。 |
load_prices_by_dates | boolean | 否 | 是否按日期加载住宿价格。设为 true 后,响应中将返回按日期拆分的 prices_by_dates 数组,并按基础请求的 2 倍计费。 |
prices_start_date | string | 否 | 按日期加载价格的起始日期。在 load_prices_by_dates=true 时使用。未指定时默认使用 check_in。格式:yyyy-mm-dd。示例:2025-05-20 |
prices_end_date | string | 否 | 按日期加载价格的结束日期。在 load_prices_by_dates=true 时使用。未指定时返回按日期划分的一个月价格。格式:yyyy-mm-dd。示例:2025-05-21 |
prices_date_range | string | 否 | 获取每日价格的预定义周期。在 load_prices_by_dates=true 时使用。可选值:month、three_months、six_months、year。默认值:month。如果未指定 prices_start_date,起始日期使用 check_in。 |
tag | string | 否 | 自定义任务标识,最多 255 个字符。可用于任务和结果,提交的值会出现在响应的 data 对象中。 |
postback_url | string | 否 | 接收任务结果的 URL。任务完成后,本平台会以 POST 请求向该地址发送 gzip 压缩的结果。URL 中可使用 $id 和 $tag 占位符,发送前会替换为任务 ID 和经过 URL 编码的标签。示例:https://your-server.com/postbackscript?id=$id&tag=$tag。特殊字符会进行 URL 编码,例如 # 会编码为 %23。 |
postback_data | string | 条件填 | 指定 postback_url 时填。用于指定发送到服务器的数据类型。可选值:advanced、html。 |
pingback_url | string | 否 | 任务完成通知 URL。任务完成后,本平台会向该地址发送 GET 请求。支持 $id 和 $tag 占位符,例如:https://your-server.com/pingscript?id=$id&tag=$tag。特殊字符会进行 URL 编码。 |
地点参数互斥
以下三组字段至少指定一组,且每个任务只能使用一种:
location_namelocation_codelocation_coordinate
语言参数互斥
以下两个字段至少指定一个:
language_namelanguage_code
###店标识参数互斥
以下两个字段至少指定一个:
hotel_identifierkeyword
认证方式
请求头使用 Bearer Token:
http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json请求示例
curl
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/business_data/google/hotel_info/task_post" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"location_code": 1023191,
"language_code": "en",
"hotel_identifier": "ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE"
},
{
"location_name": "New York,New York,United States",
"language_name": "English",
"hotel_identifier": "ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE",
"priority": 2,
"tag": "some_string_123",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/business_data/google/hotel_info/task_post"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
post_data = [
{
"location_code": 1023191,
"language_code": "en",
"hotel_identifier": "ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE",
},
{
"location_name": "New York,New York,United States",
"language_name": "English",
"hotel_identifier": "ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE",
"priority": 2,
"tag": "some_string_123",
# 任务完成后,本平台会向该地址发送 GET 请求
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag",
},
]
response = requests.post(url, headers=headers, json=post_data)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败,错误码:{},错误信息:{}".format(
result.get("status_code"),
result.get("status_message"),
)
)TypeScript
typescript
import axios from "axios";
const postData = [
{
location_code: 1023191,
language_code: "en",
hotel_identifier: "ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE",
},
{
location_name: "New York,New York,United States",
language_name: "English",
hotel_identifier: "ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE",
priority: 2,
tag: "some_string_123",
// 任务完成后,本平台会向该地址发送 GET 请求
pingback_url: "https://your-server.com/pingscript?id=$id&tag=$tag",
},
];
axios
.post(
"https://api.seermartech.cn/v3/business_data/google/hotel_info/task_post",
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);
});响应说明
接口返回 JSON 数据,顶层 tasks 数组。提交任务成功后,任务对象中的 result 为 null;任务完成后,可通过任务 ID 获取信息结果。
顶层响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求整体状态码。完整错误码请参考 /v3/appendix/errors。 |
status_message | string | 请求整体状态信息。 |
time | string | 请求执行耗时,例如 0.2609 sec.。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务总数。 |
tasks_error | integer | tasks 数组中返回错误的任务数量。 |
tasks | array | 已提交任务的详细信息。 |
任务字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 本平台生成的唯一任务 ID,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 | 请求 URL 路径信息。 |
data | object | 提交任务时使用的参数。 |
result | array | 任务结果数组。提交任务接口返回时为 null。 |
成功响应示例
json
{
"version": "0.1.20210430",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.2609 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"status_code": 20100,
"status_message": "Task Created.",
"time": "0.0123 sec.",
"cost": 0,
"result_count": 0,
"path": [
"v3",
"business_data",
"google",
"hotel_info",
"task_post"
],
"data": {
"api": "business_data",
"function": "hotel_info",
"se": "google",
"language_code": "en",
"location_name": "New York,New York,United States",
"hotel_identifier": "ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE",
"tag": "some_string_123",
"postback_url": "https://your-server.com/postbackscript.php",
"postback_data": "advanced",
"se_type": "hotel_info",
"device": "desktop",
"os": "windows"
},
"result": null
}
]
}错误处理
建议客户端同时检查以下状态:
- 顶层
status_code是否为20000。 tasks_error是否大于0。- 每个任务对象中的
status_code和status_message。 - 请求任务数量是否每次 100 个的限制。
hotel_identifier与keyword是否至少指定一个。- 地点和语言参数是否满足互斥字段要求。
check_out是否晚于check_in,且日期间隔不 30 天。- 使用
postback_url时是否同时指定postback_data。
完整错误码和状态信息请参考 /v3/appendix/errors。
实用场景
- 采集指定的评分、设施和评论,构建竞品数据库,支持竞品定位与服务差异分析。
- 按目标城市和语言批量获取信息,建立本地化目录,支持平台或聚合页面建设。
- 查询指定日期的价格,比较不同及不同日期的价格变化,动态定价和促销策略制定。
- 启用按日期价格明细获取未来价格趋势,分析旺季、淡季和节假日价格波动,优化 SEO与商业决策。
- 使用
pingback_url或postback_url接收任务完成通知,将数据自动同步到数据库、报表系统或竞品监控平台。