Hacking the Google Trends API

google trends api

Since the Google search engine is dominating the internet search market, statistical data about search keywords can be very insightful. I was amazed when I first discovered Google Trends and I still think that it is a very powerful tool for marketers, researchers, website owners, and SEO experts. The tool has expanded quite a bit over the years and now you can do much more than just see the top 10 most popular keywords. Apart from viewing the latest hot searches and the most popular phrases over the last month, you can now see these top keyword trends in a cool visualization. If you select specific keywords, you can compare and chart up to 5 keywords over time and see the top and rising related searches. You can even filter by location, time, category, and type of search (web, image, news, shopping, or YouTube) or compare keywords by location or time range.

Adding to this, Google has added Top Charts which shows you most searched and trending keywords per category and you can filter or segment the data based on any time in the past. There is a ton that you can do with this data but isn’t it really annoying that there is no official Google Trends API? We do have the hot trends atom feed and that gives you 20 trends with approximate traffic numbers and related news items. This would be good for building a little widget but it leaves a lot to be desired in terms of serious keyword and market analysis. So, today, I will dig in, sniff some network traffic and figure out what kind of calls are made between the browser and Google servers to provide this trending keyword data programatically.

As the picture of this post shows, I was initially interested in automatically generating a comparison chart between a few keywords. It turns out that there is a simple API for this that works with a GET request and will respond with a nice chart of keyword comparison over time. Open a new tab with this url: http://www.google.com/trends/fetchComponent?hl=en-US&q=html5,jquery&cid=TIMESERIES_GRAPH_0&export=5&w=500&h=300 and you will see a nice chart comparing html5 to jquery. You can add up to 5 keywords, so the basics of this GET call are:

  • URI http://www.google.com/trends/fetchComponent
  • hl en-US
  • q keywords
  • export 5
  • w width
  • h height

You can modify the width and height and provide up to 5 keywords (comma separated) to quickly chart up and compare various search trends. What about related searches? The URI is still the same but some of the parameters change to retrieve a list of related queries to your original keyword. Open a new tab with this url: http://www.google.com/trends/fetchComponent?hl=en-US&q=html5,jquery&geo=US&cid=RISING_QUERIES_0_0 and you will see 10 related searches to html5. Here is the breakdown of the GET request:

  • URI http://www.google.com/trends/fetchComponent
  • hl en-US
  • geo US
  • q keywords
  • cid RISING_QUERIES_0_0

You can modify the keywords and RISING_QUERIES_0_0 (as well as geo if you care about search trends outside of United States). To see the related queries of the second keyword on your list, you just increment the middle zero in RISING_QUERIES_0_0. For example, the previous link was comparing html5 to jquery and we saw related searches to html5 but you could grab the related searches to jquery with this url:


Now, lets look at the cool hot trends visualization. It actually pulls keyword data from a url that responds with a nice JSON list of top 20 trends for various locations:


This is probably the best way to pull the hot searches but if you need more data, you could make a call to the hottrends/hotItems URI. This, unfortunately, needs to be a POST call so you will have can’t see it in a browser, but if you have cURL and command-line, you could make this request:

curl --data "ajax=1&htd=20131111&pn=p1&htv=l" http://www.google.com/trends/hottrends/hotItems

This will give you a JSON with the latest hot searches and more information like an array of related searches list, traffic stats, images, articles, and more. If you want to get the top 30 searches in the past 30 days, change some of the parameters in that call:

curl --data "ajax=1&pn=p1&htv=m" http://www.google.com/trends/hottrends/hotItems

What about Top Charts? It turns out you can grab all that data with just one POST request to this URI:

curl --data "ajax=1&geo=US&date=201310" http://www.google.com/trends/topcharts/category

This is a huge JSON response, over 1mb, and you can manipulate the geo and date parameters to see the results of these top charts over time and location. If you are interested in just trending data for a specific category, you can call the topcharts/trendingchart URI and retrieve that specific information. For example, recent trending keywords for Actors in United States could be retrieved with the following POST request:

curl --data "ajax=1&cid=actors&geo=US&date=201310" http://www.google.com/trends/topcharts/trendingchart

I have done a lot of research around trends and even looked across other channels in the past so I find these calls really helpful. I would love to hear more about how others are using this data, so drop a comment below.

