主题
Google 自动补高级实时接口
POST /v3/serp/google/autocomplete/live/advanced
接口说明
POST https://api.seermartech.cn/v3/serp/google/autocomplete/live/advanced
Google 自动补可根据用户当前,返回搜索框中的推荐词。本接口支持指定、标位置、搜索语言、地区和搜索客户端,并返回对应的自动补建议及信息。
所有 POST 数据使用 UTF-8 编码的 JSON 格式提交,请求体为 JSON 数组。每次 Live SERP 平台限流以认证说明中的 30/60/120 次/分钟规则为准。
接口扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
###填及主要参数
| 参数 | 类型 | 说明 |
|---|---|---|
keyword | string | 填。 要查询的,最多 700 个字符。请求中的 %## 编码会被解码,字符 + 会被解码为空格。<br><br>如需在中使用 %,请编码为 %25;如需使用 +,请编码为 %2B。 |
location_code | integer | 搜索引擎地区代码。如果未指定 location_name,则提供此参数。可通过 GET /v3/serp/google/locations 获取可用地区及代码。示例:2840。 |
language_code | string | 搜索引擎语言代码。如果未指定 language_name,则提供此参数。提供此参数后,无需再提供 language_name。可通过 GET /v3/serp/google/languages 获取可用语言及代码。示例:en。 |
cursor_pointer | integer | 搜索框中的标位置,可选。表示标在中的水平位置。修改标位置后,同一可能返回不同的自动补建议。最小值为 0,默认值为所提供的最后一个字符位置。 |
cursor_pointer 示例:
| 搜索框状态 | 参数值 |
|---|---|
|which query are s | 0 |
which query is s| | 16 |
which que|ry is s | 9 |
参数
| 参数 | 类型 | 说明 |
|---|---|---|
location_name | string | 搜索引擎地区的完整名称。如果未指定 location_code,则提供此参数。提供此参数后,无需再提供 location_code。可通过 GET /v3/serp/google/autocomplete/locations 获取可用地区名称。示例:London,England,United Kingdom。 |
language_name | string | 搜索引擎语言的完整名称。如果未指定 language_code,则提供此参数。提供此参数后,无需再提供 language_code。可通过 GET /v3/serp/google/languages 获取可用语言名称。示例:English。 |
client | string | 自动补使用的搜索客户端。不同客户端可能返回不同的建议结果。 |
tag | string | 用户自定义任务标识,可选,最多 255 个字符。可用于识别任务并将请求与响应匹。提交的值会原样返回在响应任务的 data 对象中。 |
client 支持以下取值:
| 值 | 说明 |
|---|---|
chrome | 在 Chrome 浏览器中打开 Google 搜索时使用 |
chrome-omni | 在 Chrome 地址栏中使用 |
gws-wiz | 在 Google 搜索首页使用 |
gws-wiz-serp | 在 Google 搜索结果页使用 |
safari | 在 Safari 浏览器中打开 Google 搜索时使用 |
firefox | 在 Firefox 浏览器中打开 Google 搜索时使用 |
psy-ab | 可用于在 Chrome 浏览器中打开 Google 搜索时的场景 |
toolbar | 返回 XML 格式结果 |
youtube | 返回 JSONP 格式结果 |
gws-wiz-local | 用于 Google 本地搜索 |
img | 用于 Google 图片搜索 |
products-cc | 用于 Google 购物搜索 |
请求示例
cURL
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/serp/google/autocomplete/live/advanced" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein",
"cursor_pointer": 6,
"client": "gws-wiz-serp"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/google/autocomplete/live/advanced"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
# 每次请求只能提交一个任务
payload = [
{
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein",
"cursor_pointer": 6,
"client": "gws-wiz-serp",
}
]
response = requests.post(url, headers=headers, json=payload)
result = response.json()
if result.get("status_code") == 20000:
print(result)
else:
print(
"请求失败:代码=%s,消息=%s"
% (result.get("status_code"), result.get("status_message"))
)TypeScript
typescript
import axios from "axios";
const response = await axios.post(
"https://api.seermartech.cn/v3/serp/google/autocomplete/live/advanced",
[
{
language_code: "en",
location_code: 2840,
keyword: "albert einstein",
cursor_pointer: 6,
client: "gws-wiz-serp",
},
],
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
);
// 处理接口返回结果
console.log(response.data);响应结构
接口返回 JSON 数据,主体 tasks 数组。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前接口版本 |
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 | 任务结果数组 |
任务字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式 |
status_code | integer | 任务状态码,取值范围为 10000 至 60000 |
status_message | string | 任务状态说明 |
time | string | 任务执行耗时,单位为秒 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量 |
path | array | 请求路径 |
data | object | 请求中提交的参数 |
result | array | 自动补结果数组 |
result 字段
| 字段 | 类型 | 说明 |
|---|---|---|
keyword | string | 请求中提交的。返回时会解码 %## 编码,字符 + 会被解码为空格。 |
type | string | 请求中指定的搜索引擎类型 |
se_domain | string | 请求中指定的搜索引擎域名 |
location_code | integer | 搜索地区代码 |
language_code | string | 搜索语言代码 |
check_url | string | 搜索结果直接 URL,可用于核验返回结果的准确性 |
datetime | string | 获取结果的日期和时间,使用 UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。示例:2019-11-15 12:57:46 +00:00 |
spell | object | 搜索引擎自动纠错信息。如果搜索引擎对进行了纠正,将返回纠正后的及纠错类型;未发生纠错时通常为 null。 |
refinement_chips | object | 搜索细化选项 |
item_types | array | 搜索结果类型列表。此接口通常 autocomplete。 |
se_results_count | integer | 搜索结果总数 |
items_count | integer | items 数组中返回的结果数量 |
items | array | 自动补建议结果数组 |
refinement_chips 字段
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 素类型,固定为 refinement_chips |
xpath | string | 素的 XPath |
items | array | 搜索细化数组 |
refinement_chips.items 字段
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 素类型,固定为 refinement_chips_element |
title | string | 素标题 |
url | string | 含细化参数的搜索 URL |
domain | string | 搜索结果中的域名 |
options | array | 进一步的搜索细化选项 |
refinement_chips.items.options 字段
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 素类型,固定为 refinement_chips_option |
title | string | 选项标题 |
url | string | 含细化参数的搜索 URL |
domain | string | 搜索结果中的域名 |
items 字段
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 素类型,固定为 autocomplete |
rank_group | integer | 组排名。表示相同 type素中的位置,不同类型之间不计该排名。 |
rank_absolute | integer | 绝对排名,表示在搜索结果中的位置。 |
relevance | integer | 推荐词与目标的性,取值范围为 500 至 2000。数值越高,性越强。在 client 为 chrome 或 chrome-omni 时提供。 |
suggestion | string | Google 自动补推荐词 |
suggestion_type | string | Google 自动补推荐词类型。在 client 为 chrome 或 chrome-omni 时提供。 |
search_query_url | string | 与自动补推荐词对应的搜索结果 URL |
thumbnail_url | string | 推荐词缩略图 URL。在 client 为 gws-wiz 或 gws-wiz-serp 时提供。 |
highlighted | array | 搜索框中高亮显示的自动补列表。在 client 为 gws-wiz、psy-ab 或 gws-wiz-local 时提供。 |
响应示例
json
{
"version": "0.1.20240514",
"status_code": 20000,
"status_message": "Ok.",
"time": "2.0961 sec.",
"cost": 0.002,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "07081531-2806-0217-0000-9d8c7f6a5b4e",
"status_code": 20000,
"status_message": "Ok.",
"time": "1.8423 sec.",
"cost": 0.002,
"result_count": 1,
"path": [
"v3",
"serp",
"google",
"autocomplete",
"live",
"advanced"
],
"data": {
"api": "serp",
"function": "live",
"se": "google",
"se_type": "autocomplete",
"language_code": "en",
"location_code": 2840,
"keyword": "albert einstein",
"client": "gws-wiz-serp",
"device": "desktop",
"os": "windows"
},
"result": [
{
"keyword": "albert einstein",
"type": "autocomplete",
"se_domain": "google.com",
"location_code": 2840,
"language_code": "en",
"check_url": "https://www.google.com/search?q=albert+einstein",
"datetime": "2024-05-14 12:57:46 +00:00",
"spell": null,
"refinement_chips": null,
"item_types": [
"autocomplete"
],
"se_results_count": 0,
"items_count": 3,
"items": [
{
"type": "autocomplete",
"rank_group": 1,
"rank_absolute": 1,
"relevance": null,
"suggestion": "albert einstein biography",
"suggestion_type": null,
"search_query_url": "https://www.google.com/search?q=albert+einstein+biography",
"thumbnail_url": null,
"highlighted": null
},
{
"type": "autocomplete",
"rank_group": 2,
"rank_absolute": 2,
"relevance": null,
"suggestion": "albert einstein death",
"suggestion_type": null,
"search_query_url": "https://www.google.com/search?q=albert+einstein+death",
"thumbnail_url": null,
"highlighted": null
},
{
"type": "autocomplete",
"rank_group": 3,
"rank_absolute": 3,
"relevance": null,
"suggestion": "albert einstein quotes",
"suggestion_type": null,
"search_query_url": "https://www.google.com/search?q=albert+einstein+quotes",
"thumbnail_url": null,
"highlighted": null
}
]
}
]
}
]
}状态码与异常处理
请根据顶层 status_code 和任务级 status_code 判断请求是否成功。通常 20000 表示请求成功,状态码表示参数错误、任务执行异常或服务异常。
建议客户端同时处理以下:
- 顶层请求成功,但
tasks_error大于0; - 单个任务的
status_code非20000; result为空或result_count为0;- 请求时、网络连接失败或返回不是合法 JSON;
- 自动补结果因搜索客户端、地区、语言或标位置不同而发生变化。
实用场景
- 挖掘搜索联想词:批量获取目标的自动补建议,扩展 SEO选题和长尾库。
- 比较标位置差异:在同一的不同字符位置请求建议,识别用户过程中的多阶段搜索意图。
- 分析地区与语言偏好:按国家、城市和语言对比自动补结果,为本地 SEO 和化规划提供依据。
- 评估搜索客户端差异:比较 Chrome、Safari、搜索结果页等客户端返回的建议,优化不同下的覆盖。
- 发现主题:提取自动补中的人物、产品、问题和场景词,搭建集群与链接结构。