主题
百度 SERP 地点列表
GET /v3/serp/baidu/locations
本接口用于获取百度 SERP 支持的地点列表,可按国家或地区 ISO 代码筛选。
HTTP 方法与路径:
GET /v3/serp/baidu/locationsGET /v3/serp/baidu/locations/$country
平台容路径中也存在以下形式:
GET /v3/serp/wp/locationsGET /v3/serp/wp/locations/$country
请优使用百度专用路径 /v3/serp/baidu/locations。
计费说明
本接口不收取调用费用,响应中的 cost 通常为 0。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求参数
路径参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
country | string | 否 | 用于筛选地点的国家或地区 ISO 代码,例如 us、cn。传后返回对应国家或地区的地点。 |
请求示例
获取支持的地点:
http
GET /v3/serp/baidu/locations获取指定国家或地区的地点:
http
GET /v3/serp/baidu/locations/cn当前支持城市级地点。中国还支持国家级地点;国家通常支持城市级地点。
> 俄罗斯和白俄罗斯的地点目前不支持通过本平台服务调用。
curl 示例
bash
curl --location --request GET \
"https://api.seermartech.cn/v3/serp/baidu/locations" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"按国家筛选:
bash
curl --location --request GET \
"https://api.seermartech.cn/v3/serp/baidu/locations/cn" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python 示例
python
import requests
url = "https://api.seermartech.cn/v3/serp/baidu/locations/cn"
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(
"请求失败。错误码:{},错误信息:{}".format(
result.get("status_code"),
result.get("status_message"),
)
)TypeScript 示例
typescript
import axios from "axios";
axios
.get("https://api.seermartech.cn/v3/serp/baidu/locations/cn", {
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
})
.then((response) => {
const result = response.data;
if (result.status_code === 20000) {
console.log(result);
} else {
console.error(
`请求失败。错误码:${result.status_code},错误信息:${result.status_message}`
);
}
})
.catch((error) => {
console.error(error.response?.data || error.message);
});响应结构
服务端返回 JSON 数据,主要字段如下:
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 请求级状态码。20000 表示成功。 |
status_message | string | 请求级状态说明。 |
time | string | 请求执行耗时,例如 0.2246 sec.。 |
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 模块名称,例如 serp。 |
function | string | 接口功能名称,例如 locations。 |
se | string | 搜索引擎名称,例如 baidu。 |
result 地点对象字段
| 字段 | 类型 | 说明 |
|---|---|---|
location_code | integer | 地点代码。 |
location_name | string | 地点完整名称。 |
location_code_parent | integer | 上级地点代码。 |
country_iso_code | string | 地点所属国家或地区的 ISO 代码。 |
location_type | string | 地点类型。通常为 City;中国还可能返回 Country。 |
> 不建议通过 location_code_parent 匹地点。除中国外,大多数国家的地区级和国家级百度 SERP 结果不受支持。
响应示例
json
{
"version": "0.1.20201026",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.2246 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "00000000-0000-0000-0000-000000000000",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.1000 sec.",
"cost": 0,
"result_count": 1,
"path": [
"v3",
"serp",
"baidu",
"locations"
],
"data": {
"api": "serp",
"function": "locations",
"se": "baidu"
},
"result": [
{
"location_code": 1000001,
"location_name": "示例城市",
"location_code_parent": 1000000,
"country_iso_code": "cn",
"location_type": "City"
}
]
}
]
}状态码
20000:请求成功。- 状态码:请求或任务执行失败,含义以
status_code和status_message为准。
实用场景
- 生成百度 SERP 任务的地点下拉选项:根据接口返回的城市和国家代码构建投放或排名监测,减少手工维护地点数据的成本。
- 筛选区域 SEO 监测范围:按国家 ISO 代码获取地点列表,为本地搜索排名、门店 SEO 和区域监控选择准确的城市。
- 校验地点参数:在提交 SERP 查询任务前验证
location_code是否属于百度支持的地点,降低任务失败率。 - 构建多城市排名报表:利用地点名称、地点代码和国家代码排名结果,生成按城市拆分的 SEO 可见性报告。
- 维护搜索市场覆盖单:定期同步支持的地点及层级信息,帮助业务团队识别可监测的百度搜索市场范围。