{"id":3505,"library":"google-search-results","title":"Google Search Results (SerpApi)","description":"The `google-search-results` Python package (version 2.4.2) is a client library designed to scrape and parse localized search results from various engines like Google, Bing, Baidu, Yahoo, Yandex, eBay, and more, by utilizing the SerpApi.com service. While functional, it is now considered a 'legacy' SerpApi module, with the actively maintained and recommended client being the `serpapi` package. Its last update was March 2023.","status":"maintenance","version":"2.4.2","language":"en","source_language":"en","source_url":"https://github.com/serpapi/google-search-results-python","tags":["serpapi","google search","scraping","api","search engine results","web scraping"],"install":[{"cmd":"pip install google-search-results","lang":"bash","label":"Install `google-search-results` (legacy)"}],"dependencies":[],"imports":[{"note":"The `google-search-results` package exposes its main class under the `serpapi` namespace, not its own package name, which can be confusing given there is a separate, recommended `serpapi` library.","wrong":"from google_search_results import GoogleSearch","symbol":"GoogleSearch","correct":"from serpapi import GoogleSearch"}],"quickstart":{"code":"import os\nfrom serpapi import GoogleSearch\n\n# Ensure your SerpApi key is set as an environment variable, e.g., SERPAPI_API_KEY\napi_key = os.environ.get('SERPAPI_API_KEY', '')\n\nif not api_key:\n    print(\"Error: SERPAPI_API_KEY environment variable not set.\")\nelse:\n    params = {\n        \"q\": \"coffee\",\n        \"location\": \"Austin, Texas\",\n        \"hl\": \"en\",\n        \"gl\": \"us\",\n        \"api_key\": api_key\n    }\n\n    try:\n        search = GoogleSearch(params)\n        results = search.get_dict()\n\n        if 'organic_results' in results:\n            for result in results['organic_results']:\n                print(f\"Title: {result.get('title')}\\nLink: {result.get('link')}\\n\")\n        else:\n            print(\"No organic results found.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to perform a basic Google search using the `google-search-results` library, fetching results for 'coffee' in Austin, Texas. It retrieves the SerpApi key from an environment variable for security and best practice."},"warnings":[{"fix":"Migrate to the `serpapi` package. Replace `from serpapi import GoogleSearch` with `import serpapi` and use `client = serpapi.Client(api_key=os.getenv('SERPAPI_API_KEY'))` then `client.search({'q': 'query'})`.","message":"The `google-search-results` package is considered a legacy wrapper for SerpApi. The official and actively maintained Python client is now the `serpapi` package (pip install serpapi), which offers more features and better support.","severity":"breaking","affected_versions":"<=2.4.2"},{"fix":"Be mindful of the import path. For `google-search-results`, always use `from serpapi import GoogleSearch`. For the newer, recommended client, install `serpapi` and use `import serpapi`.","message":"Despite being installed as `google-search-results`, the primary class is imported from the `serpapi` namespace (`from serpapi import GoogleSearch`). This can cause confusion with the newer, separate `serpapi` package.","severity":"gotcha","affected_versions":"All versions of `google-search-results`"},{"fix":"Set your API key as an environment variable: `export SERPAPI_API_KEY='YOUR_API_KEY'`. Access it in Python using `os.environ.get('SERPAPI_API_KEY')`.","message":"Always manage your SerpApi key securely using environment variables (e.g., `SERPAPI_API_KEY`) instead of hardcoding it in your scripts.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Implement robust try-except blocks to catch `serpapi.HTTPError` and `serpapi.TimeoutError`. Check error messages and HTTP status codes for detailed diagnostics.","message":"SerpApi uses standard HTTP response codes. Unsuccessful requests will raise `serpapi.HTTPError` or `serpapi.TimeoutError` exceptions (from the underlying `serpapi` library components or the new `serpapi` client). Common errors include 401 (Unauthorized - invalid API key), 429 (Too Many Requests - rate limit or out of searches).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review your API parameters. If you were using the deprecated Google Product API, switch to using the Google Immersive Product API or its equivalent within SerpApi's offerings.","message":"As of September 2025, SerpApi discontinued support for the Google Product API endpoint. Users scraping product page views should migrate to the Google Immersive Product API.","severity":"deprecated","affected_versions":"All versions of `google-search-results` when querying deprecated endpoints."},{"fix":"Monitor your SerpApi usage on your dashboard. Implement exponential backoff or rate-limiting in your application to stay within API limits. Upgrade your SerpApi plan if higher throughput is consistently needed.","message":"SerpApi accounts have daily usage limits. Exceeding these limits can result in `429 Too Many Requests` errors or your account running out of searches.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}