pat310 / google-trends-api

An API layer on top of google trends
https://www.npmjs.com/package/google-trends-api
MIT License
877 stars 175 forks source link

Api data not working #110

Open hfldrd opened 6 years ago

hfldrd commented 6 years ago

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 commented 6 years ago

@pat310

sopko16 commented 6 years ago

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 commented 6 years ago

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