SerpApi Python Library & Package

serpapi is the official Python client for SerpApi. Use it to search the web and read the results in your Python programs.

SerpApi supports Google, Google Maps, Google Shopping, Bing, DuckDuckGo, Baidu, Yandex, Yahoo, eBay, YouTube, App Stores, Walmart, Home Depot, Naver, and many more engines.

You can retrieve web search results, local business listings, shopping results, flight schedules, stock market data, job listings, trends, news headlines, AI Overview answers, and video search results.

Install

Run one of these commands in your terminal. Use pip to install into your Python environment, or uv add if you manage your project with uv.

pip install serpapi
uv add serpapi

The package requires Python 3.6 or newer.

First Request

Sign up at SerpApi and copy your API key from the dashboard. Replace secret_api_key below with your key, then run the command in your terminal. On Windows, use PowerShell.

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

Run this code in a Python script or interpreter started from the same terminal so it can read SERPAPI_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"])

This prints the link from the first organic result, which is an unpaid search listing. results["organic_results"] is a list, and [0] selects its first item. See Getting Started for setup instructions and an explanation of each parameter.

The results variable contains a SerpResults object. You can read its fields like a Python dictionary, convert it to a plain dictionary, or use its methods to fetch more pages. You can also retrieve saved searches with client.search_archive().

Use the same search parameter names as the SerpApi API documentation. The SerpApi Playground lets you try a search in your browser and copy its parameters into Python.

Documentation Map