主题
Google Trends 地理位置列表
GET /v3/keywords_data/google_trends/locations
接口说明
本接口提供 Google Trends 支持的地理位置列表,可用于在创建趋势任务时获取和校验位置参数。
- 方法:
GET - 接口路径:
/v3/keywords_data/google_trends/locations - 按国家筛选:
/v3/keywords_data/google_trends/locations/$country - 完整请求地址:
https://api.seermartech.cn/v3/keywords_data/google_trends/locations
> 注意:由于服务政策调整,俄罗斯和白俄罗斯境的地理位置目前不再受支持。
计费说明
调用本接口当前不扣费。
如计费策略发生调整,扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
路径参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
country | string | 否 | 用于筛选地理位置的国家或地区 ISO 代码,例如 us。该参数作为 URL 路径的一部分传。 |
请求示例
查询支持的地理位置:
text
GET /v3/keywords_data/google_trends/locations查询美国境的地理位置:
text
GET /v3/keywords_data/google_trends/locations/us响应字段
接口返回 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 数组中的数量。 |
path | array | 请求使用的 URL 路径。 |
data | object | 请求 URL 中传的参数和接口信息。 |
result | array | 地理位置结果数组。 |
data 字段
| 字段 | 类型 | 说明 |
|---|---|---|
api | string | API 模块名称,通常为 keywords_data。 |
function | string | 接口名称,通常为 locations。 |
se | string | 搜索引擎或数据源名称,通常为 google_trends。 |
result 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
location_code | integer | 本平台地理位置编码。 |
location_name | string | 地理位置完整名称。 |
location_code_parent | integer | 上级地理位置编码。 |
country_iso_code | string | 该地理位置所属国家或地区的 ISO 代码。 |
location_type | string | 地理位置类型,取值遵循 Google Ads 地理定位类型定义。 |
geo_name | string | Google Trends 使用的地理位置名称,可用于匹请求中的 location_name。 |
geo_id | string | Google Trends 地理位置标识,可用于匹请求中的 location_code。 |
上下级位置示例
json
{
"location_code": 9041134,
"location_name": "Vienna International Airport,Lower Austria,Austria",
"location_code_parent": 20044
},location_code_parent 对应的上级位置可能为:
json
{
"location_code": 20044,
"location_name": "Lower Austria,Austria"
}curl 请求示例
bash
curl --location \
--request GET "https://api.seermartech.cn/v3/keywords_data/google_trends/locations" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"按国家筛选:
bash
curl --location \
--request GET "https://api.seermartech.cn/v3/keywords_data/google_trends/locations/us" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python 请求示例
python
import requests
url = "https://api.seermartech.cn/v3/keywords_data/google_trends/locations"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
result = response.json()
if result.get("status_code") == 20000:
for task in result.get("tasks", []):
for location in task.get("result", []):
print(
location.get("location_code"),
location.get("location_name"),
location.get("geo_id"),
)
else:
print(
"请求失败,状态码:{},信息:{}".format(
result.get("status_code"),
result.get("status_message"),
)
)TypeScript 请求示例
typescript
const url =
"https://api.seermartech.cn/v3/keywords_data/google_trends/locations";
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
});
const result = await response.json();
if (result.status_code === 20000) {
for (const task of result.tasks ?? []) {
for (const location of task.result ?? []) {
console.log({
locationCode: location.location_code,
locationName: location.location_name,
geoId: location.geo_id,
});
}
}
} else {
console.error(
`请求失败,状态码:${result.status_code},信息:${result.status_message}`,
);
}响应示例
json
{
"version": "0.1.20210917",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1012 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "7f6f8e8e-1e3d-4e90-9c3c-123456789abc",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0450 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"keywords_data",
"google_trends",
"locations"
],
"data": {
"api": "keywords_data",
"function": "locations",
"se": "google_trends"
},
"result": [
{
"location_code": 20044,
"location_name": "Lower Austria,Austria",
"location_code_parent": 20000,
"country_iso_code": "AT",
"location_type": "Administrative Area",
"geo_name": "Lower Austria",
"geo_id": "20044"
}
]
}
]
}状态码
接口使用通用请求级和任务级状态码。成功时通常返回:
| 状态码 | 说明 |
|---|---|
20000 | 请求成功。 |
如需处理状态码,请根据 status_code 和 status_message 判断请求级或任务级错误。
实用场景
- 获取国家或地区位置编码:在创建 Google Trends 任务前校验
location_code和geo_id,因位置参数无效导致任务失败。 - 按国家构建位置下拉选项:通过
/locations/$country获取指定国家的城市、省州或行政区,支持 SEO 工中的地域筛选功能。 - 匹 Google Trends 地理名称:使用
geo_name与业务系统中的地区名称建立映射,统一不同数据源的地域命名。 - 构建地域分析矩阵:遍历多个地理位置编码,批量比较在不同城市或地区的趋势表现,为本地 SEO 和区域策略提供依据。
- 维护位置主数据:定期同步接口返回的地理位置层级,更新 SEO 报告、市场覆盖范围和区域投放。