Tested failures · pytrends 4.9.2 · urllib3 2.8.0

Keyword research API errors: 429, a retries TypeError, and the five-term ceiling

If a keyword research script returns 429 Too Many Requests on the second term but the first one worked, the problem is request frequency inside one session — not your proxy, and not your API key. On pytrends 4.9.2 with urllib3 2.8.0, the usual advice to "add retries" makes things worse: TrendReq(retries=2) raises a TypeError before any request is sent. The combination that actually worked was no retries argument, a 30-second cool-off, and a fresh default TrendReq with a custom user-agent passed through requests_args.

All three failures below were reproduced on one Windows machine. The tracebacks are the real ones, not examples.

A rising search-interest trend line with a magnifying glass, illustrating keyword research measurement
Illustration: measuring search interest over time.

Error 1: the second term in a session returns 429

The setup was ordinary: one Python process, one TrendReq, United States, a 12-month window, two terms fired back to back with no delay. The first call completed. The second did not.

REQ 01 'keyword trends' -> OK rows=53 (0.98s)
REQ 02 'google trends'  -> EXC TooManyRequestsError:
    The request failed: Google returned a response with code 429

The traceback ends at pytrends.exceptions.TooManyRequestsError.from_response(response), raised from request.py line 159 in _get_data. The useful detail is the position: it is always the second request in the process that fails. That points at frequency within the session, not at a block on the machine. After a cool-off, the same query returned all 53 weeks.

What not to conclude: that the whole cloud account is tagged. Proxies were tried elsewhere with no change. Check which call number breaks before you rewrite your network setup.

Error 2: adding retries breaks the constructor

The standard fix for a 429 is to retry. On this version pair, that fix fails at construction time:

TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist'

The cause is version drift. pytrends 4.9.2 still passes method_whitelist into urllib3's Retry, and urllib3 2.8.0 removed that keyword. The exception happens before any network call, so no amount of waiting helps.

The natural workaround — build your own requests.Session with a modern Retry(allowed_methods=...) adapter and hand it in — fails too:

TypeError: TrendReq.__init__() got an unexpected keyword argument 'requests_session'

The installed constructor is (hl, tz, geo, timeout, proxies, retries, backoff_factor, requests_args). There is no requests_session parameter. Two separate dead ends, one version mismatch.

Error 3: more than five terms fails outright

One request accepts five comparison terms. Seven terms in the same request fail. There is no error-recovery path for this one, because it is a hard ceiling on the comparison feature.

The way around it is to stop asking for every term at once. Compare each pair, count how often each term takes the 100 slot, pick the most frequent winner as the anchor, then run the remaining terms in batches of five that always include that anchor. Line the batches up on the shared anchor. You get a defensible comparison of seven or more terms without ever exceeding the limit.

The configuration that worked

  1. No retries argument at all.
  2. Wait 30 seconds after a 429 before the next request.
  3. Construct a fresh default TrendReq.
  4. Pass a custom user-agent through requests_args instead of a session object.
# after a 30s cool-off
pt = TrendReq(hl='en-US', tz=360,
              requests_args={'headers': {'User-Agent': '...'}})
pt.build_payload(['keyword trends'], cat=0,
                 timeframe='today 12-m', geo='US', gprop='')
df = pt.interest_over_time()   # 53 rows, range 2025-11-23 -> 2026-11-22

That returned the complete weekly series with no error. The environment was Python 3.13.14, pytrends 4.9.2, requests 2.34.2, pandas 3.1.1, Windows 11.

What this means for keyword research workflow

These are not edge cases you can ignore in a real workflow. Keyword research is rarely one term; it is a shortlist checked in sequence. If your script dies on term two, you either get no data or you get data you do not trust. The practical rule is to treat the data source as rate-limited and version-sensitive: record the library versions, space the calls, and verify the returned row count before you build anything on top of it.

For the underlying index itself — what the 0–100 reading means and how to convert it into a share of the peak week — see the main explainer. It uses the same 53-week series described here, with the raw table available to download.