SerpApi Python Library & Package
Links
AI / Agents
Developers
Community
Full license MIT
Meta
Requires: Python >=3.6
Provides-Extra: color, test, docs
Integrate search data into your AI workflow, RAG or fine-tuning pipeline, Python application, or data product using the official wrapper for SerpApi.
SerpApi supports Google, Google Maps, Google Shopping, Bing, DuckDuckGo, Baidu, Yandex, Yahoo, eBay, YouTube, App Stores, Walmart, Home Depot, Naver, and many more engines.
Query a wide range of data at scale, including web search results, local business listings, shopping results, flight schedules, stock market data, job listings, trends, news headlines, AI Overview results, and video search results.
Install
pip install serpapiuv add serpapiPython 3.6 or newer is required by the package.
First Request
Sign up at SerpApi, copy your API key from the dashboard, and set it in your shell:
export SERPAPI_KEY="secret_api_key"$env:SERPAPI_KEY = "secret_api_key"import os
import serpapi
client = serpapi.Client(api_key=os.environ["SERPAPI_KEY"])
results = client.search(
engine="google",
q="coffee",
location="Austin, Texas",
hl="en",
gl="us",
)
print(results["organic_results"][0]["link"])The results variable contains a SerpResults object. It behaves like a standard dictionary and adds convenience helpers for response conversion, pagination, and fetching search archives.
Request parameters map directly to the SerpApi HTTP API. For the full engine list and engine-specific parameters, use the SerpApi API documentation. Use the SerpApi Playground to build and test a request before moving it into Python.
Documentation Map
Choose the path that matches what you are building. Start with setup and a first request, then move into client behavior, request parameters, pagination, error handling, or engine-specific examples.
- New integrations: read Getting Started, then Client Usage.
- Existing
google-search-resultsusers: follow the Migration Guide. - Engine setup: use Parameters and Engines with the SerpApi Playground.
- Production workflows: review pagination, timeouts and errors, request options, account/location helpers, async search archive, JSON Restrictor, and zero trace controls.
- Examples: browse focused recipes grouped by search engines, AI answers, local/maps, shopping, travel, finance, trends, jobs, events, media, apps, and research.