主题
设置 本平台 Trends 探索实时任务
POST /v3/keywords_data/dataforseo_trends/explore/live
本接口使用 POST 方法,路径为:
/v3/keywords_data/dataforseo_trends/explore/live
用于获取在搜索、新闻和电商场景中的热度趋势数据。每个都会在结果数组中返回对应数据。
接口支持以下趋势类型:
web:搜索趋势news:新闻趋势ecommerce:购物趋势
本平台会综合与网页、新闻文章或商品列表的程度、的受欢迎程度,以及来自多个来源的匿名用户网络行为数据,计算的相对热度。
单个请求最多可提交 5 个。接口按请求次数计费,与 keywords 数组中的数量无。
历史数据范围:
web类型:最早支持2004-01-01news和ecommerce类型:最早支持2008-01-01
请求限制与计费
- 每个请求都会产生费用。
- 单个 Live API 请求只能一个任务。 平台限流以认证说明中的 30/60/120 次/分钟规则为准。
- 同时发送的请求数量最多为 30 个。
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准。
所有 POST 请求体使用 UTF-8 编码的 JSON 格式,并且顶层结构为 JSON 数组。
请求参数
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
keywords | array | 是 | 要查询的列表,最多 5 个。 |
location_name | string | 否 | 搜索引擎地区的完整名称。不传时返回数据。使用该参数时无需同时传 location_code。可通过 /v3/keywords_data/dataforseo_trends/locations 获取可用地区及名称。数据将按该地区所属国家提供。示例:United Kingdom |
location_code | integer | 否 | 搜索引擎地区代码。不传时返回数据。使用该参数时无需同时传 location_name。可通过 /v3/keywords_data/dataforseo_trends/locations 获取可用地区及代码。数据将按该地区所属国家提供。示例:2840 |
type | string | 否 | 趋势数据类型。可选值:web、news、ecommerce。不传时默认为 web。 |
date_from | string | 否 | 时间范围的开始日期,格式为 yyyy-mm-dd。不传时默认为前一年当日的日期。web 类型最早支持 2004-01-01,类型最早支持 2008-01-01。示例:2019-01-15 |
date_to | string | 否 | 时间范围的结束日期,格式为 yyyy-mm-dd。不传时默认为当前日期。示例:2019-01-15 |
time_range | string | 否 | 预设时间范围。如果同时指定 date_from 或 date_to,该参数将被忽略。可选值:past_4_hours、past_day、past_7_days、past_30_days、past_90_days、past_12_months、past_5_years |
tag | string | 否 | 自定义任务标识,最多 255 个字符。可用于识别任务并匹结果。提交的值会原样返回在响应的 data 对象中。 |
> location_name 与 location_code 二选一即可,不能同时使用。
请求示例
cURL
bash
curl --location --request POST \
"https://api.seermartech.cn/v3/keywords_data/dataforseo_trends/explore/live" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"location_code": 2840,
"keywords": [
"iphone 14",
"samsung s23"
],
"type": "web",
"time_range": "past_12_months"
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/keywords_data/dataforseo_trends/explore/live"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
payload = [
{
"location_code": 2840,
"keywords": [
"iphone 14",
"samsung s23",
],
"type": "web",
"time_range": "past_12_months",
}
]
response = requests.post(url, headers=headers, json=payload)
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";
const payload = [
{
location_code: 2840,
keywords: ["iphone 14", "samsung s23"],
type: "web",
time_range: "past_12_months",
},
];
axios
.post(
"https://api.seermartech.cn/v3/keywords_data/dataforseo_trends/explore/live",
payload,
{
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
}
)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error.response?.data || error.message);
});响应结构
接口返回 JSON 数据,顶层 tasks 数组。
顶层响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
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 | 请求路径信息。 |
data | object | 创建任务时提交的参数。 |
result | array | 任务结果数组。 |
result 字段
| 字段 | 类型 | 说明 |
|---|---|---|
keywords | array | 请求中提交的列表。 |
type | array | 请求中提交的趋势类型。 |
location_code | integer | 请求中使用的地区代码。无数据时可能为 null。 |
language_code | string | 语言代码。无数据时为 null。 |
datetime | string | 结果生成时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00。 |
items_count | integer | items 数组中的数量。 |
items | array | 含热度及数据。 |
items 字段
| 字段 | 类型 | 说明 |
|---|---|---|
position | integer | 素在结果中的序号,例如 1、2、3。 |
type | string | 素类型,固定为 dataforseo_trends_graph。 |
keywords | array | 该趋势图对应的列表。 |
data | array | 指定参数下的趋势数据。 |
averages | array | 整个时间范围的平均热度值。 |
data 数组字段
| 字段 | 类型 | 说明 |
|---|---|---|
date_from | string | 当前数据点对应时间范围的开始日期,格式为 yyyy-mm-dd。 |
date_to | string | 当前数据点对应时间范围的结束日期,格式为 yyyy-mm-dd。 |
timestamp | integer | 当前数据点的 Unix 时间戳。 |
values | array | 当前时间点的相对热度。该值表示在指定时间范围的相对受欢迎程度。 |
values 的计算规则:
100表示该在所选时间范围达到最高热度。50表示热度约为峰值的一半。0表示该缺少足够数据。- 如果一次提交多个,系统会所有中的最高热度进行归一化,并返回相应的平均趋势数据。
响应示例
json
{
"version": "0.1.20231117",
"status_code": 20000,
"status_message": "Ok.",
"time": "7.9401 sec.",
"cost": 0.001,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "01234567-89ab-cdef-0123-456789abcdef",
"status_code": 20000,
"status_message": "Ok.",
"time": "7.9000 sec.",
"cost": 0.001,
"result_count": 1,
"path": [
"v3",
"keywords_data",
"dataforseo_trends",
"explore",
"live"
],
"data": {
"api": "keywords_data",
"function": "explore",
"se": "dataforseo_trends",
"keywords": [
"iphone 14",
"samsung s23"
],
"location_code": 2840
},
"result": [
{
"keywords": [
"iphone 14",
"samsung s23"
],
"type": "web",
"location_code": 2840,
"language_code": null,
"datetime": "2024-01-10 11:18:54 +00:00",
"items_count": 1,
"items": [
{
"position": 1,
"type": "dataforseo_trends_graph",
"keywords": [
"iphone 14",
"samsung s23"
],
"data": [
{
"date_from": "2023-01-22",
"date_to": "2023-01-28",
"timestamp": 1674345600,
"values": [72, 48]
},
{
"date_from": "2023-01-29",
"date_to": "2023-02-04",
"timestamp": 1674950400,
"values": [81, 52]
}
],
"averages": [76.5, 50.0]
}
]
}
]
}
]
}错误处理
请根据以下字段判断请求和任务是否成功:
- 顶层
status_code - 任务级
status_code status_messagetasks_error
通常 20000 表示请求成功。接时应针对网络异常、参数错误、任务错误和无数据设计相应的重试、告警及降级机制。
实用场景
- 比较多个候选的搜索热度,识别用户度更高的主题,为筛选和优级排序提供依据。
- 监测的历史趋势变化,发现季节性需求和长期增长主题,优化 SEO发布时间及更新计划。
- 分析新闻的短期热度,及时捕捉突发事件和舆论热点,支持新闻选题与热点生产。
- 评估电商的购物趋势,识别商品需求变化,为选品、促销活动和商品页 SEO 提供数据支持。
- 按国家或地区对比热度,发现不同市场的搜索需求差异,化 SEO 和区域市场投放决策。