Package: simplifiedpytrends
simplified pytrendsSimplified version ofhttps://github.com/GeneralMills/pytrends: removed pandas dependency.IntroductionUnofficial API for Google TrendsAllows simple interface for automating downloading of reports from Google Trends. Main feature is to allow the script to login to Google on your behalf to enable a higher rate limit. Only good until Google changes their backend again :-P. When that happens feel free to contribute!Table of contensInstallationAPIAPI MethodsCommon API parametersInterest Over TimeCaveatsCreditsInstallationpip install simplifiedpytrendsRequirementsWritten for both Python 2.7+ and Python 3.3+Requires RequestsAPIConnect to Googlefrom simplifiedpytrends.request import TrendReq

pytrends = TrendReq(hl='en-US', tz=360)or if you want to use proxies as you are blocked due to Google rate limit:from simplifiedpytrends.request import TrendReq

pytrends = TrendReq(hl='en-US', tz=360, proxies = {'https': 'https://34.203.233.13:80'})Note: only https proxies will work, and you need to add the port number after the proxy ip addressBuild Payloadkw_list = ["Blockchain"]
pytrends.build_payload(kw_list, cat=0, timeframe='today 5-y', geo='', gprop='')Parameterskw_listRequiredKeywords to get data forAPI MethodsThe following API methods are available:Interest Over Time: returns historical, indexed data for when the keyword was searched most as shown on Google Trends' Interest Over Time section.Common API parametersMany API methods use the following:kw_listkeywords to get data forExample['Pizza']Currently supports only one parameterAdvanced KeywordsWhen using Google Trends dashboard Google may provide suggested narrowed search terms.For example"iron"will have a drop down of"Iron Chemical Element, Iron Cross, Iron Man, etc".Find the encoded topic by using the get_suggestions() function and choose the most relevant one for you.For example:https://www.google.com/trends/explore#q=%2Fm%2F025rw19&cmpt=q"%2Fm%2F025rw19"is the topic "Iron Chemical Element" to use this with pytrendsYou can also usepytrends.suggestions()to automate this.catCategory to narrow resultsFind available cateogies by inspecting the url when manually using Google Trends. The category starts aftercat=and ends before the next&or view thiswiki page containing all available categoriesFor example:"https://www.google.com/trends/explore#q=pizza&cat=71"'71'is the categoryDefaults to no categorygeoTwo letter country abbreviationFor example United States is'US'Defaults to WorldMore detail available for States/Provinces by specifying additonal abbreviationsFor example: Alabama would be'US-AL'For example: England would be'GB-ENG'tzTimezone OffsetFor example US CST is'360'timeframeDate to start fromDefaults to last 5yrs,'today 5-y'.Everything'all'Specific dates, 'YYYY-MM-DD YYYY-MM-DD' example'2016-12-14 2017-01-25'Specific datetimes, 'YYYY-MM-DDTHH YYYY-MM-DDTHH' example'2017-02-06T10 2017-02-12T07'Note Time component is based off UTCCurrent Time Minus Time Pattern:By Month:'today #-m'where # is the number of months from that date to pull data forFor example:'today 3-m'would get data from today to 3months agoNOTEGoogle uses UTC date as'today'Seems to only work for 1, 2, 3 months onlyDaily:'now #-d'where # is the number of days from that date to pull data forFor example:'now 7-d'would get data from the last weekSeems to only work for 1, 7 days onlyHourly:'now #-H'where # is the number of hours from that date to pull data forFor example:'now 1-H'would get data from the last hourSeems to only work for 1, 4 hours onlygpropWhat Google property to filter toExample'images'Defaults to web searchesCan beimages,news,youtubeorfroogle(for Google Shopping results)Interest Over Timepytrends.interest_over_time()Returns a sorted list of dict: containing "timestamp" and "data"CaveatsThis is not an official or supported APIGoogle may change aggregation level for items with very large or very small search volumeGoogle will send you an email saying that you had a new login after running this.Rate Limit is not publicly known, let me know if you have a consistent estimateOne user reports that 1,400 sequential requests of a 4 hours timeframe got them to the limit. (Replicated on 2 networks)It has been tested, and 60 seconds of sleep between requests (successful or not) is the correct amount once you reach the limit.For certain configurations the dependency lib certifi requires the environment variable REQUESTS_CA_BUNDLE to be explicitly set and exported. This variable must contain the path where the ca-certificates are saved or a SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] error is given at runtime.CreditsOriginal pytrends lib:https://github.com/GeneralMills/pytrendsMajor JSON revision ideas taken from pat310's JavaScript libraryhttps://github.com/pat310/google-trends-apiConnecting to google code heavily based off Stack Overflow posthttp://stackoverflow.com/questions/6754709/logging-in-to-google-using-pythonWith some ideas pulled from Matt Reid's Google Trends APIhttps://bitbucket.org/mattreid9956/google-trend-api/overview