Unofficial Google Trends API for Go

Google Trends API for Go

Unofficial Google Trends API for Golang

Mentioned in Awesome Go Go Doc Coverage Status Go Report Card License

gogtrends is API wrapper which allows to get reports from Google Trends.

All contributions, updates and issues are warmly welcome.

Installation

go get -u github.com/groovili/gogtrends

Debug

To see request-response details use gogtrends.Debug(true)

Usage

Daily and Realtime trends used as it is. For both methods user interface language are required. For Realtime trends category is required param, list of available categories - TrendsCategories.

Please notice that Realtime trends are available only for limited list of locations.

For InterestOverTime, InterestByLocation and Related - widget and user interface language are required.

To get widget you should call Explore methods first, it will return constant list of available widgets, every widget corresponds to methods above.

Widget includes request params and unique token for every method.

Also Explore method supports single and multiple items for comparision. Please take a look at ExploreRequest input. It supports search by multiple categories and locations which you can get as tree structure by ExploreCategories and ExploreLocations.

Please notice, when you call Explore method for keywords comparison, two first widgets would be for all of compared items, next widgets would be for each of individual items.

Available methods

  • Daily(ctx context.Context, hl, loc string) ([]*TrendingSearch, error) - daily trends descending ordered by days and articles corresponding to it.

  • Realtime(ctx context.Context, hl, loc, cat string) ([]*TrendingStory, error) - represents realtime trends with included articles and sources.

  • Explore(ctx context.Context, r *ExploreRequest, hl string) ([]*ExploreWidget, error) - widgets with tokens. Every widget is related to specific method (InterestOverTime, InterestByLocation, Related) and contains required token and request information.

  • InterestOverTime(ctx context.Context, w *ExploreWidget, hl string) ([]*Timeline, error) - interest over time, dots for chart.

  • InterestByLocation(ctx context.Context, w *ExploreWidget, hl string) ([]*GeoMap, error) - interest by location, list for map with geo codes and interest values.

  • Related(ctx context.Context, w *ExploreWidget, hl string) ([]*RankedKeyword, error) - related topics or queries, supports two types of widgets.

  • TrendsCategories() map[string]string - available categories for Realtime trends.

  • ExploreCategories(ctx context.Context) (*ExploreCatTree, error) - tree of categories for explore and comparison. Called once, then returned from cache.

  • ExploreLocations(ctx context.Context) (*ExploreLocTree, error) - tree of locations for explore and comparison. Called once, then returned from cache.

Parameters

  • hl - string, user interface language

  • loc - string, uppercase location (geo) country code, example "US" - United States

  • cat - string, lowercase category for real time trends, example "all" - all categories

  • exploreReq - ExploreRequest struct, represents search or comparison items.

  • widget - ExploreWidget struct, specific for every method, can be received by Explore method.

Examples

Working detailed examples for all methods and cases can be found in example folder. Short version below.

// Daily trends
ctx := context.Background()
dailySearches, err := gogtrends.Daily(ctx, "EN", "US")
// Get available trends categories and realtime trends
cats := gogtrends.TrendsCategories()
realtime, err := gogtrends.Realtime(ctx, "EN", "US", "all")
// Explore available widgets for keywords and get all available stats for it
explore, err := gogtrends.Explore(ctx, 
	    &gogtrends.ExploreRequest{
            ComparisonItems: []*gogtrends.ComparisonItem{
                {
                    Keyword: "Go",
                    Geo:     "US",
                    Time:    "today 12-m",
                },
            },
            Category: 31, // Programming category
            Property: "",
        }, "EN")

// Interest over time
overTime, err := gogtrends.InterestOverTime(ctx, explore[0], "EN")

// Interest by location
byLoc, err := gogtrends.InterestByLocation(ctx, explore[1], "EN")

// Related topics for keyword
relT, err := gogtrends.Related(ctx, explore[2], "EN")

// Related queries for keyword
relQ, err := gogtrends.Related(ctx, explore[3], "EN")

// Compare keywords interest
compare, err := gogtrends.Explore(ctx, 
	    &gogtrends.ExploreRequest{
            ComparisonItems: []*gogtrends.ComparisonItem{
                {
                    Keyword: "Go",
                    Geo:     "US",
                    Time:    "today 12-m",
                },
                {
                    Keyword: "Python",
                    Geo:     "US",
                    Time:    "today 12-m",
                },
                {
                    Keyword: "PHP",
                    Geo:     "US",
                    Time:    "today 12-m",
                },                               
            },
            Category: 31, // Programming category
            Property: "",
        }, "EN")

Licence

Package is distributed under MIT Licence.

Owner
Max Ivanov
Software Engineer
Max Ivanov
Similar Resources

Unofficial getpocket.com API Golang SDK

GetPocket API Golang SDK https://getpocket.com/developer/ Example usage: package main import ( "context" "fmt" pocket "github.com/ernur-eskermes/p

Nov 28, 2021

(unofficial) TexTra API client library

go-textra This is a library that translates with みんなの自動翻訳(minnano-jidou-honyaku)@textra's API. You need a textra account. package main import ( "fmt

Dec 13, 2021

unofficial golang api for proxybonanza.com

ProxyGonanza -- import "git.tcp.direct/kayos/proxygonanza" Documentation const ( APIBaseURL = "https://proxybonanza.com/api/v1/" ) func GetMyIP func

Oct 30, 2022

Unofficial golang implementation for the pipl.com search API

Unofficial golang implementation for the pipl.com search API

go-pipl The unofficial golang wrapper for the pipl.com API. Table of Contents Installation Documentation Examples & Tests Benchmarks Code Standards Us

