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

Doing a basic function with startTime and getting the value from 3 days ago.

Open ethanolle opened this issue 5 years ago • 3 comments

Hello I'm doing a basic function with the google-trends-api and I'm getting the last value from 3 days ago. For example: const googleTrends = require("google-trends-api");

const getData = (stockName) => { let week = 604800000; googleTrends.interestOverTime( { keyword: "Valentines Day", startTime: new Date(Date.now() - week), }, function (err, results) { if (err) console.log("oh no error!", err); else console.log(results + Date.now()); } ); };

getData("btc");

exports.getData = getData; ` And I also can't get the value from the last day. and the last value that I get is "formattedTime":"Feb 9, 2021","formattedAxisTime":"Feb 9","value":[100],"hasData":[true]," and today is the the 12 of February and I'm getting the value from the 9. hope for help thanks pat310 for this amazing npm

ethanolle avatar Feb 12 '21 08:02 ethanolle

I too am having this issue. I noticed that the Google Trends site also lops off the last two days unless the time frame is 7 days or less, but I can't get yesterday or today's data no matter what I put into startTime.

        const end = moment().toDate();

        const start = moment().subtract(6, 'days').toDate();

        const options = {
            keyword: 'blah',
            property: 'web',
            startTime: start,
            // endTime: end
        }

        const result = JSON.parse(await googleTrends.interestOverTime(options));

gentlemanjohn avatar Feb 18 '21 01:02 gentlemanjohn

I'm able to get recent data if I change startTime to 6 days ago or less and granularTimeResolution: true

gentlemanjohn avatar Feb 18 '21 01:02 gentlemanjohn

I just understood that's the probleme is not the NPM but google trends that's not giving any value of the last days with more than 1 week

ethanolle avatar Feb 18 '21 06:02 ethanolle