pat310 / google-trends-api

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

Completely different results depending on the location? #147

Open przemoo83 opened 3 years ago

przemoo83 commented 3 years ago

It completely blew my mind. I have the same piece of code on my localhost and remote server (Heroku). For the query with identical parameters I get completely different results depending on whether I run it locally or on Heroku server. The difference is not trivial, it can be something like 0 to 100. What is going on here? EXAMPLE:

const googleTrends = require('google-trends-api');
googleTrends.interestOverTime(
  {
    keyword: 'wynajem aut',
    startTime: new Date('2020-11-01'),
    endTime: new Date('2020-11-07'),
    geo: 'PL'
  }
  )
.then(function(results){
  console.log(results);
})
.catch(function(err){
  console.error(err);
});

LOCALHOST RESPONSE:

{"default":{"timelineData":[{"time":"1604188800","formattedTime":"Nov 1, 2020","formattedAxisTime":"Nov 1","value":[79],"hasData":[true],"formattedValue":["79"]},{"time":"1604275200","formattedTime":"Nov 2, 2020","formattedAxisTime":"Nov 2","value":[66],"hasData":[true],"formattedValue":["66"]},{"time":"1604361600","formattedTime":"Nov 3, 2020","formattedAxisTime":"Nov 3","value":[100],"hasData":[true],"formattedValue":["100"]},{"time":"1604448000","formattedTime":"Nov 4, 2020","formattedAxisTime":"Nov 4","value":[48],"hasData":[true],"formattedValue":["48"]},{"time":"1604534400","formattedTime":"Nov 5, 2020","formattedAxisTime":"Nov 5","value":[33],"hasData":[true],"formattedValue":["33"]},{"time":"1604620800","formattedTime":"Nov 6, 2020","formattedAxisTime":"Nov 6","value":[87],"hasData":[true],"formattedValue":["87"]},{"time":"1604707200","formattedTime":"Nov 7, 2020","formattedAxisTime":"Nov 7","value":[41],"hasData":[true],"formattedValue":["41"]}],"averages":[]}}

HEROKU SERVER RESPONSE:

{"default":{"timelineData":[{"time":"1604188800","formattedTime":"Nov 1, 2020","formattedAxisTime":"Nov 1","value":[0],"hasData":[false],"formattedValue":["0"]},{"time":"1604275200","formattedTime":"Nov 2, 2020","formattedAxisTime":"Nov 2","value":[25],"hasData":[true],"formattedValue":["25"]},{"time":"1604361600","formattedTime":"Nov 3, 2020","formattedAxisTime":"Nov 3","value":[100],"hasData":[true],"formattedValue":["100"]},{"time":"1604448000","formattedTime":"Nov 4, 2020","formattedAxisTime":"Nov 4","value":[24],"hasData":[true],"formattedValue":["24"]},{"time":"1604534400","formattedTime":"Nov 5, 2020","formattedAxisTime":"Nov 5","value":[25],"hasData":[true],"formattedValue":["25"]},{"time":"1604620800","formattedTime":"Nov 6, 2020","formattedAxisTime":"Nov 6","value":[52],"hasData":[true],"formattedValue":["52"]},{"time":"1604707200","formattedTime":"Nov 7, 2020","formattedAxisTime":"Nov 7","value":[0],"hasData":[false],"formattedValue":["0"]}],"averages":[]}}
nametviner commented 3 years ago

I'm having the same issue. Were you able to find a way around it?

przemoo83 commented 3 years ago

No. I think that's not this APIs fault but it is just the way Google Trends works. Maybe different regions are served by different data centers? Or that's just a little Google's trick to discourage you from using their data like this? :P I think no one knows the answer