forked from pat310/google-trends-api
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexamples.js
132 lines (113 loc) · 3.56 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
'use strict';
// var googleTrends = require('./lib/google-trends-api.min.js');
/* ******************* Autocomplete **************************/
// googleTrends.autoComplete({keyword: 'Back to school'})
// .then((res) => {
// console.log('this is res', res);
// })
// .catch((err) => {
// console.log('got the error', err);
// console.log('error message', err.message);
// console.log('request body', err.requestBody);
// });
/* ******************* Interest over time **************************/
// googleTrends.interestOverTime({keyword: 'Valentines Day'})
// .then((res) => {
// console.log('this is res', res);
// })
// .catch((err) => {
// console.log('got the error', err);
// console.log('error message', err.message);
// console.log('request body', err.requestBody);
// });
// googleTrends.interestOverTime({
// keyword: 'Valentines Day',
// startTime: new Date(Date.now() - (4 * 60 * 60 * 1000)),
// granularTimeResolution: true,
// }, function(err, results) {
// if (err) console.log('oh no error!', err);
// else console.log(results);
// });
/* ****** Interest over time - Set a custom timezone ***************/
// googleTrends.interestOverTime({
// keyword: 'Valentines Day',
// timezone: new Date().getTimezoneOffset() / 60,
// }, function(err, results) {
// if (err) console.log('oh no error!', err);
// else console.log(results);
// });
/* ****** Interest over time - Comparing multiple keywords *********/
// googleTrends.interestOverTime({keyword: ['Valentines Day', 'Christmas Day']})
// .then((res) => {
// console.log('this is res', res);
// })
// .catch((err) => {
// console.log('got the error', err);
// })
/* ******************* Interest by region **************************/
// googleTrends.interestByRegion({
// keyword: 'Donald Trump',
// startTime: new Date('2017-02-01'),
// endTime: new Date('2017-02-06'),
// resolution: 'CITY',
// })
// .then((res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// })
// googleTrends.interestByRegion({
// keyword: 'Donald Trump',
// startTime: new Date('2017-02-01'),
// endTime: new Date('2017-02-06'),
// geo: 'US-CA',
// })
// .then((res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// })
/* ******************* Related queries **************************/
// googleTrends.relatedQueries({keyword: 'Westminster Dog Show'})
// .then((res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// })
/* ******************* Related topics **************************/
// googleTrends.relatedTopics({
// keyword: 'Chipotle',
// startTime: new Date('2015-01-01'),
// endTime: new Date('2017-02-10'),
// })
// .then((res) => {
// console.log(res);
// })
// .catch((err) => {
// console.log(err);
// });
/* ************************* RealTime Trending Searches ******************/
// googleTrends.realTimeTrends({
// geo: 'US',
// category: 'all',
// }, function(err, results) {
// if (err) console.log('oh no error!', err);
// else console.log(results);
// });
/* *********************** Daily Trends *******************************/
// Please note that google only keeps around T-15 days of daily trends information.
// TrendDate designation that go too far back in the past will result in an error.
// Note: TrendDate is optional and will default to currentDate
// googleTrends.dailyTrends({
// trendDate: new Date('2019-01-10'),
// geo: 'US',
// }, function(err, results) {
// if (err) {
// console.log('oh no error!', err);
// }else{
// console.log(results);
// }
// });