主题
Google Trends 类别列表
GET /v3/keywords_data/google_trends/categories
本接口使用 GET 方法,请求路径为:
/v3/keywords_data/google_trends/categories
用于获取 Google Trends API 支持的类别及层级。
计费说明
本接口调用,不收取任务费用。扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求
请求方法
GET
请求 URL
text
https://api.seermartech.cn/v3/keywords_data/google_trends/categories请求头
http
Authorization: Bearer smt_live_YOUR_KEY
Content-Type: application/json本接口无需请求体,也无需传递查询参数。
响应结构
接口返回 JSON 数据,顶层 tasks 数组。每个任务的 result 数组一个 Google Trends 类别对象。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本 |
status_code | integer | 通用响应状态码 |
status_message | string | 通用状态信息 |
time | string | 请求执行耗时,单位为秒 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量 |
tasks_error | integer | tasks 数组中返回错误的任务数量 |
tasks | array | 任务列表 |
任务字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式 |
status_code | integer | 任务状态码,范围通常为 10000–60000 |
status_message | string | 任务状态信息 |
time | string | 任务执行耗时,单位为秒 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量 |
path | array | 请求 URL 路径 |
data | object | GET 请求中使用的接口参数 |
result | array | 类别结果列表 |
data 字段
| 字段 | 类型 | 说明 |
|---|---|---|
api | string | API 模块名称,值为 keywords_data |
function | string | 接口名称,值为 categories |
se | string | 搜索引擎数据源,值为 google_trends |
result 类别字段
| 字段 | 类型 | 说明 |
|---|---|---|
category_code | integer | Google Trends 类别唯一标识 |
category_name | string | 类别名称 |
category_code_parent | integer | 父级类别标识 |
例如,类别 1100“Superhero Films”的父级类别为 1097“Action & Adventure Films”:
json
{
"category_code": 1100,
"category_name": "Superhero Films",
"category_code_parent": 1097
}请求示例
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(
"请求失败。状态码: %s,信息: %s"
% (result.get("status_code"), result.get("status_message"))
)TypeScript
typescript
import axios from "axios";
axios
.get(
"https://api.seermartech.cn/v3/keywords_data/google_trends/categories",
{
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.message);
});PHP
php
<?php
$url = 'https://api.seermartech.cn/v3/keywords_data/google_trends/categories';
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer smt_live_YOUR_KEY',
'Content-Type: application/json',
],
]);
$response = curl_exec($ch);
if ($response === false) {
echo '请求失败: ' . curl_error($ch);
} else {
$result = json_decode($response, true);
if (($result['status_code'] ?? null) === 20000) {
print_r($result);
// 在此处理类别列表
} else {
printf(
"请求失败。状态码: %s,信息: %s\n",
$result['status_code'] ?? 'unknown',
$result['status_message'] ?? 'unknown'
);
}
}
curl_close($ch);C#
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
public static class GoogleTrendsCategoriesDemo
{
public static async Task GetCategoriesAsync()
{
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/keywords_data/google_trends/categories"
);
var content = await response.Content.ReadAsStringAsync();
var result = JObject.Parse(content);
if ((int?)result["status_code"] == 20000)
{
Console.WriteLine(result);
// 在此处理类别列表
}
else
{
Console.WriteLine(
$"请求失败。状态码: {result["status_code"]}," +
$"信息: {result["status_message"]}"
);
}
}
}响应示例
json
{
"version": "0.1.20210917",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0569 sec.",
"cost": 0,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "00000000-0000-0000-0000-000000000000",
"status_code": 20000,
"status_message": "Ok.",
"time": "0.0450 sec.",
"cost": 0,
"result_count": 2,
"path": [
"v3",
"keywords_data",
"google_trends",
"categories"
],
"data": {
"api": "keywords_data",
"function": "categories",
"se": "google_trends"
},
"result": [
{
"category_code": 1097,
"category_name": "Action & Adventure Films",
"category_code_parent": 34
},
{
"category_code": 1100,
"category_name": "Superhero Films",
"category_code_parent": 1097
}
]
}
]
}响应状态码
- 顶层
status_code表示本次 API 请求的整体处理结果。 - 任务级
status_code表示对应任务的处理结果。 20000表示请求成功。- 状态码表示请求或任务处理异常,含义请参考错误码文档。
实用场景
- 获取并同步 Google Trends 类别树,为趋势查询建立标准化的类别字。
- 按父子类别组织趋势数据,支持网站或电商平台进行主题层级分析。
- 校验业务侧类别标识,提交无效的 Google Trends 类别编码。
- 构建类别筛选器,帮助 SEO 团队按行业、主题或类型筛选趋势。
- 定期刷新类别数据,确保报表和数据仓库中的类别名称与平台保持一致。