serpapi
The official Python client for SerpApi, returning structured search results from Google, Bing, and more.
Repository Health
Technical Analysis
serpapi is the official, modern Python wrapper for SerpApi — a hosted service that runs search-engine queries and returns clean, structured JSON. It supersedes the legacy google-search-results package with a cleaner client design centered on a single Client.search() method and a SerpResults object.
SerpApi covers Google (including Maps, Shopping, Images, Scholar, Jobs, and more), Bing, Baidu, Yandex, Yahoo, eBay, app stores, and other engines, exposing web results, flight schedules, stock data, news, and more. The library is designed to feed search data into AI workflows, RAG and fine-tuning pipelines, and general Python applications.
What You Get
- A unified
Client.search()method that works across all supported engines via anengineparameter - A dict-like
SerpResultsmodel with pagination helpers - Environment-variable-based API key configuration
- Typed exceptions for API and request errors
Common Use Cases
- Feeding live search results into RAG and LLM-agent pipelines
- Collecting SERP data for rank tracking, SEO, and market research
- Querying Google Maps, Shopping, Scholar, and other verticals programmatically
Under The Hood
Architecture - The serpapi/ package is cleanly layered: core.py defines a Client that subclasses HTTPClient (http.py) and exposes search(), returning a SerpResults model (models.py) that wraps the JSON response and adds pagination. exceptions.py defines typed errors, utils.py holds helpers, and textui.py provides light terminal output.
Tech Stack - Pure Python packaged with a modern pyproject.toml, built on requests for HTTP. The repo ships Sphinx docs under docs/, a pylint.rc, and CI workflows.
Code Quality - Testing is extensive: tests/ contains per-engine example tests (Google, Maps, Images, Scholar, Jobs, Bing, Baidu, eBay, and more) plus test_exceptions.py, test_integration.py, and test_timeout.py with a conftest.py. The module boundaries and docstrings are well maintained by the SerpApi team.
API Design - The public API is minimal and pythonic — instantiate serpapi.Client(api_key=...) and call search(q=..., engine=...), or use the module-level serpapi.search() shortcut. Results behave like dicts, keyword and dict params are interchangeable, and the API key is read from an environment variable, making onboarding quick.