Skip to content

百度 SERP 地区列表

接口概述

通过本接口可获取百度 SERP 支持的地区列表。 你也可以在请求路径中附带国家 ISO 代码返回指定国家下的地区。

该接口常用于创建 SERP 查询任务前,确认可用的 location_code 与地区层级。

计费说明: 调用本接口不收费,扣费以响应头 X-SeerMarTech-Charge-CNY 为准。

请求方式

获取地区

GET /v3/serp/wp/locations

按国家筛选地区

GET /v3/serp/wp/locations/{country}

说明:虽然原页面标题对应百度地区列表,但技术路径以接口容路径为准,请按返回结果使用。 country 为可选路径参数,用于按国家过滤地区。

此外,你也可以下载完整支持地区单作为离线参考文档。

特别说明

由于平台服务策略限制,俄罗斯和白俄罗斯的所有地区在服务中均不再支持。

路径参数

字段名类型是否填说明
countrystring国家 ISO 代码。填写后返回该国家的地区列表,例如:us

响应结构

接口返回 JSON 数据,顶层 tasks 数组,每个任务对象中本次请求的执行状态与结果。

顶层字段

字段名类型说明
versionstring当前 API 版本
status_codeinteger通用状态码,完整列表见 /v3/appendix/errors
status_messagestring通用状态信息,完整列表见 /v3/appendix/errors
timestring执行耗时,单位秒
costfloat本次请求总费用,单位 USD
tasks_countintegertasks 数组中的任务数量
tasks_errorintegertasks 数组中返回错误的任务数量
tasksarray任务结果数组

tasks[] 字段

字段名类型说明
idstring任务唯一标识,UUID 格式
status_codeinteger任务状态码,范围通常为 10000-60000
status_messagestring任务状态说明
timestring任务执行耗时,单位秒
costfloat该任务费用,单位 USD
result_countintegerresult 数组中的结果数量
patharray请求路径
dataobjectGET 请求 URL 中传的参数
resultarray地区结果列表

result[] 字段

字段名类型说明
location_codeinteger地区编码
location_namestring地区完整名称
location_code_parentinteger上级地区编码
country_iso_codestring地区所属国家的 ISO 代码
location_typestring地区类型

地区层级说明

百度 SERP 地区支持存在以下限制:

  • 除中国外,国家通常支持 City
  • 中国除 City 外,还支持 Country
  • 不要依赖 location_code_parent 做通用层级匹 因为大多数国家并不支持 RegionCountry 级别的百度 SERP 结果

调用示例

cURL

bash
curl --request GET "https://api.seermartech.cn/v3/serp/wp/locations" \
 --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"
headers = {
 "Authorization": "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
data = response.json

if data.get("status_code") == 20000:
 print(data)
else:
 print(f"error. Code: {data.get('status_code')} Message: {data.get('status_message')}")

TypeScript

typescript
import axios from "axios";

axios({
 method: "get",
 url: "https://api.seermartech.cn/v3/serp/baidu/locations",
 headers: {
 "Authorization": "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json"
 }
})
 .then((response) => {
 // 返回结果
 console.log(response.data);
 })
 .catch((error) => {
 console.log(error);
 });

响应示例

json
{
 "version": "0.1.20201026",
 "status_code": 20000,
 "status_message": "Ok.",
 "time": "0.2246 sec.",
 "cost": 0,
 "tasks_count": 1,
 "tasks_error": 0,
 "tasks": [
 {
 "data": {
 "api": "serp",
 "function": "locations",
 "se": "baidu"
 },
 "result": []
 }
 ]
}

状态码说明

状态码字段说明
status_code通用或任务级状态码
status_message对应状态说明

完整错误码与说明请参考:/v3/appendix/errors

使用建议

  • 在创建百度 SERP 任务前,调用本接口确认 location_code
  • 如果你的业务只针对某个国家,建议使用 /v3/serp/wp/locations/{country} 缩小返回范围
  • 对百度地区进行映射时,应优使用 location_code,不要依赖名称字符串匹
  • 涉及中国以外国家时,应预期大多数结果支持城市级定位

实用场景

  • 校验投放地区:在提交百度 SERP 抓取任务前校验地区是否受支持,因地区参数错误导致任务失败
  • 生成地区下拉选项:为 SEO 平台后台生成可选城市列表,提升任务效率并减少人工维护
  • 映射地理维度:将企业城市库与平台 location_code 对齐,便于后续批量排名监控
  • 过滤无效市场:在化 SEO 研究中筛除不支持的国家或层级,减少无效请求
  • 构建本地化监控方案:基于城市级地区编码百度本地搜索可见性监控,提升区域 SEO 分析精度

统一入口:官网 · LLM API · 控制台