Google Trends API returns 429 on first request due to missing NID cookie
Developers querying the Google Trends API programmatically encounter an HTTP 429 error on their very first request, even from a clean IP address. The error is not a rate-limit block but occurs because Google Trends requires an NID cookie that is only issued after visiting certain Google pages. A working fix involves making a warm-up GET request to a lightweight endpoint — specifically '/_/TrendsUi/data/batchexecute' — which returns a 405 status but sets the required 106-byte NID cookie at minimal data cost. Once that cookie is included in subsequent API calls, requests to '/trends/api/explore' return the expected 200 response with full data. The widely used 'pytrends' library, archived in April 2025, no longer handles this cookie handshake correctly, which is why many existing scrapers recently broke.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in