forked from pat310/google-trends-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
examples.js
154 lines (130 loc) · 5.67 KB
/
examples.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
'use strict';
var googleTrends = require('./index.js');
var util = require('util');
//uncomment the code within each example to run it
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 1 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= trendData =~=~=~=~=~=~=~=~=~=~ */
// // Parameters: array of key words (required)
// // optionally as the first argument pass an object instead: {keywords: ['dog']}
// googleTrends.trendData({keywords: 'OJ Simpson'})
// .then(function(trendData){
// console.log('here are the results', util.inspect(trendData, {showHidden: false, depth: null}));
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });
// // Trend data example with multiple keywords
// googleTrends.trendData(['swimming', 'olympics'])
// .then(function(trendData){
// console.log('here are the results', util.inspect(trendData, {showHidden: false, depth: null}));
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });
// // Trend data example with a time period provided (timePeriod is an optional parameter)
// googleTrends.trendData({keywords: 'OJ Simpson', timePeriod: {type: 'day', value: 5}})
// .then(function(trendData){
// console.log('here are the results', util.inspect(trendData, {showHidden: false, depth: null}));
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 2 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= topRelated =~=~=~=~=~=~=~=~=~=~ */
// // Parameters: array of key words (optional), country as a string (optional, 'US' is default)
// // optionally as the first argument pass an object: {keywords: ['dog'], geo: 'US'}
// googleTrends.topRelated({keywords: 'dog house'})
// .then(function(topRelated){
// console.log("here are the topRelated", topRelated);
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });
// // topRelated example with timePeriod object
// googleTrends.topRelated({keywords: 'dog house', timePeriod: {type: 'hour', value: 5}})
// .then(function(topRelated){
// console.log("here are the topRelated", topRelated);
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 3 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= hotTrends =~=~=~=~=~=~=~=~=~=~ */
// //Parameters: takes a country as a string (optional, 'US' is default)
// // optionally as the first argument pass an object: {geo: 'US'}
// googleTrends.hotTrends('US')
// .then(function(results){
// console.log("these are the results", results);
// })
// .catch(function(err){
// console.log("there was an err", err);
// });
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 4 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= hotTrendsDetail =~=~=~=~=~=~=~=~=~=~ */
// //Parameters: takes a country as a string (optional, 'US' is default)
// // optionally as the first argument pass an object: {geo: 'US'}
// googleTrends.hotTrendsDetail()
// .then(function(results){
// console.log('here are the results', util.inspect(results, {showHidden: false, depth: null}));
// })
// .catch(function(err){
// console.log("there was an err", err);
// });
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 5 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= top30in30 =~=~=~=~=~=~=~=~=~=~ */
// //Parameters: none
// googleTrends.top30in30()
// .then(function(results){
// console.log('here are the results', util.inspect(results, {showHidden: false, depth: null}));
// })
// .catch(function(err){
// console.log("there was an error", err);
// });
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 6 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= allTopCharts =~=~=~=~=~=~=~=~=~=~ */
// // Parameters: date in format yyyymm where January is 01 (optional, today's date is default), country code as string (optional, 'US' is default)
// // optionally as the first argument pass an object: {geo: 'US', date: '201601'}
// googleTrends.allTopCharts({geo: 'US', date: '201601'})
// .then(function(results){
// console.log('here are the results', util.inspect(results, {showHidden: false, depth: null}));
// })
// .catch(function(err){
// console.log("there was an error", err);
// });
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 7 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= categoryTopCharts =~=~=~=~=~=~=~=~=~=~ */
// //Parameters: category (required), date in format yyyymm where January is 01 (optional, today's date is default), country code as string (optional, 'US' is default)
// // optionally as the first argument pass an object: {category: 'actors', geo: 'US', date:'201601'}
// googleTrends.categoryTopCharts({category: 'actors', geo: 'US', date:'201601'})
// .then(function(results){
// console.log('here are the results', util.inspect(results, {showHidden: false, depth: null}));
// })
// .catch(function(err){
// console.log('there was an error', err);
// });
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 8 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= risingSearches =~=~=~=~=~=~=~=~=~=~ */
// // Parameters: array of key words (optional), country as a string (optional, 'US' is default)
// // optionally as the first argument pass an object: {keywords: ['dog'], geo: 'US'}
// googleTrends.risingSearches({keywords: 'dog house'})
// .then(function(risingSearches){
// console.log("here are the risingSearches", risingSearches);
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });
// // risingSearches example with timePeriod object
// googleTrends.risingSearches({keywords: 'dog house', timePeriod: {type: 'hour', value: 5}})
// .then(function(risingSearches){
// console.log("here are the risingSearches", risingSearches);
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });