Skip to content

merchant/google/locations

GET /v3/merchant/google/locations

本接口用于获取 Merchant API 支持的 Google Shopping 地区列表。支持以下请求方式和路径:

  • GET /v3/merchant/google/locations
  • GET /v3/merchant/google/locations/$country

$country 为 ISO 3166-1 国家代码,可用于按国家筛选地区。此接口不收取调用费用。

> 注意:由于服务政策调整,俄罗斯和白俄罗斯地区目前不再受支持。

请求参数

路径参数

参数名类型说明
countrystring国家 ISO 代码。传后返回该国家下的 Google Shopping 地区。示例:us

请求示例

获取支持的地区:

http
GET https://api.seermartech.cn/v3/merchant/google/locations

获取美国支持的地区:

http
GET https://api.seermartech.cn/v3/merchant/google/locations/us

认证方式

请求时需在 Authorization 请求头中携带 API 密钥:

http
Authorization: Bearer smt_live_YOUR_KEY

返回字段

接口返回 JSON 对象 tasks 数组。

顶层字段

字段名类型说明
versionstring当前 API 版本
status_codeinteger请求的通用状态码
status_messagestring请求的通用说明信息
timestring接口执行耗时,单位为秒
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 路径
dataobject请求中传的参数及接口信息
resultarray地区结果数组

result 数组字段

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

例如:

json
{
  "location_name": "Arkansas, United States",
  "location_name_parent": "United States"
}

请求示例

cURL

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

按国家筛选:

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

Python

python
import requests

url = "https://api.seermartech.cn/v3/merchant/google/locations"

headers = {
    "Authorization": "Bearer smt_live_YOUR_KEY",
    "Content-Type": "application/json",
}

response = requests.get(url, headers=headers)
response.raise_for_status()

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("country_iso_code"),
            )
else:
    print(
        f"请求失败,状态码:{result.get('status_code')},"
        f"消息:{result.get('status_message')}"
    )

TypeScript

typescript
import axios from "axios";

async function getMerchantGoogleLocations(country?: string) {
  const path = country
    ? `/v3/merchant/google/locations/${country}`
    : "/v3/merchant/google/locations";

  const response = await axios.get(
    `https://api.seermartech.cn${path}`,
    {
      headers: {
        Authorization: "Bearer smt_live_YOUR_KEY",
        "Content-Type": "application/json",
      },
    }
  );

  const result = response.data;

  if (result.status_code === 20000) {
    return result.tasks?.flatMap(
      (task: { result?: unknown[] }) => task.result ?? []
    );
  }

  throw new Error(
    `请求失败,状态码:${result.status_code},消息:${result.status_message}`
  );
}

getMerchantGoogleLocations("us")
  .then((locations) => {
    console.log(locations);
  })
  .catch((error) => {
    console.error(error);
  });

返回示例

json
{
  "version": "3.20191128",
  "status_code": 20000,
  "status_message": "Ok.",
  "time": "0.4305 sec.",
  "cost": 0,
  "tasks_count": 1,
  "tasks_error": 0,
  "tasks": [
    {
      "id": "9f8c7b6a-5d4e-3f2a-1b0c-9d8e7f6a5b4c",
      "status_code": 20000,
      "status_message": "Ok.",
      "time": "0.1200 sec.",
      "cost": 0,
      "result_count": 2,
      "path": [
        "v3",
        "merchant",
        "google",
        "locations"
      ],
      "data": {
        "api": "merchant",
        "function": "locations",
        "se": "google"
      },
      "result": [
        {
          "location_code": 21160,
          "location_name": "Arkansas, United States",
          "location_name_parent": "United States",
          "country_iso_code": "US",
          "location_type": "State"
        },
        {
          "location_code": 2840,
          "location_name": "United States",
          "location_name_parent": null,
          "country_iso_code": "US",
          "location_type": "Country"
        }
      ]
    }
  ]
}

错误处理

请根据顶层或任务级别的 status_codestatus_message 判断请求是否成功:

  • status_code = 20000:请求成功。
  • 状态码:请求或任务执行失败,原因以 status_message 为准。

实用场景

  • 构建国家和地区选择器:为 Merchant 商品投放提供标准化的国家、州、省及城市列表,减少手动维护地区数据的成本。
  • 校验投放地域参数:在创建商品广告或购物数据任务前验证地区代码是否受支持,因无效地域导致任务失败。
  • 按国家生成市场单:批量获取目标国家下的可用地区,用于制定跨区域 SEO、商品投放和市场拓展计划。
  • 统一地区维度分析:使用标准化的 location_code 和 ISO 国家代码整合商品、流量及排名数据,提升跨地区报表的一致性。
  • 同步地区基础数据:定期拉取最新支持地区列表,更新投放系统、数据仓库或运营后台中的地域字。

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