You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
next_page() / yield_pages() send the client's API key instead of the one passed to search() #57
When the key is passed per call, page 1 uses it but every later page uses the client's own key. With a keyless client, page 2 has no key and fails with a 401.
Same with serpapi.search(api_key=...): page 2 goes out without a key.
As the comment in next_page() says, the next-page URL doesn't include the key, so it adds self.client.api_key. That key isn't always the one the search used. The async next_page() has the same problem.
Related to #46: the review there flags next_page() dropping the session key on a keyless client. This is a different case in the same spot: a key passed per call to search() isn't reused for later pages, even on master. Since #46 touches next_page(), it may be easiest to cover both there. Otherwise I can open a separate PR once #46 lands.
I have a fix with offline tests for both clients (results remember the key sent with their request, and fall back to the client key otherwise), happy to share it either way.
Activity
hilmanski commentedon Dec 1, 2026
Thanks for opening an issue. We'll investigate this.