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

unexpected token c in json at position 0 #115

Open spookyvert opened 5 years ago

spookyvert commented 5 years ago

I tried running it once and it worked! after that i get unexpected token c in json at position 0 everytime

spookyvert commented 5 years ago

hopped on my VPN & it started working

when i disconnect it doesnt?

pat310 commented 5 years ago

@spookyvert Are you still having this issue? What query are you running?

FelisPhasma commented 5 years ago

Hello, I've had that issue and a couple others like it. It seems to be due to encountering the rate limit.

hawknguyen189 commented 5 years ago

I also have the same issue and haven't figured out the solution yet. Any suggestions would be greatly appreciated.

hayksaakian commented 5 years ago

it's a rate limit issue. This library won't really be able to solve it besides communicating the errors more clearly.

pat310 commented 5 years ago

Thanks @hayksaakian. Since these errors happen so frequently it might be good to have a specific case to catch them and report it back to the user. What do you think?

nakasoori commented 5 years ago

Does anyone know any numbers or have an estimate of what the rate limit is or a quota limit?

As far as I can tell, running a request every second used to be the fastest rate to query without running into any throttling. After I receive a ''too many requests" error, the fastest reliable request speed seems to be once per minute.

I was wondering if any one else has played around with the rate limit and any rates they may have observed.

FelisPhasma commented 5 years ago

@nakasoori I could fire off a bunch of requests fairly quickly but eventually I would get rate limited. With about thousands of requests, as I needed to perform, I did 1 request per minute, which experimentally seems to be the rate limit over time. (It also lines up with a suggestion I found elsewhere online)

nakasoori commented 5 years ago

Thanks @FelisPhasma . I noticed that limit too. On the python version of this library, someone tested that there is a rate limit of 1400 requests per every 4 hours and a limit of 1 request per minute once the 4 hour limit is reached.

In my case, ideally I want to run a request every second and so I started working on using rotating proxy servers once a limit is reached. It seems that Google not only limits one's IP address, but limits a range of IP addresses altogether. Currently I am trying to find a way to ensure distinguished enough IP addresses while also optimizing the query speed as best as possible. If anyone has an ideas, I would very much appreciate it!