Skip to content

Google Ads SERP 地理位置列表 ​

GET /v3/serp/google/ads_search/locations

本接口使用 GET 方法,路径为:

/v3/serp/google/ads_search/locations

用于获取 Google Ads Search SERP API 支持的地理位置列表国家、省州、城市、机场等层级信息。

计费说明 ​

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

> 目前不支持俄罗斯和白俄罗斯境的地理位置。

请求方式 ​

请求地址 ​

text
GET https://api.seermartech.cn/v3/serp/google/ads_search/locations

该接口无需请求参数,也无需请求体。

请求头 ​

http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json

响应结构 ​

接口返回 JSON 数据,顶层 tasks 数组。

顶层字段 ​

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

tasks 数组字段 ​

字段类型说明
idstring任务唯一标识,UUID 格式
status_codeinteger当前任务状态码,通常在 10000 至 60000 范围
status_messagestring当前任务状态说明
timestring任务执行耗时,单位为秒
costfloat平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。
result_countintegerresult 数组中的数量
patharray请求 URL 路径
dataobject本次请求使用的参数信息
resultarray地理位置结果数组

tasks[].data 字段 ​

字段类型说明
apistringAPI 类型,固定为 serp
functionstring接口功能,固定为 locations
sestring搜索引擎,固定为 google
se_typestringSERP 类型,固定为 ads_search

tasks[].result 字段 ​

字段类型说明
location_codeinteger地理位置编码
location_namestring地理位置完整名称
location_code_parentinteger上级地理位置编码
country_iso_codestring地理位置对应的 ISO 国家或地区代码
location_typestring地理位置类型

location_code_parent 用于表示地理位置层级。例如:

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"
}

请求示例 ​

cURL ​

bash
curl --location --request GET \
  "https://api.seermartech.cn/v3/serp/google/ads_search/locations" \
  --header "Authorization: Bearer smt_live_YOUR_KEY" \
  --header "Content-Type: application/json"

Python ​

python
import requests

url = "https://api.seermartech.cn/v3/serp/google/ads_search/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:
    for task in result.get("tasks", []):
        for location in task.get("result", []):
            print(
                location.get("location_code"),
                location.get("location_name"),
                location.get("location_type"),
            )
else:
    print(
        "请求失败,状态码:%s,消息:%s"
        % (result.get("status_code"), result.get("status_message"))
    )

TypeScript ​

typescript
import axios from "axios";

async function getGoogleAdsSearchLocations() {
  try {
    const response = await axios.get(
      "https://api.seermartech.cn/v3/serp/google/ads_search/locations",
      {
        headers: {
          Authorization: "Bearer smt_live_YOUR_KEY",
          "Content-Type": "application/json",
        },
      }
    );

    const result = response.data;

    if (result.status_code === 20000) {
      for (const task of result.tasks ?? []) {
        for (const location of task.result ?? []) {
          console.log({
            code: location.location_code,
            name: location.location_name,
            type: location.location_type,
          });
        }
      }
    } else {
      console.error(
        `请求失败,状态码:${result.status_code},消息:${result.status_message}`
      );
    }
  } catch (error) {
    console.error("请求异常:", error);
  }
}

getGoogleAdsSearchLocations();

PHP ​

php
<?php

$url = 'https://api.seermartech.cn/v3/serp/google/ads_search/locations';

$headers = [
    'Authorization: Bearer smt_live_YOUR_KEY',
    'Content-Type: application/json',
];

$ch = curl_init($url);

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_CUSTOMREQUEST => 'GET',
]);

$response = curl_exec($ch);

if ($response === false) {
    echo '请求异常:' . curl_error($ch) . PHP_EOL;
    curl_close($ch);
    exit;
}

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$result = json_decode($response, true);

if (($result['status_code'] ?? null) === 20000) {
    print_r($result);
} else {
    echo '请求失败,HTTP 状态码:' . $httpCode . PHP_EOL;
    echo '业务状态码:' . ($result['status_code'] ?? '未知') . PHP_EOL;
    echo '错误信息:' . ($result['status_message'] ?? '未知') . PHP_EOL;
}

C# ​

csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

public static class SerpLocationsDemo
{
    public static async Task GetLocationsAsync()
    {
        using var httpClient = new HttpClient();

        httpClient.DefaultRequestHeaders.Authorization =
            new AuthenticationHeaderValue("Bearer", "smt_live_YOUR_KEY");

        var response = await httpClient.GetAsync(
            "https://api.seermartech.cn/v3/serp/google/ads_search/locations"
        );

        var result = await response.Content.ReadAsStringAsync();

        if (response.IsSuccessStatusCode)
        {
            Console.WriteLine(result);
        }
        else
        {
            Console.WriteLine($"HTTP 请求失败:{response.StatusCode}");
            Console.WriteLine(result);
        }
    }
}

响应示例 ​

json
{
  "version": "0.1.20241101",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "0.0715 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "0.0500 sec.",
      "cost": 0,
      "result_count": 1,
      "path": [
        "v3",
        "serp",
        "google",
        "ads_search",
        "locations"
      ],
      "data": {
        "api": "serp",
        "function": "locations",
        "se": "google",
        "se_type": "ads_search"
      },
      "result": [
        {
          "location_code": 20044,
          "location_name": "Lower Austria,Austria",
          "location_code_parent": 20000,
          "country_iso_code": "AT",
          "location_type": "region"
        }
      ]
    }
  ]
}

状态码与错误处理 ​

请优检查以下字段:

  • 顶层 status_code:判断整个请求是否成功。
  • tasks[].status_code:判断任务是否成功。
  • status_message:获取对应的状态说明。
  • tasks_error:确认是否存在失败任务。

当状态码为 20000 时,表示请求成功。状态码表示请求或任务处理异常,应结合 status_message 定位问题。

实用场景 ​

  • 获取国家、省州、城市及机场编码,为 Google Ads SERP 查询构造合法的地理位置参数,手工维护位置字。
  • 建立地理位置层级映射,将城市、机场等下级位置到省州和国家,支持区域 SEO 报告的分层汇总。
  • 校验投放与排名监测区域,在批量提交 SERP 任务前确认目标区域是否受支持,减少无效请求。
  • 生成多地区排名任务,根据返回的位置编码批量扩展国家或区域维度,比较不同市场的搜索结果表现。
  • 同步位置基础数据,定期更新本地 SEO 平台中的地理位置名称、类型和 ISO 国家代码,保证报表维度的一致性。

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