Skip to content
Java based implementation of Unofficial Google Trends API
Branch: master
Clone or download
Latest commit 5040ce1 Jan 25, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
j-google-trends-api Not fully working version Jul 20, 2014
releases/org/freaknet/gtrends/j-google-trends-api Release 1.5.6 Mar 23, 2014
.gitignore Ignore maven-release plugin files Jan 25, 2014 Update Jan 25, 2015

Java Google Trends API (unofficial)

j-google-trends-api is a Java based implementation of Unofficial Google Trends API.

Google does not provide any API for its Trends services, this an unofficial Java implementation. Features:

  • Easily authenticates to Google's services
  • Parses CSV file as downloaded from Trends
  • Simply queries Trends by only configuring the request parameters
  • Supports Proxy configuration

A ready to use binary client for Google Trends is available here!

Download binaries


import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.NTCredentials;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.impl.client.DefaultHttpClient;
import org.freaknet.gtrends.api.GoogleAuthenticator;
import org.freaknet.gtrends.api.GoogleTrendsClient;
import org.freaknet.gtrends.api.GoogleTrendsCsvParser;
import org.freaknet.gtrends.api.GoogleTrendsRequest;
import org.freaknet.gtrends.api.exceptions.GoogleTrendsClientException;

public class App {

    public static void main(String[] args) throws GoogleTrendsClientException {
        String u = "";
        String p = "mypasswd";
        /* OPTIONAL: setup a proxy with NTLM authentication */
        HttpHost proxy = new HttpHost("", 8080, "http");
        Credentials credentials = new NTCredentials("myLogin", "myPasswd", "", "DOMAIN");
        DefaultHttpClient httpClient = new DefaultHttpClient();
        httpClient.getCredentialsProvider().setCredentials(new AuthScope(proxy.getHostName(), proxy.getPort()), credentials);
        httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

        /* Creates a new authenticator */
        GoogleAuthenticator authenticator = new GoogleAuthenticator(u, p, httpClient);
        /* Creates a new Google Trends Client */
        GoogleTrendsClient client = new GoogleTrendsClient(authenticator, httpClient);
        GoogleTrendsRequest request = new GoogleTrendsRequest("bananas");
        /* Here the default request params can be modified with getter/setter methods */
        String content = client.execute(request);
        /* The default request downloads a CSV available in content */
        GoogleTrendsCsvParser csvParser = new GoogleTrendsCsvParser(content);
        /* Get a specific section of the CSV */
        String section = csvParser.getSectionAsString("Top searches for", true);


Google has imposed new policies to restrict traffic from bots, these can be circumvented by using a set of anonimous proxies like . A new proxy has to be setup after 4 requests max.


Based on the original python version available here:


j-google-trends-api Java based implementation of Unofficial Google Trends API Copyright (C) 2013 Marco Tizzoni

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

You can’t perform that action at this time.