pat310 / google-trends-api

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

Error 400 #104

Open cjm771 opened 6 years ago

cjm771 commented 6 years ago

Is this still working? I recieved an Error 400 when querying the api! JW thanks!

pat310 commented 6 years ago

@cjm771 are you still having trouble? I'm getting results back when testing.

Did you make a lot requests in a short time frame or was it just once? Also, can you share the query (which api method) you are trying?

cjm771 commented 6 years ago

Sure! I am trying just once. Looks like the end point is: https://trends.google.com/trends/fetchComponent?q=Seahawks&cid=TIMESERIES_GRAPH_0&export=3

Code Below

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

//interest by region
googleTrends.trendData("Seahawks").then( (res) => console.log("interest By region",res))
    .catch( (err) => console.log("an error occurred",err));

Results in

 <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><title>Resource unavilable</title></head><body>This resource is no longer available.<br>If you require support please email trends-data-request@google.com <br>Please include details about how you are using the Trends data.</body></html>
pat310 commented 6 years ago

@cjm771 what version of are you using? trendData isn't a method anymore, can you try upgrading to 4.6.2?

Hannah-Jiang commented 6 years ago

I also have 400 error with googleTrends.interestOverTime API. I used to have 429 error, this error is resolved after update to v4.2.6, now I have 400 error.

cjm771 commented 6 years ago

@pat310 I was using v3.0.2, in an effort to resolve similar issues with the latest version at that time. Running latest v4.6.2, Everything looks to be working using following code :) Man I wish the api gave daily resolution for some of the endpoint, rather than monthly am I right? heh.

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

//interest by region
googleTrends.interestOverTime({keyword: 'Seahawks'}, function(err, results){
  if(err) console.error('there was an error!', err);
  else console.log('my sweet sweet results', results);
})