Menu

Google Trends API in Python without pytrends 429 errors (and with more than 5 terms on one scale)
📰

Google Trends API in Python without pytrends 429 errors (and with more than 5 terms on one scale)

DEV Community: api·Ocius Data·about 2 hours ago
#EqH4blwz
#devtoapi#devto#dev#terms#google
Reading 0:00
15s threshold

Disclosure: I build and maintain the Apify Actor used in this tutorial ( ocius-data/google-trends-reliable ). The method for comparing more than five terms works with any tool; the code below uses ours.

Google has never shipped a public Google Trends API. Most Python projects use pytrends , an unofficial library that calls the same endpoints as the website. It works well in a notebook and then breaks in production for two reasons:

TooManyRequestsError (HTTP 429). Google rate-limits by IP address. A scheduled job on a cloud server hits the limit after a few requests, and the usual fix ( time.sleep plus retries) makes every run slow and still unreliable.

The five-term limit. Google Trends compares at most five terms per request, and every request is scaled to its own 0-100 range.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.