Skip to content

百度 SERP 地点列表

GET /v3/serp/baidu/locations

本接口用于获取百度 SERP 支持的地点列表,可按国家或地区 ISO 代码筛选。

HTTP 方法与路径:

  • GET /v3/serp/baidu/locations
  • GET /v3/serp/baidu/locations/$country

平台容路径中也存在以下形式:

  • GET /v3/serp/wp/locations
  • GET /v3/serp/wp/locations/$country

请优使用百度专用路径 /v3/serp/baidu/locations

计费说明

本接口不收取调用费用,响应中的 cost 通常为 0。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。

请求参数

路径参数

参数类型说明
countrystring用于筛选地点的国家或地区 ISO 代码,例如 uscn。传后返回对应国家或地区的地点。

请求示例

获取支持的地点:

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 数据,主要字段如下:

字段类型说明
versionstring当前 API 版本。
status_codeinteger请求级状态码。20000 表示成功。
status_messagestring请求级状态说明。
timestring请求执行耗时,例如 0.2246 sec.
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
tasks_countintegertasks 数组中的任务数量。
tasks_errorintegertasks 数组中返回错误的任务数量。
tasksarray任务结果数组。

tasks 对象字段

字段类型说明
idstring任务唯一标识,UUID 格式。
status_codeinteger任务状态码,通常在 1000060000 范围。
status_messagestring任务状态说明。
timestring任务执行耗时。
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
result_countintegerresult 数组中的结果数量。
patharray本次请求的 URL 路径。
dataobjectURL 请求中传的参数及接口信息。
resultarray地点结果数组。

data 对象示例字段

字段类型说明
apistringAPI 模块名称,例如 serp
functionstring接口功能名称,例如 locations
sestring搜索引擎名称,例如 baidu

result 地点对象字段

字段类型说明
location_codeinteger地点代码。
location_namestring地点完整名称。
location_code_parentinteger上级地点代码。
country_iso_codestring地点所属国家或地区的 ISO 代码。
location_typestring地点类型。通常为 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_codestatus_message 为准。

实用场景

  • 生成百度 SERP 任务的地点下拉选项:根据接口返回的城市和国家代码构建投放或排名监测,减少手工维护地点数据的成本。
  • 筛选区域 SEO 监测范围:按国家 ISO 代码获取地点列表,为本地搜索排名、门店 SEO 和区域监控选择准确的城市。
  • 校验地点参数:在提交 SERP 查询任务前验证 location_code 是否属于百度支持的地点,降低任务失败率。
  • 构建多城市排名报表:利用地点名称、地点代码和国家代码排名结果,生成按城市拆分的 SEO 可见性报告。
  • 维护搜索市场覆盖单:定期同步支持的地点及层级信息,帮助业务团队识别可监测的百度搜索市场范围。

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