Getting Started

Install serpapi, create a client, and run your first search.

SerpApi Python is the official Python client for SerpApi. It wraps SerpApi HTTP endpoints with a small Python API while keeping request parameters close to the underlying API.

Use this page to install the package, configure your API key, and make a first Google Search request.

Installation

pip install serpapi
uv add serpapi
uv pip install serpapi

Python 3.6 or newer is required by the package.

Create or sign in to your SerpApi account, copy your API key from the dashboard, and set it in the environment:

export SERPAPI_KEY="secret_api_key"
$env:SERPAPI_KEY = "secret_api_key"

What the Parameters Mean

The example above sends a Google Search request:

Parameter Purpose
engine Selects the SerpApi engine. google is Google Search.
q Search query.
location Search location used by SerpApi.
hl Interface language.
gl Country for Google results.

SerpApi supports many engines and engine-specific parameters. The authoritative list lives in the SerpApi API documentation. The SerpApi Playground is the fastest way to build and test a request before moving it into Python.

When to Use the Client

Use serpapi.Client for application code, scripts that make more than one request, pagination, and concurrent workloads. The client stores the API key, timeout, and HTTP session configuration in one place.

The module-level helpers are useful for quick experiments:

import serpapi

results = serpapi.search(
    api_key="secret_api_key",
    engine="google",
    q="coffee",
)

For production code, prefer a client instance:

client = serpapi.Client(api_key="secret_api_key", timeout=20)
results = client.search(engine="google", q="coffee")

Next Steps