Migrating from google-search-results

Move from the deprecated google-search-results SDK to the recommended serpapi package.

SerpApi has two Python libraries that use similar import names. For new projects and active integrations, use the recommended serpapi package.

Deprecated Package

The old Python SDK is google-search-results on PyPI. It is deprecated for new integrations.

It was installed with:

pip install google-search-results

Older code often looks like this:

from serpapi import GoogleSearch

search = GoogleSearch({
    "q": "coffee",
    "location": "Austin,Texas",
    "api_key": "<your secret api key>",
})
result = search.get_dict()

Do not add this package to new projects.

Update Your Dependencies

Remove google-search-results from your dependency files, such as requirements.txt, pyproject.toml, setup.py, Pipfile, or Poetry dependency configuration.

Then add serpapi instead:

pip install serpapi

Avoid installing both packages in the same environment. They can share the serpapi import namespace, which makes migration harder to reason about.

Update Your Code

Replace GoogleSearch(...).get_dict() with serpapi.Client(...).search(...).

Old:

from serpapi import GoogleSearch

search = GoogleSearch({
    "q": "coffee",
    "location": "Austin,Texas",
    "api_key": "<your secret api key>",
})
result = search.get_dict()

New:

import os
import serpapi

client = serpapi.Client(api_key=os.environ["SERPAPI_KEY"])
results = client.search(
    engine="google",
    q="coffee",
    location="Austin, Texas",
)

Search parameters use the same SerpApi names, so most request parameter usage can move over directly. Prefer passing them as keyword arguments in new code; dictionaries are still accepted when migration code already has parameters in a mapping.

Migration Checklist

  • Remove google-search-results from requirements and dependency files.
  • Install serpapi with pip install serpapi.
  • Replace from serpapi import GoogleSearch with import serpapi.
  • Replace GoogleSearch(params).get_dict() with serpapi.Client(api_key=...).search(engine=..., q=..., ...).
  • Keep using the SerpApi Playground and the SerpApi API documentation to confirm engine parameters.