主题
趋势支持地区列表
接口说明
获取趋势接口支持的地区列表。
注意:由于地缘政策限制,俄罗斯和白俄罗斯的所有地区在本平台服务中均不再支持。
本接口支持以下两种请求方式:
GET /v3/keywords_data/dataforseo_trends/locationsGET /v3/keywords_data/dataforseo_trends/locations/$country
$country 为国家 ISO 代码,用于按国家筛选地区列表,例如 us。
该接口常用于在创建趋势分析任务前,查询可用的地理范围。需要注意:
- 趋势接口支持的最小地理粒度为国家级
- 即使返回结果中更细的地区信息,任务设置时应以接口支持范围为准
计费说明
本接口不收费。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准;该接口通常返回 0。
请求地址
获取支持地区
GET https://api.seermartech.cn/v3/keywords_data/dataforseo_trends/locations
按国家筛选地区
GET https://api.seermartech.cn/v3/keywords_data/dataforseo_trends/locations/$country
示例:
GET https://api.seermartech.cn/v3/keywords_data/dataforseo_trends/locations/us
路径参数
| 字段 | 类型 | 说明 |
|---|---|---|
country | string | 可选。国家 ISO 代码;传后返回该国家下的支持地区。示例:us |
响应结构
接口返回 JSON 数据,顶层 tasks 数组保存本次请求的任务结果。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本 |
status_code | integer | 接口整体状态码;完整错误码见 /v3/appendix/errors |
status_message | string | 接口整体状态信息;完整说明见 /v3/appendix/errors |
time | string | 接口执行耗时,单位秒 |
cost | float | 本次请求总成本,单位 USD |
tasks_count | integer | tasks 数组中的任务数量 |
tasks_error | integer | tasks 数组中返回错误的任务数量 |
tasks | array | 任务结果数组 |
tasks[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式 |
status_code | integer | 任务状态码,范围通常为 10000-60000;完整错误码见 /v3/appendix/errors |
status_message | string | 任务状态说明 |
time | string | 任务执行耗时,单位秒 |
cost | float | 任务成本,单位 USD |
result_count | integer | result 数组中的数量 |
path | array | 当前请求对应的 URL 路径 |
data | object | GET 请求 URL 中携带的参数信息 |
result | array | 返回的地区结果列表 |
result[] 字段
| 字段 | 类型 | 说明 |
|---|---|---|
location_code | integer | 地区编码 |
location_name | string | 地区完整名称 |
location_code_parent | integer | 上级地区编码 |
country_iso_code | string | 地区所属国家的 ISO 代码 |
location_type | string | 地区类型;枚举参考 Google 地理定向类型 |
geo_name | string | 趋势接口使用的地区名称,可用于与请求中的 location_name 参数进行匹 |
geo_id | string | 趋势接口使用的地区标识,可用于与请求中的 location_code 参数进行匹 |
上下级地区示例
json
{
"location_code": 9041134,
"location_name": "Vienna International Airport,Lower Austria,Austria",
"location_code_parent": 20044
}location_code_parent = 20044 对应的上级地区可能为:
json
{
"location_code": 20044,
"location_name": "Lower Austria,Austria"
}认证方式
请求头统一使用 Bearer Token:
http
Authorization: Bearer smt_live_YOUR_KEY请求示例
cURL
bash
curl --location --request GET "https://api.seermartech.cn/v3/keywords_data/dataforseo_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/dataforseo_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/dataforseo_trends/locations"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
result = response.json
if result.get("status_code") == 20000:
print(result)
else:
print(f"error. Code: {result.get('status_code')} Message: {result.get('status_message')}")TypeScript
typescript
import axios from "axios";
// 获取趋势支持地区列表
axios({
method: "get",
url: "https://api.seermartech.cn/v3/keywords_data/dataforseo_trends/locations",
headers: {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
}).then(function (response) {
const result = response.data;
console.log(result);
}).catch(function (error) {
console.log(error);
});响应示例
json
{
"version": "0.1.20210917",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1012 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"data": {
"api": "keywords_data",
"function": "locations",
"se": "dataforseo_trends"
},
"result": []
}
]
}状态码说明
| 字段 | 说明 |
|---|---|
20000 | 请求成功 |
| 状态码 | 请参考 /v3/appendix/errors |
建议同时检查以下字段:
- 顶层
status_code:判断整个请求是否成功 tasks[].status_code:判断单个任务是否成功tasks_error:判断是否存在任务级错误
使用建议
- 在发起趋势任务前,调用本接口校验地区是否受支持
- 若业务面向单一国家,建议使用
/locations/$country形式减少返回数据量 - 使用
geo_name与geo_id可帮助将地区列表与后续查询参数做映射 - 若需要建立本地地区字,可定期同步本接口返回结果
实用场景
- 校验投放国家:在创建趋势分析任务前检查目标国家是否受支持,任务提交失败或返回空结果
- 构建地区映射表:同步
location_code、geo_id、geo_name到本地数据库,便于前端下拉框和参数统一映射 - 限制用户可选范围:在 SaaS 后台中展示可用国家/地区选项,降低运营错误率
- 匹历史任务参数:利用
geo_name和geo_id将历史趋势数据与当前地区主数据对齐,提升报表一致性 - 监控地区可用性变化:定期拉取支持地区列表,识别新增、下线或受限市场,及时调整 SEO 研究范围