惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
aimingoo的专栏
aimingoo的专栏
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
P
Proofpoint News Feed
T
The Blog of Author Tim Ferriss
WordPress大学
WordPress大学
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
I
InfoQ
U
Unit 42
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Martin Fowler
Martin Fowler
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
G
Google Developers Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Security Affairs
Jina AI
Jina AI
Google DeepMind News
Google DeepMind News
M
MIT News - Artificial intelligence
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
H
Hacker News: Front Page
MongoDB | Blog
MongoDB | Blog
A
About on SuperTechFans
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
SecWiki News
SecWiki News
V
V2EX
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
博客园 - 司徒正美
L
LangChain Blog
F
Fortinet All Blogs
Scott Helme
Scott Helme
量子位
Recent Announcements
Recent Announcements
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Cloudbric
Cloudbric
W
WeLiveSecurity
The Register - Security
The Register - Security
NISL@THU
NISL@THU
博客园_首页

SerpApi

Decoding Protobuf Messages Without Access to the Schema Introducing SerpTrail: A self-hosted SEO and GEO rank tracker for your business Introducing SerpApi’s Hermes Agent Plugin Loop Engineering Visualized: A World Cup Fan Journey with SerpApi and Codex Google v. SerpApi: The Court Granted Our Motion to Dismiss SerpApi Weekly Changelog: July 13-19, 2026 The State of the SERP in the Age of AI How to find the Google Knowledge Graph ID (kgmid) for anything What is an API? Part 2: Feeding the Machine (JSON) Building an Accessibility Search Experience with Google Flights, Hotels, and Maps APIs SerpApi Weekly Changelog: July 06-12, 2026 How to Scrape Google Flights Deals with a simple API Monitoring FIFA World Cup 2026 scores with a simple API How to scrape Google sports results Build Smarter Pydantic AI Agents with Real-Time Search A complete guide to web scraping with Ruby (2026) SerpApi Weekly Changelog: June 29- July 05, 2026 Make no mistakes: agent usability testing Semantic Image Search with Elasticsearch What is an API? Part 1: The Secret Life of a Web Browser MCP Apps with FastMCP: Turning Tool Output Into Interactive UI How to Scrape Naver AI Briefings with SerpApi Connect Sakana AI (Fugu) with Web Search API SerpApi Weekly Changelog: June 22-28, 2026 Trending Travel Destinations using Python & SerpApi How to scrape Bing reverse image search results Measuring Brand Presence Across AI Answer Engines SerpApi Weekly Changelog: June 15-21, 2026 How I Built a Star Wars Grogu Product Research Agent with Codex, Lark, and SerpApi How to scrape Bing web search results Categorizing hotels using Google Hotels images How to scrape Bing Images search results How to scrape Bing Copilot answers Build A No Code AI-Powered Local Lead Outreach System SerpApi Weekly Changelog: June 08-14, 2026 How to Do SEO Research with Claude Desktop and SerpApi MCP Track and Compare Product Prices Across Stores and Locations (SerpApi & Python) How to Extract Full Opinion Text from Google Scholar Case Law with SerpApi How to scrape Bing Maps search results SerpApi Weekly Changelog: June 01-07, 2026 Amazon ASIN Lookup API: Find and Fetch Product Details The State of MCP: Everything That Changed in H1 2026 How to scrape Bing News search results How to Connect Your Local LLM with Web Search Data SerpApi on Postman: One Unified Collection for Faster API Exploration SerpApi Weekly Changelog: May 25-31, 2026 Building an AI Agent in Python How to scrape Google Case Law API for Legal Research, Analytics, AI, and more SerpApi Achieves SOC 2 Type 2 and ISO 27001 Certification How to find your next product idea with Google Trends and SerpApi Scrape Competitors' Google Ads Data (Tutorial 2026) Using SerpApi and DeepSeek to Break Down Dan Koe’s Content Strategy SerpApi Weekly Changelog: May 18-24, 2026 How to scrape Bing Videos search results How to Scrape Instagram Profile Data with SerpApi How to scrape Bing Shopping search results How to Scrape Google Hotels Reviews SerpApi Weekly Changelog: May 11-17, 2026 5 Things You Can Build with Claude Code and Live Search Data Real Estate Data API for PropTech Developers How to Scrape Apple Maps with SerpApi
How to scrape Google Trends
Corbin Davenport · 2026-05-15 · via SerpApi

