主题
Google Trends 分类列表
GET /v3/keywords_data/google_trends/categories
接口概述
通过调用本接口,你可以获取 Google Trends 支持的分类列表。
- 请求方式:
GET - 请求地址:
https://api.seermartech.cn/v3/keywords_data/google_trends/categories - 计费说明:调用本接口不收费
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准
接口返回 JSON 数据,结果位于 tasks 数组中,每个任务下的 result 数组可用分类信息。
请求信息
HTTP Request
GET /v3/keywords_data/google_trends/categories
请求头
| 名称 | 类型 | 是否填 | 说明 |
|---|---|---|---|
| Authorization | string | 是 | 使用 Bearer Token 认证:Bearer smt_live_YOUR_KEY |
| Content-Type | string | 是 | 固定为 application/json |
说明:该接口为 GET 请求,无需请求体。
返回字段说明
顶层响应字段
| 字段名 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本 |
status_code | integer | 接口通用状态码 |
status_message | string | 接口通用状态信息 |
time | string | 执行耗时,单位秒 |
cost | float | 本次请求总费用,单位 USD;本接口通常为 0 |
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 |
result_count | integer | result 数组中的数量 |
path | array | 请求路径 |
data | object | GET 请求 URL 中传递的参数信息 |
result | array | 结果数组 |
result[] 分类字段
| 字段名 | 类型 | 说明 |
|---|---|---|
category_code | integer | Google Trends 分类唯一标识 |
category_name | string | Google Trends 分类名称 |
category_code_parent | integer | 上级分类编码 |
分类层级示例
例如:
json
{
"category_code": 1100,
"category_name": "Superhero Films",
"category_code_parent": 1097
}category_code_parent = 1097 对应的上级分类可能是:
json
{
"category_code": 1097,
"category_name": "Action & Adventure Films"
}这意味着分类数据备父子层级,可用于构建分类树或映射业务标签。
请求示例
cURL
bash
curl --location --request GET "https://api.seermartech.cn/v3/keywords_data/google_trends/categories" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"Python
python
import requests
url = "https://api.seermartech.cn/v3/keywords_data/google_trends/categories"
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(f'error. Code: {result.get("status_code")} Message: {result.get("status_message")}')TypeScript
typescript
import axios from "axios";
// 获取 Google Trends 分类列表
axios({
method: "get",
url: "https://api.seermartech.cn/v3/keywords_data/google_trends/categories",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
})
.then(function (response) {
// 响应结果
console.log(response.data);
})
.catch(function (error) {
console.error(error);
});响应示例
json
{
"version": "0.1.20210917",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0569 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"data": {
"api": "keywords_data",
"function": "categories",
"se": "google_trends"
},
"result": []
}
]
}说明:示例中
result被省略,返回时该数组中会分类对象列表。
响应状态与错误处理
你可以根据以下字段判断请求是否成功:
- 顶层
status_code = 20000:请求成功 tasks_error = 0:所有任务均成功tasks[].status_code:单个任务的执行状态tasks[].status_message:单个任务的状态说明
如需排查异常,重点查看:
- 顶层
status_code与status_message tasks[].status_code与tasks[].status_messagetasks_error是否大于0
使用建议
- 拉取完整分类列表,再在本地建立
category_code到category_name的映射表 - 使用
category_code_parent构建多级分类树,便于前端筛选或分析聚合 - 若后续要请求 Trends 数据,可优用该接口确认可用分类编码,传无效类别
实用场景
- 构建分类筛选器:拉取 Trends 分类并生成前端下拉选项,便于用户按行业或主题筛选趋势数据。
- 建立分类映射表:将
category_code与业务标签体系对齐,降低后续趋势分析与报表处理成本。 - 生成分类树结构:利用
category_code_parent构建父子层级,支持按大类、子类逐层钻取分析。 - 校验分类参数:在发起 Trends 请求前,校验分类编码是否合法,减少无效请求与排错时间。
- 沉淀行业趋势模板:基于官方分类预设影视、金融、游戏、消费等分析模板,提升常见 SEO 选题与市场洞察效率。