Nov 6, 2022

Unofficial golang implementation for the Preev API

Unofficial golang implementation for the Preev API

go-preev The unofficial golang implementation for the Preev.pro API Table of Contents Installation Documentation Examples & Tests Benchmarks Code Stan

Sep 13, 2022

🔗 Unofficial golang implementation for the NOWNodes API

🔗 Unofficial golang implementation for the NOWNodes API

go-nownodes The unofficial golang implementation for the NOWNodes.io API Table of Contents Installation Documentation Examples & Tests Benchmarks Code

Jan 30, 2022

Golang SDK for Dusupay payment gateway API (Unofficial)

Dusupay API SDK GO (Unofficial) Description Unofficial Dusupay payment gateway API Client for Go API documentation https://docs.dusupay.com/ Installat

Sep 27, 2022

A Wrapper Client for Google Spreadsheet API (Sheets API)

Senmai A Wrapper Client for Google Spreadsheet API (Sheets API) PREPARATION Service Account and Key File Create a service account on Google Cloud Plat

Nov 5, 2021

Twilight is an unofficial Golang SDK for Twilio APIs

Twilight is an unofficial Golang SDK for Twilio APIs

Twilight is an unofficial Golang SDK for Twilio APIs. Twilight was born as a result of my inability to spell Twilio correctly. I searched for a Twillio Golang client library and couldn’t find any, I decided to build one. Halfway through building this, I realized I had spelled Twilio as Twillio when searching for a client library on Github.

Jul 2, 2021
Comments
  • [Debug] Response: 429 Too Many Requests

    [Debug] Response: 429 Too Many Requests

    Hi How can i avoid this error, everytime i try to recover data i find this error:

    [Debug] Response: &{429 Too Many Requests 429 HTTP/2.0 2 0 map[Alt-Svc:[h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"] Cache-Control:[no-cache, no-store, max-age=0, must-revalidate] Content-Security-Policy:[script-src 'nonce-MbgHlkCAIUd6Dor2BMruvw' 'unsafe-inline' 'strict-dynamic' https: http: 'unsafe-eval';object-src 'none';base-uri 'self';report-uri /trends/cspreport] Content-Type:[text/html; charset=utf-8] Cross-Origin-Opener-Policy:[same-origin-allow-popups] Date:[Tue, 22 Nov 2022 15:21:38 GMT] Expires:[Mon, 01 Jan 1990 00:00:00 GMT] P3p:[CP="This is not a P3P policy! See g.co/p3phelp for more info."] Pragma:[no-cache] Server:[GSE] Set-Cookie:[NID=511=UBRQU8IhfIWTbiMogok59t01CWb16d3vqnvj0QiLL-i9ywC6SYQC63PfHT7s2DutzzVD7ZUOmSgwjbPVGK1vVDZVWHkwqUKNXPliOjD3Soee6DX7NsggLvPxYfuEBKk1tB9sjvrZDX1P9JS0jdQRkhLsHhizsbGlZA6V6U50kkc; expires=Wed, 24-May-2023 15:21:38 GMT; path=/; domain=.google.com; HttpOnly] X-Content-Type-Options:[nosniff] X-Frame-Options:[SAMEORIGIN] X-Xss-Protection:[1; mode=block]] 0xc0000a9350 -1 [] false true map[] 0xc0001a4000 0xc0003020b0}

    thanks

Go client for the YNAB API. Unofficial. It covers 100% of the resources made available by the YNAB API.

YNAB API Go Library This is an UNOFFICIAL Go client for the YNAB API. It covers 100% of the resources made available by the YNAB API. Installation go

Oct 6, 2022
The NVD API is an unofficial Go wrapper around the NVD API.

NVD API The NVD API is an unofficial Go wrapper around the NVD API. Supports: CVE CPE How to use The following shows how to basically use the wrapper

Jan 7, 2023
An unofficial API based on Hasura API Reference.

An unofficial API based on Hasura API Reference.

Apr 14, 2022
Correct the timestamp of photo/video of Google Photo from Google takeout

Correct Timestamp of Google Photo from Google Takeout Development Environment: Ubuntu 20.04 Go 1.17 Usage Require Go 1.16 or later to build. go build

Sep 9, 2022
Unofficial SDK of official notion API in Go

notion-go A go client for the Notion API Description This aims to be an unofficial Go version of the official SDK which is written in JavaScript. Inst

May 12, 2022
Unofficial Anilist.co GraphQL API wrapper for GoLang.

anilistWrapGo Unofficial Anilist.co GraphQL API wrapper for GoLang. Examples All examples are present as tests in test directory. Below are a few snip

Dec 20, 2022
Avanza Unofficial GO API Client

Avanza Unofficial GO API Client Please note that I am not affiliated with Avanza Bank AB in any way. The underlying API can be taken down or changed w

Jan 7, 2023
Unofficial Go SDK for GoPay Payments REST API

Unofficial Go SDK for GoPay Payments REST API Installation go get https://github.com/apparently-studio/gopay-go-api Basic usage client := gopay.NewCl

Nov 18, 2022
unofficial NBA Stats API SDK in Go

nba api go (nag) is an unofficial NBA Stats API in Go. it is very much a Go port of nba_api. endpoints alltimeleadersgrids assistleaders assisttracker

Sep 23, 2022
Unofficial but convenient Go wrapper around the NVD API

NVD API The NVD API is an unofficial Go wrapper around the NVD API. Supports: CVE CPE How to use The following shows how to basically use the wrapper

Nov 1, 2021