Documentation
¶
Index ¶
- Variables
- func Debug(debug bool)
- func TrendsCategories() map[string]string
- type ComparisonItem
- type ExploreCatTree
- type ExploreLocTree
- type ExploreRequest
- type ExploreResponse
- type ExploreWidget
- type GeoMap
- type KeywordRestriction
- type KeywordTopic
- type KeywordsRestriction
- type RankedKeyword
- type RequestOptions
- type SearchArticle
- type SearchImage
- type SearchTitle
- type Timeline
- type TrendingArticle
- type TrendingSearch
- type TrendingSearchDays
- type TrendingStory
- type WidgetComparisonItem
- type WidgetResponse
- type WidgetType
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCategory - user input is not in trendsCategories list (binding to available options in Google Trends) ErrInvalidCategory = errors.New("invalid category param") // ErrRequestFailed - response status != 200 ErrRequestFailed = errors.New("failed to perform http request") // ErrInvalidWidgetType - provided widget is invalid or is used for another method ErrInvalidWidgetType = errors.New("invalid widget type") )
Functions ¶
func TrendsCategories ¶
TrendsCategories return list of available categories for Realtime method as [param]description map.
Types ¶
type ComparisonItem ¶
type ComparisonItem struct {
Keyword string `json:"keyword" bson:"keyword"`
Geo string `json:"geo,omitempty" bson:"geo"`
Time string `json:"time" bson:"time"`
GranularTimeResolution bool `json:"granularTimeResolution" bson:"granular_time_resolution"`
StartTime string `json:"startTime" bson:"start_time"`
EndTime string `json:"endTime" bson:"end_time"`
}
ComparisonItem it's concrete search keyword with Geo (can be found with ExploreLocations method) locality and Time period
type ExploreCatTree ¶
type ExploreCatTree struct {
Name string `json:"name" bson:"name"`
ID int `json:"id" bson:"id"`
Children []*ExploreCatTree `json:"children" bson:"children"`
}
ExploreCatTree - available categories list tree
func ExploreCategories ¶
func ExploreCategories(ctx context.Context) (*ExploreCatTree, error)
ExploreCategories gets available categories for explore and comparison and caches it in client. Deprecated: This function uses the old Google Trends API which may be unstable.
type ExploreLocTree ¶
type ExploreLocTree struct {
Name string `json:"name" bson:"name"`
ID string `json:"id" bson:"id"`
Children []*ExploreLocTree `json:"children" bson:"children"`
}
ExploreLocTree - available locations list tree
func ExploreLocations ¶
func ExploreLocations(ctx context.Context) (*ExploreLocTree, error)
ExploreLocations gets available locations for explore and comparison and caches it in client. Deprecated: This function uses the old Google Trends API which may be unstable.
type ExploreRequest ¶
type ExploreRequest struct {
ComparisonItems []*ComparisonItem `json:"comparisonItem" bson:"comparison_items"`
Category int `json:"category" bson:"category"`
Property string `json:"property" bson:"property"`
}
ExploreRequest it's an input which can contain multiple items (keywords) to discover category can be found in ExploreCategories output
type ExploreResponse ¶
type ExploreResponse []*ExploreWidget
func Explore ¶
func Explore(ctx context.Context, r *ExploreRequest, hl string) (ExploreResponse, error)
Explore list of widgets with tokens. Every widget is related to specific method (`InterestOverTime`, `InterestOverLoc`, `RelatedSearches`, `Suggestions`) and contains required token and request information.
func (ExploreResponse) GetWidgetsByOrder ¶
func (e ExploreResponse) GetWidgetsByOrder(i int) ExploreResponse
func (ExploreResponse) GetWidgetsByType ¶
func (e ExploreResponse) GetWidgetsByType(t WidgetType) ExploreResponse
func (ExploreResponse) Len ¶
func (e ExploreResponse) Len() int
func (ExploreResponse) Less ¶
func (e ExploreResponse) Less(i, j int) bool
func (ExploreResponse) Sort ¶
func (e ExploreResponse) Sort()
func (ExploreResponse) Swap ¶
func (e ExploreResponse) Swap(i, j int)
type ExploreWidget ¶
type ExploreWidget struct {
Token string `json:"token" bson:"token"`
Type string `json:"type" bson:"type"`
Title string `json:"title" bson:"title"`
ID string `json:"id" bson:"id"`
Request *WidgetResponse `json:"request" bson:"request"`
}
ExploreWidget - output of Explore method, required for InterestOverTime, InterestByLocation and Related methods. Globally it's a structure related to Google Trends UI and contains mostly system info
type GeoMap ¶
type GeoMap struct {
GeoCode string `json:"geoCode" bson:"geo_code"`
GeoName string `json:"geoName" bson:"geo_name"`
Value []int `json:"value" bson:"value"`
FormattedValue []string `json:"formattedValue" bson:"formatted_value"`
MaxValueIndex int `json:"maxValueIndex" bson:"max_value_index"`
HasData []bool `json:"hasData" bson:"has_data"`
}
GeoMap - it's representation of interest by location. Mostly used for maps
func InterestByLocation ¶
InterestByLocation as list of `GeoMap`, with geo codes and interest values.
type KeywordRestriction ¶
type KeywordRestriction struct {
Type string `json:"type" bson:"type"`
Value string `json:"value" bson:"value"`
}
KeywordRestriction - specific keyword limitation. Part of KeywordsRestriction
type KeywordTopic ¶
type KeywordTopic struct {
Mid string `json:"mid" bson:"mid"`
Title string `json:"title" bson:"title"`
Type string `json:"type" bson:"type"`
}
KeywordTopic - is a part of RankedKeyword
type KeywordsRestriction ¶
type KeywordsRestriction struct {
Keyword []*KeywordRestriction `json:"keyword" bson:"keyword"`
}
KeywordsRestriction - system info for keywords limitations, not used. part of WidgetResponse
type RankedKeyword ¶
type RankedKeyword struct {
Query string `json:"query,omitempty" bson:"query"`
Topic KeywordTopic `json:"topic,omitempty" bson:"topic"`
Value int `json:"value" bson:"value"`
FormattedValue string `json:"formattedValue" bson:"formatted_value"`
HasData bool `json:"hasData" bson:"has_data"`
Link string `json:"link" bson:"link"`
}
RankedKeyword - it's representation of related to search items
func Related ¶
func Related(ctx context.Context, w *ExploreWidget, hl string) ([]*RankedKeyword, error)
Related topics or queries, list of `RankedKeyword`, supports two types of widgets.
type RequestOptions ¶
type RequestOptions struct {
Property string `json:"property" bson:"property"`
Backend string `json:"backend" bson:"backend"`
Category int `json:"category" bson:"category"`
}
RequestOptions - part of WidgetResponse
type SearchArticle ¶
type SearchArticle struct {
Title string `json:"title" bson:"title"`
TimeAgo string `json:"timeAgo" bson:"time_ago"`
Source string `json:"source" bson:"source"`
Image *SearchImage `json:"image" bson:"image"`
URL string `json:"url" bson:"url"`
Snippet string `json:"snippet" bson:"snippet"`
}
SearchArticle is a news relative to trending search
type SearchImage ¶
type SearchImage struct {
NewsURL string `json:"newsUrl" bson:"news_url"`
Source string `json:"source" bson:"source"`
ImageURL string `json:"imageUrl" bson:"image_url"`
}
SearchImage is a picture of trending search
type SearchTitle ¶
type SearchTitle struct {
Query string `json:"query" bson:"query"`
}
SearchTitle is a user query string for daily trending search
type Timeline ¶
type Timeline struct {
Time string `json:"time" bson:"time"`
FormattedTime string `json:"formattedTime" bson:"formatted_time"`
FormattedAxisTime string `json:"formattedAxisTime" bson:"formatted_axis_time"`
Value []int `json:"value" bson:"value"`
HasData []bool `json:"hasData" bson:"has_data"`
FormattedValue []string `json:"formattedValue" bson:"formatted_value"`
}
Timeline - it's representation of interest to trend trough period timeline. Mostly used for charts
func InterestOverTime ¶
InterestOverTime as list of `Timeline` dots for chart.
type TrendingArticle ¶
type TrendingArticle struct {
Title string `json:"articleTitle" bson:"title"`
URL string `json:"url" bson:"url"`
Source string `json:"source" bson:"source"`
Time string `json:"time" bson:"time"`
Snippet string `json:"snippet" bson:"snippet"`
}
TrendingArticle is an article relative to trending story
type TrendingSearch ¶
type TrendingSearch struct {
Title *SearchTitle `json:"title" bson:"title"`
FormattedTraffic string `json:"formattedTraffic" bson:"formatted_traffic"`
Image *SearchImage `json:"image" bson:"image"`
Articles []*SearchArticle `json:"articles" bson:"articles"`
}
TrendingSearch is a representation trending search in period of 24 hours
func Daily ¶
func Daily(ctx context.Context, hl, loc string) ([]*TrendingSearch, error)
Daily gets daily trends descending ordered by days and articles corresponding to it. Deprecated: This function uses the old Google Trends API which may be unstable. Use DailyNew instead, which uses the new Google Trends API.
type TrendingSearchDays ¶
type TrendingSearchDays struct {
FormattedDate string `json:"formattedDate" bson:"formatted_date"`
Searches []*TrendingSearch `json:"trendingSearches" bson:"searches"`
}
func DailyTrendingSearch ¶
func DailyTrendingSearch(ctx context.Context, hl, loc string) ([]*TrendingSearchDays, error)
DailyTrendingSearch gets daily trends descending ordered by days and articles corresponding to it. Deprecated: This function uses the old Google Trends API which may be unstable. Use DailyTrendingSearchNew instead, which uses the new Google Trends API.
func DailyTrendingSearchNew ¶ added in v0.0.2
func DailyTrendingSearchNew(ctx context.Context, hl, loc string) ([]*TrendingSearchDays, error)
DailyTrendingSearchNew gets daily trends ordered by days using the new Google Trends API. It has the same parameters and return type as the original DailyTrendingSearch method.
type TrendingStory ¶
type TrendingStory struct {
Title string `json:"title" bson:"title"`
Image *SearchImage `json:"image" bson:"image"`
Articles []*TrendingArticle `json:"articles" bson:"articles"`
}
TrendingStory is a representation of realtime trend
func Realtime ¶
func Realtime(ctx context.Context, hl, loc, cat string) ([]*TrendingStory, error)
Realtime represents realtime trends with included articles and sources. Deprecated: This function uses the old Google Trends API which may be unstable. Consider using the new API methods for more reliable results.
type WidgetComparisonItem ¶
type WidgetComparisonItem struct {
Geo map[string]string `json:"geo,omitempty" bson:"geo"`
Time string `json:"time,omitempty" bson:"time"`
ComplexKeywordsRestriction KeywordsRestriction `json:"complexKeywordsRestriction,omitempty" bson:"complex_keywords_restriction"`
OriginalTimeRangeForExploreURL string `json:"originalTimeRangeForExploreUrl,omitempty" bson:"original_time_range_for_explore_url"`
}
WidgetComparisonItem - system info for comparison item part of WidgetResponse
type WidgetResponse ¶
type WidgetResponse struct {
Geo interface{} `json:"geo,omitempty" bson:"geo"`
Time string `json:"time,omitempty" bson:"time"`
Resolution string `json:"resolution,omitempty" bson:"resolution"`
Locale string `json:"locale,omitempty" bson:"locale"`
Restriction WidgetComparisonItem `json:"restriction" bson:"restriction"`
CompItem []*WidgetComparisonItem `json:"comparisonItem" bson:"comparison_item"`
RequestOpt RequestOptions `json:"requestOptions" bson:"request_option"`
KeywordType string `json:"keywordType" bson:"keyword_type"`
Metric []string `json:"metric" bson:"metric"`
Language string `json:"language" bson:"language"`
TrendinessSettings map[string]string `json:"trendinessSettings" bson:"trendiness_settings"`
DataMode string `json:"dataMode,omitempty" bson:"data_mode"`
UserConfig map[string]string `json:"userConfig,omitempty" bson:"user_config"`
UserCountryCode string `json:"userCountryCode,omitempty" bson:"user_country_code"`
}
WidgetResponse - system info for every available trends search mode
type WidgetType ¶
type WidgetType string
const ( IntOverTimeWidgetID WidgetType = "TIMESERIES" IntOverRegionID WidgetType = "GEO_MAP" RelatedQueriesID WidgetType = "RELATED_QUERIES" RelatedTopicsID WidgetType = "RELATED_TOPICS" )