Facebook Twitter Hacker News Reddit More...
  • Brianna Hillson

    Wowzers! This is awesome. I’m working on a Q&A site, and am looking to provide Google with some lovely user generated content for queries that it doesn’t have great responses for yet. Hopefully some of this will help me out, and give our community the chance to answer questions the internet is desperately seeking good answers for :)

  • http://zzy-master.blogspot.com/ Zzy Master

    good job!

  • curious

    Hi There.
    Great article.

    I am looking to analyze as much details I can get for the hot trending topics on the internet (google, Twitter, FB, Bing) etc. As much analytics as I can get would be awesome. Need to gather the trending data and find patterns for my research.
    I see that google has the concept of rising topics. Any insights to how that can be fetched?

    Can you help?


    • iweczek

      Can you provide more details?

  • mahi mehta

    hi seo1.
    The race for first place, in the SEO rankings
    visit :advante360

  • Joseph Musser

    It took me a while to realize that the curl command lines have an n-dash instead of a normal dash. Kind of prevents them from running. Chiral quotes too. ;-)

    • iweczek

      Thanks! I updated it and it should be good now.

  • disqus_Kn52PTnRrj

    Very usefull ! Where did you found this information ? I’m looking to select the period or the time step (month or week). Thank you

  • Thook

    Great great work. Would you give us some insight on how you sniff these connections ? It would be as much interesting as the data you allow us to retrieve !

    • iweczek

      I’m happy to explain anything in more detail but this was just looking at the requests and responses in network tab of the developer console of Chrome as I was browsing various pages in Google Trends.

  • buenosdiaz

    Awesome work! Thank you for that.

    Can you explain how i can change correctly the parameters in the ajax request?

    Almost every change i do results in an error.

    For example:

    curl –data “ajax=1&cid=actors&geo=DE&date=201409″ http://www.google.com/trends/topcharts/trendingchart

    I changed the geo and the date parameter..

  • atul

    hi, is there a way to find the area under the curve??

  • Doc Orkenstein

    Very good and useful article!

    After several request I get error:

    “We’re sorry but there’s been an error. You have reached your quota limit. Please try again later.”

    Any chance to avoid it?

  • Rohit

    Wow! great article, Can you also explain how I can tweak the value of the geo parameter to get top charts for other places? I get nothing when I try the below POST request
    curl –data “ajax=1&cid=actors&geo=DE&date=201310″ http://www.google.com/trends/topcharts/trendingchart

    • iweczek

      Take a look at my answer to buenosdiaz below. Your call looks correct but Google is not returning that data

    • http://www.movieovo.com/ Ivan

      Google has limit the requests for bot. You may get http 203. I have tested it.

  • http://www.sexemessenger.biz/ Sexemessenger

    This was a great post, with this information I would be able to extract the keywords I am interested in and create a dynamic visualization directly from Google trends, thanks again.

  • Eric Turner

    Can this technique be used to find specific keyword searches from or within a given area? More specifically, could one select a small region like a county or city to see if certain queries were made from there in a given amount of time?

  • 鴻毅 吳

    Hi,This tutorial really helps me a lot to fetch google trend data.However,I am curious about this response json data “http://hawttrends.appspot.com/api/terms/”.How to know what region correspond to the number of this format.Like:”1″ corresponds to US and “4″ corresponds to Japan etc.Hmm…I just know a little about above region.Any help?

    • iweczek

      Here you go:


      United States:2












      Costa Rica:e


      Czech Republic:g


      Dominican Republic:i



      El Salvador:l









      Hong Kong:u














      New Zealand:18









      Puerto Rico:1h



      Saudi Arabia:1k






      South Africa:1q

      South Korea:1r









      United Arab Emirates:20

      United Kingdom:21




      • 鴻毅 吳

        Thanks first!Actually,I can’t figure it out.Do we use the same url,”http://hawttrends.appspot.com/api/terms/” ? Because the json strings inside are only 1,3,4…..52,there are no a,b,c…z and 1a,1b…..1z that you mentioned.I’m confused…

        • iweczek

          oh, now I get what you are looking for. Here is the map:


          • 鴻毅 吳

            yap!This is what I am searchinG for. Enthusiastically thanks!

  • dipen

    Hey superb article, made my things pity easier. I have a question to add,
    Can we get the forecast data from google trends?

    • iweczek

      I don’t think so. I have collected the data over a few years and many things repeat so there is some forecasting that could happen but I don’t think anyone really knows what people will search for in the future. Often, top searches are generally driven by unpredictable real time events.

  • Raju Mohan


    Great work .

    I just want to get google trends data “https://www.google.com/trends/” datas

    by passing the geo=$$$ and category=$$

    eg : https://www.google.co.in/trends/home/m/AU

    Get the Health treadns of Australia. Is is posible to get ????.

    And i also want to take the youtube trends .

    I got a solution to take the favorites videos by reagion .


    But i can pass gender in it . How can i pass gender in Youtube video search ????

    Thanks in advance.

  • Raju Mohan

    Realy Great work man .

    I just want to get google trends data https://www.google.com/trends/ datas

    by passing the geo=$$$ and category=$$

    eg : https://www.google.co.in/trends/home/m/AU

    to get the Health treadns of Australia. Is is posible ????.

    And i also want to take the yoube trends .

    I got a solution to take the favorites videos by reagion .


    But i can pass gender . How can i pass gender in Youtube video search ????

    Thanks in advance.

  • Rogue Hogue

    I’ve built a python library along the same lines. https://github.com/dreyco676/pytrends

  • LNGCh

    It is possible to use google trends for only image visualization? Images instead words?

  • eX

    Is there any way of getting the data for different US states over time? Or does one need to know all of their 2 digit codes, and then iterate over them in geo?

  • Harry Wang

    google.load(‘visualization’, ’1′);

    function queryInit(){
    var url = ‘http://www.google.com/trends/fetchComponent?q=asdf,qwerty&cid=TIMESERIES_GRAPH_0&export=3′;
    var query = new google.visualization.Query(url)

    function handleQueryResponse(response) {

    use google chart to gab/present data

  • Idemo Radimo

    i tried (within command line) code that you provided for retrieving large JSON (1mb). But so far, i am getting only small JSON response:
    “summaryMessage”: “Showing latest searches. Updated 1hour ago”, “dataUpdateTime”:1.4446368E9,
    I don’t know what i am doing wrong…

  • 鴻毅 吳

    May I ask a question about the geo value ?
    What country codes do the Uri offer to retrieve,Could you supply me a list?
    Thanks a lot.