Package: serpapi
SerpApi Python Library & PackageThis repository is the home of thesoon–to–beofficial Python API wrapper forSerpApi. Thisserpapimodule allows you to access search data in your Python application.SerpApisupports Google, Google Maps, Google Shopping, Bing, Baidu, Yandex, Yahoo, eBay, App Stores, and more. Check out thedocumentationfor a full list.InstallationTo install theserpapipackage, simply run the following command:$pipinstallserpapiPlease note that this package is separate from the legacyserpapimodule, which is available on PyPi asgoogle-search-results. This package is maintained by SerpApi, and is the recommended way to access the SerpApi service from Python.UsageLet's start by searching for Coffee on Google:>>>importserpapi>>>s=serpapi.search(q="Coffee",engine="google",location="Austin, Texas",hl="en",gl="us")Thesvariable now contains aSerpResultsobject, which acts just like a standard dictionary, with some convenient functions added on top.Let's print the first result:>>>s["organic_results"][0]["link"]'https://en.wikipedia.org/wiki/Coffee'Let's print the title of the first result, but in a more Pythonic way:>>>s["organic_results"][0].get("title")'Coffee - Wikipedia'TheSerpApi.com API Documentationcontains a list of all the possible parameters that can be passed to the API.DocumentationDocumentation isavailable on Read the Docs.Basic Examples in PythonSearch Bingimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'bing','q':'coffee',})API Documentation:serpapi.com/bing-search-apiSearch Baiduimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'baidu','q':'coffee',})API Documentation:serpapi.com/baidu-search-apiSearch Yahooimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'yahoo','p':'coffee',})API Documentation:serpapi.com/yahoo-search-apiSearch YouTubeimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'youtube','search_query':'coffee',})API Documentation:serpapi.com/youtube-search-apiSearch Walmartimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'walmart','query':'coffee',})API Documentation:serpapi.com/walmart-search-apiSearch eBayimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'ebay','_nkw':'coffee',})API Documentation:serpapi.com/ebay-search-apiSearch Naverimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'naver','query':'coffee',})API Documentation:serpapi.com/naver-search-apiSearch Home Depotimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'home_depot','q':'table',})API Documentation:serpapi.com/home-depot-search-apiSearch Apple App Storeimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'apple_app_store','term':'coffee',})API Documentation:serpapi.com/apple-app-storeSearch DuckDuckGoimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'duckduckgo','q':'coffee',})API Documentation:serpapi.com/duckduckgo-search-apiSearch Googleimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google','q':'coffee','engine':'google',})API Documentation:serpapi.com/search-apiSearch Google Scholarimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_scholar','q':'coffee',})API Documentation:serpapi.com/google-scholar-apiSearch Google Autocompleteimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_autocomplete','q':'coffee',})API Documentation:serpapi.com/google-autocomplete-apiSearch Google Productimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_product','q':'coffee','product_id':'4887235756540435899',})API Documentation:serpapi.com/google-product-apiSearch Google Reverse Imageimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_reverse_image','image_url':'https://i.imgur.com/5bGzZi7.jpg','max_results':'1',})API Documentation:serpapi.com/google-reverse-imageSearch Google Eventsimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_events','q':'coffee',})API Documentation:serpapi.com/google-events-apiSearch Google Local Servicesimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_local_services','q':'electrician','data_cid':'6745062158417646970',})API Documentation:serpapi.com/google-local-services-apiSearch Google Mapsimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_maps','q':'pizza','ll':'@40.7455096,-74.0083012,15.1z','type':'search',})API Documentation:serpapi.com/google-maps-apiSearch Google Jobsimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_jobs','q':'coffee',})API Documentation:serpapi.com/google-jobs-apiSearch Google Playimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_play','q':'kite','store':'apps','max_results':'2',})API Documentation:serpapi.com/google-play-apiSearch Google Imagesimportosimportserpapiclient=serpapi.Client(api_key=os.getenv("API_KEY"))results=client.search({'engine':'google_images','tbm':'isch','q':'coffee',})API Documentation:serpapi.com/images-resultsLicenseMIT License.ContributingBug reports and pull requests are welcome on GitHub. Once dependencies are installed, you can run the tests withpytest.