google-trends-api icon indicating copy to clipboard operation
google-trends-api copied to clipboard

Api data not working

Open hfldrd opened this issue 7 years ago • 3 comments

The API is not getting any data from the last 72 hours. try any code, and it shows up blank

this is an example of non working code, if you change the date to june 11th it works

const express = require("express"); const trends = require('google-trends-api'); const app = express(); const moment = require('moment'); const PORT = process.env.PORT || 9090; const data = {}; const path = require('path');

googleTrends.interestOverTime({keyword: 'Valentines Day', startTime: new Date(Date.now() - (4 * 60 * 60 * 1000))}, function(err, results) { if (err) console.log('oh no error!', err); else console.log(results); });

hfldrd avatar Jun 14 '18 23:06 hfldrd

@pat310

hfldrd avatar Jun 25 '18 05:06 hfldrd

Check out the examples here, particularly the one at this line: https://github.com/pat310/google-trends-api/blob/master/examples.js#L29

I saw/thought the same thing. It looks like "granularTimeResolution" needs to be set for this to work in this case.

sopko16 avatar Jun 26 '18 17:06 sopko16

It is worth noting that I never see the API data match the web interface for data less than "daily" frequency -

const googleTrends = require('google-trends-api');

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);
});

WEB and CSV return this, when API is debugged it is not close to this: image

and the API appears to count time UP (into the future) when this is used (2:06 CST was the latest this data above is from. So 3:06 EST in that and should not be higher or going up): image

sopko16 avatar Jun 26 '18 19:06 sopko16