SerpApi Python Library & Package

Official Python client for SerpApi search data in applications, AI workflows, RAG, and data pipelines.

AI / Agents

llms.txt
llms-full.txt

Developers

SerpApi

Author

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 serpapi
uv add serpapi

Python 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.