{"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":"python","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,"search_vec":"'2.4.2':13 '2023':69 'activ':55 'api':74 'baidu':32 'bing':31 'client':16,59 'consid':48 'design':18 'ebay':35 'engin':28,76 'function':44 'googl':1,7,30,71 'google-search-result':6 'last':65 'legaci':50 'librari':17 'like':29 'local':23 'maintain':56 'march':68 'modul':52 'packag':11,63 'pars':22 'python':10 'recommend':58 'result':3,9,25,77 'scrape':20,73,79 'search':2,8,24,72,75 'serpapi':4,51,62,70 'serpapi.com':41 'servic':42 'updat':66 'util':39 'various':27 'version':12 'web':78 'yahoo':33 'yandex':34","created_at":"2026-04-11T17:32:29.267241+00:00","updated_at":"2026-04-16T15:25:46.057645+00:00","problems":[{"fix":"Ensure you have installed the `google-search-results` package (or the recommended `serpapi` package) correctly using `pip install google-search-results` (or `pip install serpapi`). The import statement for `google-search-results` should be `from serpapi import GoogleSearch` or similar, depending on the specific usage, not `from google import search` or `from googlesearch import search` which belong to different, often unmaintained, libraries.","cause":"This error often occurs because developers confuse the `google-search-results` package with other libraries named 'google' or 'googlesearch', or they have not installed the correct package, or installed it in a different environment. The `google-search-results` library is part of the SerpApi ecosystem, and its main class is imported directly, not usually from a top-level 'google' module.","error":"ModuleNotFoundError: No module named 'google'"},{"fix":"Obtain a valid API key from your SerpApi dashboard (serpapi.com/manage-api-key) and pass it to the `GoogleSearch` constructor via the `api_key` parameter in the `params` dictionary, or set it as an environment variable (e.g., `SERPAPI_API_KEY`).\n\nExample:\n```python\nfrom serpapi import GoogleSearch\n\nparams = {\n    \"api_key\": \"YOUR_API_KEY\", # Replace with your actual API key\n    \"engine\": \"google\",\n    \"q\": \"coffee\",\n    \"location\": \"Austin, Texas, United States\",\n}\n\nsearch = GoogleSearch(params)\nresults = search.get_dict()\n```","cause":"This error indicates that the SerpApi client library was initialized or a search was attempted without a valid API key being provided, or the API key provided is incorrect/expired. SerpApi requires an API key for authentication to process search requests.","error":"SerpApiError: You didn't supply an API Key."},{"fix":"Check your SerpApi account dashboard for your current search usage and rate limits. If you've run out of searches, you may need to upgrade your plan or wait for your quota to reset. If performing many requests, introduce delays between calls or consider using SerpApi's asynchronous or batch features if available in the `serpapi` library (the recommended successor).","cause":"This error occurs when your SerpApi account has exceeded its allocated search quota or rate limit within a given timeframe. Google may also block requests if it detects automated scraping.","error":"HTTP 429: Too Many Requests"},{"fix":"Verify that the API key you are using is copied exactly from your SerpApi dashboard (https://serpapi.com/manage-api-key) and that it is active. Ensure there are no leading or trailing spaces or other hidden characters. Pass the correct key in your code.","cause":"This is a specific error message returned directly from the SerpApi service, indicating that the provided API key is either missing, malformed, or not recognized as valid by SerpApi's servers. This is often due to typos or using an expired/incorrect key.","error":"{'error': 'Invalid API key. Your API key should be here: https://serpapi.com/manage-api-key'}"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.4.2","cli_name":"","cli_version":null,"type":"library","homepage":"https://serpapi.com","github":"https://github.com/serpapi/google-search-results-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/google-search-results/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}