Throwing error on `serpapi.search`

Open
#17 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
api, backend

Research direction

Start by locating the Python implementation of serpapi.search and determine how HTTP errors, especially 429 responses, are currently handled. Use the reported try-catch example as the expected usage pattern, then update the README with error-handling guidance; done means search failures raise a proper error and the documented example explains rate limiting.

Written by the indexing model from the issue text.

Description

improvement

The developer team from a high-volume customer reached out that we should throw a proper error on the serpapi.search.

I've suggested using a try-catch exception to handle errors. For example:

try:
    search = serpapi.search(q="CoffeeMilk", api_key="", engine="google", location="Austin, Texas", hl="en", gl="us")
    print(search)
    print("----------------")
except Exception as e:
    if "429" in str(e):
        print("You are being rate limited")
        print(e)
    else:
        print("An error occurred")

Intercom

sidenote: we should probably update our readme to show how to handle errors.

Dominant language
Python
Stars
173
Forks
24
Avg merge
1d 17h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from serpapi/serpapi-python

All issues in serpapi/serpapi-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.