Google Trends allows you to check the popularity of top search queries in Google Search. It can help you discover new trending topics, compare the performance of keywords based on time and region, check which topics are popular at the moment, and much more. Google Search is the most widely-used search engine on Earth, so even the generalized data available through Google Trends is immensely valuable.

With the Google Trends API from SerpApi, you can pull results from Google Trends search pages, autocomplete results, and the 'Trending Now' page in simple JSON data. SerpApi handles the HTML parsing, proxy network, captcha puzzles, and other challenges, so you can spend more time on your actual project or business.

Here's everything you can pull from Google Trends using SerpApi:

  • Interest over time: The popularity for a given search query over a period of time, or group of search queries, just like you'd see on the regular Google Trends search page. You can change the date range, category, time zone offset, region, and other settings. Each query has a 1-100 score.
  • Interest by region: The popularity of a certain search query, or group of queries, with rankings for different regions. The regions can be countries, subregions (like U.S. states or Canadian providences), metro areas, or cities.
  • Compared breakdown by region: When comparing multiple search queries in multiple regions, this is the data representing the percentage of searches for each region.
  • Related queries: The list of related queries that appear under Google Trends search results.
  • Related topics: The list of related topics that appear for Google Trends search results, categorized into "rising" and "top" results.
  • Autocomplete results: The suggested searches that appear as you type in the main Google Trends search field, like the one on the Trends home page.
  • Trending Now page: The list of trending searches from the Google Trends Trending Now page. You can specify a certain region, time range, category, and other settings.
Screenshot of Google Trends search for "ford" and "bmw" alongside JSON results.
SerpApi fetches and parses Google Trends results into structured JSON.

Getting started with SerpApi

You need a free SerpApi account to obtain results from Google Trends. SerpApi also provides APIs for pulling data directly from Google Search, Bing, DuckDuckGo, and other engines. You can upgrade to a paid account later if you need more search capacity, faster speeds, or other features.

If you haven't already, create an account and verify your email and other details. After that, you need to grab your API key, which can be found in your account dashboard.

You should store your API key in a safe location if you are sharing or publishing your code. If the key is leaked or stolen, you can regenerate it from the SerpApi account dashboard.

Install the SerpApi library (optional)

You can use SerpApi's official libraries for Python, JavaScript, Ruby, Java, and other languages. They provide a simple wrapper around the API requests.

You can also use a simple GET request, using cURL, fetch() in Node.js, and other similar methods. This guide will cover both the GET method and several of the official integrations.

Each API at SerpApi has extensive documentation, covering all the supported parameters and filters, code examples for popular languages, and example JSON responses. For Google Trends, check out the pages for the Google Trends API, Google Trends Autocomplete API, and Google Trends Trending Now API.

Google Trends API - SerpApi

Scrape Google Trends results with SerpApi’s Google Trends Results API. Interest over time, Interest by region, Related topics, Related queries.

SerpApiSerpApi

The only required parameter for the main Google Trends API is the search query, or comma-separated list of search queries, that you want to check.

If you have your API key, you're ready to start pulling data from Google Trends. No matter how you're accessing SerpApi, the API results will be identical.

GET request

This will search Google Trends for the queries "chrome" and "firefox" and return the scores for each term, over the default time period:

https://serpapi.com/search?engine=google_trends&q=chrome,firefox&api_key=API_KEY_GOES_HERE

If you wanted to compare the popularity across different countries, you could set the data_type parameter to GEO_MAP like this:

https://serpapi.com/search.json?engine=google_trends&q=chrome,firefox&data_type=GEO_MAP&region=COUNTRY&api_key=API_KEY_GOES_HERE

SerpApi's JSON Restrictor feature can trim the API response to certain values. This would perform a search for "chrome" and "firefox" in the United States over the past 12 months, and filter the response to only the averages:

https://serpapi.com/search?engine=google_trends&q=chrome,firefox&geo=US&date=today%2012-m&json_restrictor=interest_over_time.averages&api_key=API_KEY_GOES_HERE

The JSON Restrictor might be helpful for more efficient parsing, or if you're using an LLM with a limited context window.

Python

SerpApi has an official library for Python with access to all APIs. This will pull Google Trends data in the United States for "chrome," "firefox," and the Opera web browser, with the topic code for Opera obtained through the Google Trends Autocomplete API:

import serpapi

client = serpapi.Client(api_key=YOUR_KEY_GOES_HERE)
results = client.search({
  "engine": "google_trends",
  "q": "chrome,firefox,/m/01z7gs",
  "geo": "US"
})

