主题
创建 Google Hotel Info 任务
/v3/business_data/google/hotel_info/task_post 用于提交采集任务。接口会返回指定实体在 Google Hotels 中可获取的结构化信息,例如服务说明、地理位置、评分、设施、评论、图片、价格等。
你可以通过以下任一方式指定目标:
- 使用
hotel_identifier指定唯一标识; - 或使用
keyword直接传名称。
,hotel_identifier 可通过以下接口获取:
/v3/serp/google/organic/overview/的高级结果;/v3/business_data/google/hotel_searches/task_post/的搜索结果。
返回会受到所选地点和语言参数影响,因此创建任务时指定对应设置。
接口信息
请求方式: POST接口地址: https://api.seermartech.cn/v3/business_data/google/hotel_info/task_post
计费说明
创建任务即会产生扣费。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
价格:
- 普通任务:按单次任务计费;
- 高优级任务(
priority=2):会额外加价; - 若启用
load_prices_by_dates=true:该请求按基础价格的 2 倍计费。
文档原文未给出明确单价,因此此处不展示人民币参考价。扣费请以接口响应中的
cost字段为准。
请求说明
- 请求体为 UTF-8 编码的 JSON;
- POST 请求体格式为 JSON 数组:
[{ ... }] - 单次 POST 最多可提交 100 个任务;
- 接口速率上限为 每分钟 2000 次 API 调用;
- 若单次 POST含 100 个任务,出部分会返回错误码
40006。
任务创建后,你可以:
- 使用返回的任务
id轮询结果; - 或在创建任务时设置
postback_url/pingback_url,由系统在任务完成后主动回调。
若你的回调服务器在 10 秒未响应,请求会因时中断,任务随后会
/v3/business_data/google/hotel_info/tasks_ready/列表,供你后续主动获取结果。
请求参数
任务级字段说明
| 字段名 | 类型 | 说明 |
|---|---|---|
hotel_identifier | string | 店唯一标识。若未传 keyword,则该字段填;如果传了该字段,则无需再传 keyword。该值是 Google 搜索中的实体唯一 ID,可从 /v3/serp/google/organic/overview/ 返回结果中的 hotels_pack素,或 /v3/business_data/google/hotel_searches/task_post/ 获取。示例:ChYIq6SB--i6p6cpGgovbS8wN2s5ODZfEAE |
keyword | string | 店名称。若未传 hotel_identifier,则该字段填;如果传了该字段,则无需再传 hotel_identifier。最长支持 700 个字符。所有 %## 会被解码,+ 会被解码为空格;如需传递字面量 %,请写为 %25。 |
priority | integer | 任务优级,可选。取值:1 = 普通优级(默认),2 = 高优级。高优级任务会额外收费。 |
location_name | string | 搜索位置名。若未传 location_code 或 location_coordinate,该字段填;如果传了该字段,则无需再传 location_code 或 location_coordinate。可通过 /v3/business_data/google/locations 获取可用地点列表。示例:London,England,United Kingdom |
location_code | integer | 搜索位置编码。若未传 location_name 或 location_coordinate,该字段填;如果传了该字段,则无需再传 location_name 或 location_coordinate。可通过 /v3/business_data/google/locations 获取。示例:2840 |
location_coordinate | string | 地理坐标位置。若未传 location_name 或 location_code,该字段填;如果传了该字段,则无需再传 location_name 或 location_code。格式:latitude,longitude,纬度和经度最多 7 位小数。使用坐标时,系统会在最近的聚地执行搜索。示例:53.476225,-2.243572 |
language_name | string | 搜索语言名。若未传 language_code,则该字段填;如果传了该字段,则无需再传 language_code。可通过 /v3/business_data/google/languages 获取。示例:English |
language_code | string | 搜索语言编码。若未传 language_name,则该字段填;如果传了该字段,则无需再传 language_name。可通过 /v3/business_data/google/languages 获取。示例:en |
check_in | string | 住日期,可选。默认取明天。不能早于当天。格式:yyyy-mm-dd。示例:2019-01-15 |
check_out | string | 退房日期,可选。默认取后天。严格大于 check_in,且与 check_in 的间隔不能 30 天。格式:yyyy-mm-dd。示例:2019-01-15 |
currency | string | 货币代码,可选。示例:USD |
adults | integer | 成人数量,可选。默认值为 2。示例:1 |
children | array | 儿童年龄数组,可选。默认不儿童。该字段用于传递儿童人数及年龄。示例:一个 14 岁儿童可传 [14];一个 13 岁儿童和一个 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。如果未指定 prices_start_date,则开始日期默认取 check_in。可选值:month、three_months、six_months、year。默认:month |
tag | string | 自定义任务标识,可选。最长 255 字符。可用于将任务与业务系统中的记录,返回结果会在 data 对象中原样返回该值。 |
postback_url | string | 结果回调地址,可选。任务完成后,系统会将结果以 gzip 压缩的 POST 请求发送到该地址。支持在 URL 中使用 $id 和 $tag 变量,发送时会自动替换。示例:http://your-server.com/postbackscript?id=$id、http://your-server.com/postbackscript?id=$id&tag=$tag。注意:URL 中特殊字符会进行 URL 编码,例如 # 会编码为 %23。 |
postback_data | string | 回调数据类型。若传了 postback_url,该字段填。可选值:advanced、html |
pingback_url | string | 任务完成通知地址,可选。任务完成后,系统会向该地址发送 GET 请求。支持在 URL 中使用 $id 和 $tag 变量,发送时会自动替换。示例:http://your-server.com/pingscript?id=$id、http://your-server.com/pingscript?id=$id&tag=$tag。注意:URL 中特殊字符会进行 URL 编码。 |
响应说明
接口返回 JSON 数据,顶层 tasks 数组,用于描述本次提交的任务结果。
顶层响应字段
| 字段名 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本 |
status_code | integer | 接口通用状态码,完整列表参考 /v3/appendix/errors |
status_message | string | 接口通用状态信息 |
time | string | 执行耗时,单位秒 |
cost | float | 本次请求总费用,单位 USD |
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 |
result_count | integer | result 数组中的数量 |
path | array | 请求路径 |
data | object | 你提交的任务参数回显 |
result | array | 结果数组。对于任务提交接口,此处通常为 null |
建议在业务系统中对
status_code和tasks_error建立完整的异常处理机制。
请求示例
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 请求体为 JSON 数组
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",
"pingback_url": "https://your-server.com/pingscript?id=$id&tag=$tag"
}
]
response = requests.post(url, headers=headers, json=data)
print(response.json)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",
pingback_url: "https://your-server.com/pingscript?id=$id&tag=$tag"
}
];
axios({
method: "post",
url: "https://api.seermartech.cn/v3/business_data/google/hotel_info/task_post",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
},
data: postData
})
.then((response) => {
// 输出任务提交结果
console.log(response.data);
})
.catch((error) => {
console.error(error);
});响应示例
json
{
"version": "0.1.20210430",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.2609 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"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
}
]
}使用建议
- 如果你已经通过搜索接口拿到了
hotel_identifier,优使用该字段,匹更稳定; - 如果知道名称,可用
keyword创建任务,但名称歧义可能影响结果准确性; - 当你需要对未来一段时间的价格波动做分析时,可启用
load_prices_by_dates=true; - 若需要更快返回结果,可使用
priority=2,但会增加成本; - 批量提交时请严格控制单次请求任务数不 100。
常见错误与限制
| 场景 | 说明 |
|---|---|
| 单次 POST过 100 个任务 | 出部分返回 40006 |
| 未同时传参数 | hotel_identifier 与 keyword 至少提供一个 |
| 未同时传位置参数 | location_name、location_code、location_coordinate 至少提供一个 |
| 未同时传语言参数 | language_name 与 language_code 至少提供一个 |
check_out <= check_in | 参数非法 |
check_in 与 check_out 相差 30 天 | 参数非法 |
设置 postback_url 但未设置 postback_data | 参数不完整 |
使用价格按日加载参数但未设置 load_prices_by_dates=true | 参数组合无效 |
实用场景
- 采集页数据:获取单家的评分、设施、图片、评论等结构化信息,用于构建资料库或落地页增强。
- 监控区域价格变化:按日期范围抓取每日价格,分析价格波动趋势,为行业投放和价格策略提供依据。
- 补实体识别信息:基于
hotel_identifier拉取标准化数据,提升本地生活、聚合、地图类产品中的实体匹准确率。 - 比对多地区展示差异:切换
location_code或location_coordinate,观察同一在不同地区下的展示信息和价格差异,支持化运营分析。 - 自动化任务回调处理:结合
pingback_url或postback_url,在任务完成后自动接收结果并库,降低轮询成本并提升数据链路时效性。