forked from pat310/google-trends-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.js
110 lines (91 loc) · 3.99 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
'use strict';
var googleTrends = require(__dirname + '/');
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: {keywords: ['dog']}
// googleTrends.trendData({keywords: 'OJ Simpson'})
// .then(function(trendData){
// console.log("here is the trendData", trendData);
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });
// Trend data example with multiple keywords
// googleTrends.trendData({keywords: ['Olympics', 'Michael Phelps']})
// .then(function(trendData){
// console.log("here is the trendData", trendData);
// })
// .catch(function(err){
// console.log("there was an error", err);
// return err;
// });
/* ~=~=~=~=~=~=~=~=~=~= EXAMPLE 2 =~=~=~=~=~=~=~=~=~=~ */
/* ~=~=~=~=~=~=~=~=~=~= topRelated =~=~=~=~=~=~=~=~=~=~ */
// // Parameters: array of key words (required), 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;
// });
/* ~=~=~=~=~=~=~=~=~=~= 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);
// });