print(results["interest_over_time"])

This compares searches for "playstation 5," "xbox series x," and "nintendo switch 2" over the past three months, showing the average search volume for each query:

import serpapi

client = serpapi.Client(api_key=YOUR_KEY_GOES_HERE)
results = client.search({
  "engine": "google_trends",
  "q": "playstation 5,nintendo switch 2,xbox series x",
  "date": "today 3-m"
})

for item in results["interest_over_time"]["averages"]:
  print(f'{item["query"]} average: {item["value"]}')

You can check out more Python examples in our other blog post, including how SerpApi compares to PyTrends library.

Ruby

This example uses the official SerpApi Ruby gem to search for "microsoft edge" and "internet explorer" in Google Trends:

require "serpapi"

client = SerpApi::Client.new(
    engine: "google_trends",
    q: "microsoft edge, internet explorer",
    api_key: YOUR_KEY_GOES_HERE
)

results = client.search
p results

This checks for related queries to "walt disney world" and displays each one:

require "serpapi"

client = SerpApi::Client.new(
    engine: "google_trends",
    q: "walt disney world",
    data_type: "RELATED_QUERIES",
    api_key: YOUR_KEY_GOES_HERE
)

for result in client.search[:related_queries][:top] do
    p result[:query]
end

JavaScript and Node.js

This shows searches for the Apple Safari web browser over time, using the official SerpApi JavaScript library and the topic ID obtained with the Google Trends Autocomplete API:

import { getJson } from 'serpapi';

const search = await getJson({
    engine: "google_trends",
    q: "/m/0168s_",
    api_key: YOUR_KEY_GOES_HERE
});

search?.interest_over_time?.timeline_data.forEach(function (dateRange) {
    console.log(`${dateRange.date}: Score ${dateRange.values[0].value}`);
});

This compares the popularity of searches for "macbook pro" and "macbook air" over the last 12 months:

import { getJson } from 'serpapi';

const search = await getJson({
    engine: "google_trends",
    q: "macbook air,macbook pro",
    date: "today 12-m",
    api_key: YOUR_KEY_GOES_HERE
});

search?.interest_over_time?.timeline_data?.forEach(function (item) {
    console.log(`\nDate range: ${item.date}\n===`)
    item.values.forEach(function (result) {
        console.log(`${result.query} popularity: ${result.value}`);
    })
});

cURL

Here's how to pull Google Trends data for the "macbook air" search term across the last 12 months, in the "Interest over time" format:

curl --get https://serpapi.com/search \
 -d engine="google_trends" \
 -d q="macbook+air" \
 -d date="today+12-m" \
 -d data_type="TIMESERIES" \
 -d api_key="YOUR_KEY_GOES_HERE"

Other languages and no-code solutions

Even if an official SerpApi integration isn't available for your preferred language or environment, you can still use the API directly with GET requests. You can also use SerpApi with Make.com, N8N, and other tools.

You can also fetch the list of autocomplete suggestions from the main Google Trends search box, using the Google Trends Autocomplete API. This is mainly helpful for finding an exact topic ID for use with the main Google Trends API, instead of a search term that could have multiple meanings.

Let's say you wanted to check Google Trends data for Vivaldi web browser, and exclude searches for Vivaldi the composer. Searching for "vivaldi" with the Autocomplete API returns topic IDs for both topics, as well as others:

{
  ...
  "search_parameters": {
    "engine": "google_trends_autocomplete",
    "q": "vivaldi",
    "hl": "en"
  },
  "suggestions": [
    {
      "q": "vivaldi",
      "title": "vivaldi",
      "type": "Search term",
      "link": "https://trends.google.com/trends/explore?q=vivaldi",
      ...
    },
    {
      "q": "/m/0pth",
      "title": "Antonio Vivaldi",
      "type": "Italian composer",
      "link": "https://trends.google.com/trends/explore?q=/m/0pth",
      ...
    },
    {
      "q": "/m/012r1xmq",
      "title": "Vivaldi",
      "type": "Web browser",
      "link": "https://trends.google.com/trends/explore?q=/m/012r1xmq",
      ...
    },
    {
      "q": "/g/11b73xfgd0",
      "title": "Vivaldi Technologies",
      "type": "Software developer",
      "link": "https://trends.google.com/trends/explore?q=/g/11b73xfgd0",
      ...
    },
    {
      "q": "/g/11fzz2bjz1",
      "title": "The Four Seasons : Summer",
      "type": "Book by Antonio Vivaldi",
      "link": "https://trends.google.com/trends/explore?q=/g/11fzz2bjz1",
      ...
    },
    {
      "q": "/g/11y6ktp5vz",
      "title": "The Instrumentalist",
      "type": "Novel by Harriet Constable",
      "link": "https://trends.google.com/trends/explore?q=/g/11y6ktp5vz",
      ...
    }
  ]
}

Here's how to pull a list of autocomplete results for "Apple" with a basic GET request, and display each one with its category and topic ID:

https://serpapi.com/search.json?engine=google_trends_autocomplete&q=apple&api_key=YOUR_KEY_GOES_HERE

This is how you can do it in Python, with the official SerpApi Python integration:

import serpapi

client = serpapi.Client(api_key=YOUR_KEY_GOES_HERE)
results = client.search({
  "engine": "google_trends_autocomplete",
  "q": "apple"
})
for item in results["suggestions"]:
    print(f"{item["title"]} - {item["type"]}: {item["q"]}")

Here's the same search in Ruby, with the SerpApi Ruby gem:

require "serpapi"

client = SerpApi::Client.new(
    engine: "google_trends_autocomplete",
    q: "apple",
    api_key: YOUR_KEY_GOES_HERE
)
for item in client.search[:suggestions] do
    puts "#{item[:title]} - #{item[:type]} - #{item[:q]}"
end

Finally, this is the same search in JavaScript with the Node.js runtime, using the official JavaScript library:

import { getJson } from 'serpapi';

const search = await getJson({
    engine: "google_trends_autocomplete",
    q: "apple",
    api_key: YOUR_KEY_GOES_HERE
});
search.suggestions.forEach(function (item) {
    console.log(`${item.title} - ${item.type} - ${item.q}`)
})

Finally, you can pull the list of trending searches from the Google Trends Trending Now page with SerpApi, using the Google Trends Trending Now API. The JSON results will be identical for all integrations and GET methods, as with other APIs.

GET request

This pulls the active trending topics in the United States, with no other settings specified:

https://serpapi.com/search.json?engine=google_trends_trending_now&geo=US&api_key=API_KEY_GOES_HERE

If you wanted to filter to only technology topics, use the Technology category from the categories list page, like this:

https://serpapi.com/search.json?engine=google_trends_trending_now&geo=US&category_id=18&api_key=API_KEY_GOES_HERE

As with the other APIs, you can use SerpApi's JSON Restrictor feature to trim the response to certain values, if you need more efficient parsing. Here's the list of trending topics in the US again, but with only the query strings and no other information:

https://serpapi.com/search.json?engine=google_trends_trending_now&geo=US&json_restrictor=trending_searches[].query&api_key=API_KEY_GOES_HERE

Python

This fetches the current trending topics in Canada and displays each result:

import serpapi

client = serpapi.Client(api_key=YOUR_KEY_GOES_HERE)
results = client.search({
  "engine": "google_trends_trending_now",
  "geo": "CA"
})

for topic in results["trending_searches"]:
  print(topic["query"])

Ruby

This pulls the list of trending gaming topics, with the category ID from the categories list page, and displays each result:

require "serpapi"

client = SerpApi::Client.new(
    engine: "google_trends_trending_now",
    category_id: 6, # Gaming category ID
    api_key: YOUR_KEY_GOES_HERE
)

for result in client.search[:trending_searches] do
    p result[:query]
end

JavaScript and Node.js

This fetches the current trending topics in the United States, and displays each result with its search volume:

import { getJson } from 'serpapi';

const search = await getJson({
    engine: "google_trends_trending_now",
    geo: "US",
    api_key: YOUR_KEY_GOES_HERE
});

search?.trending_searches?.forEach(function (item) {
    console.log(`${item.query}: Volume ${item.search_volume}`);
});

cURL

This fetches the current trending topics in the United Kingdom:

curl --get https://serpapi.com/search \
 -d engine="google_trends_trending_now" \
 -d geo="GB" \
 -d api_key="YOUR_KEY_GOES_HERE"

Conclusion

With SerpApi, you compare search queries and topics with the Google Trends API, and identify new trends with the Google Trends Trending Now API. For searches that can have different meanings for the same word, you can use the Google Trends Autocomplete API to find the exact topic ID that you need.

These APIs are a powerful set of tools for keyword research, finding new opportunities for articles or videos, analyzing competitors, and much more. Best of all, they work in any programming language or workflow that accepts simple GET requests.

If you need help using SerpApi, please contact us.