gtrendsR (version 1.3.4)

gtrends: Google Trends Query


The gtrends default method performs a Google Trends query for the ‘query’ argument and session ‘session’. Optional arguments for geolocation and category can also be supplied.


gtrends(query, geo, cat, session, ...)
"gtrends"(query = "", geo, cat, session, res = c(NA, "1h", "4h", "1d", "7d"), start_date = as.Date("2004-01-01"), end_date = as.Date(Sys.time()), ...)
"summary"(object, ...)
"plot"(x, type = c("trend", "geo"), which = 5, ind = 1L, ...)
"as.zoo"(x, ...)


A character vector with the actual Google Trends query keywords. Multiple keywords are possible using gtrends(c("NHL", "NBA", "MLB", "MLS")).
A character vector denoting geographic regions for the query, default to “all” for global queries. Multiple regions are possible using gtrends("NHL", c("CA", "US")).
A character denoting the category, defaults to “0”.
A valid session which can be created via gconnect. Users can either supply an explicit handle, or rely on the helper function .getDefaultConnection() to retrieve the current connection handle.
Additional parameters passed on in method dispatch.
Resolution of the trending data to be returned. One of c("1h", "4h", "1d", "7d"). If res is provided, then start_date and end_date parameters are ignored. See Query resolution for more information.
Starting date using yyyy-mm-dd format. Must be greater than 2004-01-01.
Starting date using yyyy-mm-dd format. Must be before than current date.
A gtrends object
A gtrends object
A character variable selecting the type of plot; permissible values are ‘trends’ (which is also the default), ‘geo’.
Block number containing the geographical data to plot.
A integer selecting the result set in case of multiple search terms.


An object of class ‘gtrends’ which is list with six elements containing the results.When type is equal to ‘trends’, the resulting ggplot2 object is returned silently.

Query resolution

By default, Google returns weekly information when the requested data spans a period greater than three months. It is also possible to obtain daily and hourly information. However, these are only available for a certain period prior to the current date. For instance, 1h, 7h, 1d and 7d denote trends data for the last 1 hour, last four hours, last day and last seven days respectively. Using one of the above res will return the corresponding hourly data. Note that data requested for a beriod between one and three months will be returned daily. For a period greater than three months, data will be always returned weekly.


## Not run: 
# session <- gconnect("", "psw")
# gtrends(c("NHL", "NBA", "MLB", "MLS"))
# gtrends("NHL", geo = c("CA", "US"))
# # Search only for the sport category.
# gtrends("NHL", geo = c("CA", "US"), cat = "0-20")
# # Trends between 2015-01-01 and 2015-03-01 in Sweeden. Will be daily data.
# gtrends("NHL", geo = c("SE"), start_date = "2015-01-01", end_date = "2015-03-01")
# # Trends between 2015-01-01 and 2015-04-01 in Sweeden. Will be weekly data.
# gtrends("NHL", geo = c("SE"), start_date = "2015-01-01", end_date = "2015-04-01")
# # Last 4 hours trends
# gtrends("NHL", geo = c("CA"), res = "4h")
# # Last 7 days trends
# gtrends("NHL", geo = c("CA"), res = "7d")
# ## End(Not run)