Google Trends API
从 Google Trends 获取历史和当前的搜索热度数据。设置 engine=google_trends,在 q 中传入一个或多个关键词,并可选择使用 geo、date 和 cat 来限定请求范围。
Endpoint
Section titled “Endpoint” GET https://serp.shifter.io/v1?engine=google_trends&api_key=YOUR_API_KEY
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
api_key | string | 是 | 您的 SERP API 密钥 |
engine | string | 是 | 必须为 google_trends |
q | string | 是 | 搜索关键词。多个关键词可用逗号分隔 |
geo | string | 否 | 地理位置代码。默认为 worldwide。参见地理参数选项列表 |
region | string | 否 | country、city、subregion 或 metro。适用于 compared_breakdown_by_region |
date | string | 否 | YYYY-MM-DD YYYY-MM-DD 格式的日期范围,或以下之一:now 1-H、now 4-H、now 1-d、now 7-d、today 1-m、today 3-m、today 5-y、all |
cat | string | 否 | 分类 ID。参见分类列表 |
curl "https://serp.shifter.io/v1?engine=google_trends&api_key=YOUR_API_KEY&geo=US&q=american%20football&date=2021-01-01%202022-01-01"import requests
params = { "engine": "google_trends", "api_key": "YOUR_API_KEY", "geo": "US", "q": "american football", "date": "2021-01-01 2022-01-01",}r = requests.get("https://serp.shifter.io/v1", params=params)data = r.json()import fetch from 'node-fetch';
const url = 'https://serp.shifter.io/v1?' + new URLSearchParams({ engine: 'google_trends', api_key: 'YOUR_API_KEY', geo: 'US', q: 'american football', date: '2021-01-01 2022-01-01',});const data = await (await fetch(url)).json();{ "search_parameters": { "engine": "google_trends", "q": "american football", "geo": "US", "date": "2021-01-01 2022-01-01" }, "interest_over_time": { "timeline_data": [ { "date": "Jan 3 - 9, 2021", "timestamp": "1609632000", "values": [ { "query": "american football", "value": "100", "extracted_value": 100 } ] } ], "averages": [ { "query": "american football", "value": 68 } ] }, "interest_by_region": [ { "geo": "US-FL", "location": "Florida", "value": "100" } ], "related_queries": { "top": [ { "query": "nfl scores", "value": "100" } ], "rising": [ { "query": "nfl playoffs", "value": "Breakout" } ] }}