serpapi


Nameserpapi JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/serpapi/serpapi-python
SummaryThe official Python client for SerpApi.com.
upload_time2023-11-01 14:00:43
maintainer
docs_urlNone
authorSerpApi.com
requires_python>=3.6.0
licenseMIT
keywords scrape serp api serpapi scraping json search localized rank google bing baidu yandex yahoo ebay scale datamining training machine ml youtube naver walmart apple store app serpapi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

<div align="center">
<h1 align="center">SerpApi Python Library & Package</h1>
  <img src="https://user-images.githubusercontent.com/78694043/233921372-bb57c347-9005-4b59-8f09-993698a87eb6.svg" width="600" alt="serpapi python library logo">

  <a href="https://badge.fury.io/py/serpapi-python">![Package](https://badge.fury.io/py/serpapi.svg)</a>
  
  [![serpapi-python](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml/badge.svg)](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml)
</div>

This repository is the home of the *soon–to–be* official Python API wrapper for [SerpApi](https://serpapi.com). This `serpapi` module allows you to access search data in your Python application.

[SerpApi](https://serpapi.com) supports Google, Google Maps, Google Shopping, Bing, Baidu, Yandex, Yahoo, eBay, App Stores, and more. Check out the [documentation](https://serpapi.com/search-api) for a full list.


## Installation

To install the `serpapi` package, simply run the following command:

```bash
$ pip install serpapi
```

Please note that this package is separate from the legacy `serpapi` module, which is available on PyPi as `google-search-results`. This package is maintained by SerpApi, and is the recommended way to access the SerpApi service from Python.

## Usage

Let's start by searching for Coffee on Google:

```pycon
>>> import serpapi
>>> s = serpapi.search(q="Coffee", engine="google", location="Austin, Texas", hl="en", gl="us")
```

The `s` variable now contains a `SerpResults` object, which acts just like a standard dictionary, with some convenient functions added on top.

Let's print the first result:

```pycon
>>> 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:

```pycon
>>> s["organic_results"][0].get("title")
'Coffee - Wikipedia'
```

The [SerpApi.com API Documentation](https://serpapi.com/search-api) contains a list of all the possible parameters that can be passed to the API.

## Documentation

Documentation is [available on Read the Docs](https://serpapi-python.readthedocs.io/en/latest/).

## Basic Examples in Python

### Search Bing
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'bing',
    'q': 'coffee',
})
```
- API Documentation: [serpapi.com/bing-search-api](https://serpapi.com/bing-search-api)

### Search Baidu
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'baidu',
    'q': 'coffee',
})
```
- API Documentation: [serpapi.com/baidu-search-api](https://serpapi.com/baidu-search-api)

### Search Yahoo
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'yahoo',
    'p': 'coffee',
})
```
- API Documentation: [serpapi.com/yahoo-search-api](https://serpapi.com/yahoo-search-api)

### Search YouTube
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'youtube',
    'search_query': 'coffee',
})
```
- API Documentation: [serpapi.com/youtube-search-api](https://serpapi.com/youtube-search-api)

### Search Walmart
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'walmart',
    'query': 'coffee',
})
```
- API Documentation: [serpapi.com/walmart-search-api](https://serpapi.com/walmart-search-api)

### Search eBay
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'ebay',
    '_nkw': 'coffee',
})
```
- API Documentation: [serpapi.com/ebay-search-api](https://serpapi.com/ebay-search-api)

### Search Naver
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'naver',
    'query': 'coffee',
})
```
- API Documentation: [serpapi.com/naver-search-api](https://serpapi.com/naver-search-api)

### Search Home Depot
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'home_depot',
    'q': 'table',
})
```
- API Documentation: [serpapi.com/home-depot-search-api](https://serpapi.com/home-depot-search-api)

### Search Apple App Store
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'apple_app_store',
    'term': 'coffee',
})
```
- API Documentation: [serpapi.com/apple-app-store](https://serpapi.com/apple-app-store)

### Search DuckDuckGo
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'duckduckgo',
    'q': 'coffee',
})
```
- API Documentation: [serpapi.com/duckduckgo-search-api](https://serpapi.com/duckduckgo-search-api)

### Search Google
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'google',
    'q': 'coffee',
    'engine': 'google',
})
```
- API Documentation: [serpapi.com/search-api](https://serpapi.com/search-api)

### Search Google Scholar
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'google_scholar',
    'q': 'coffee',
})
```
- API Documentation: [serpapi.com/google-scholar-api](https://serpapi.com/google-scholar-api)

### Search Google Autocomplete
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'google_autocomplete',
    'q': 'coffee',
})
```
- API Documentation: [serpapi.com/google-autocomplete-api](https://serpapi.com/google-autocomplete-api)

### Search Google Product
```python
import os
import serpapi

client = 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-api](https://serpapi.com/google-product-api)

### Search Google Reverse Image
```python
import os
import serpapi

client = 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-image](https://serpapi.com/google-reverse-image)

### Search Google Events
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'google_events',
    'q': 'coffee',
})
```
- API Documentation: [serpapi.com/google-events-api](https://serpapi.com/google-events-api)

### Search Google Local Services
```python
import os
import serpapi

client = 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-api](https://serpapi.com/google-local-services-api)

### Search Google Maps
```python
import os
import serpapi


client = 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-api](https://serpapi.com/google-maps-api)

### Search Google Jobs
```python
import os
import serpapi


client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'google_jobs',
    'q': 'coffee',
})
```
- API Documentation: [serpapi.com/google-jobs-api](https://serpapi.com/google-jobs-api)

### Search Google Play
```python
import os
import serpapi

client = 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-api](https://serpapi.com/google-play-api)

### Search Google Images
```python
import os
import serpapi

client = serpapi.Client(api_key=os.getenv("API_KEY"))
results = client.search({
    'engine': 'google_images',
    'tbm': 'isch',
    'q': 'coffee',
})
```
- API Documentation: [serpapi.com/images-results](https://serpapi.com/images-results)


## License

MIT License.

## Contributing

Bug reports and pull requests are welcome on GitHub. Once dependencies are installed, you can run the tests with `pytest`.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/serpapi/serpapi-python",
    "name": "serpapi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6.0",
    "maintainer_email": "",
    "keywords": "scrape,serp,api,serpapi,scraping,json,search,localized,rank,google,bing,baidu,yandex,yahoo,ebay,scale,datamining,training,machine,ml,youtube,naver,walmart,apple,store,app,serpapi",
    "author": "SerpApi.com",
    "author_email": "kenneth@serpapi.com",
    "download_url": "https://files.pythonhosted.org/packages/f0/fa/3fd8809287f3977a3e752bb88610e918d49cb1038b14f4bc51e13e594197/serpapi-0.1.5.tar.gz",
    "platform": null,
    "description": "\n\n<div align=\"center\">\n<h1 align=\"center\">SerpApi Python Library & Package</h1>\n  <img src=\"https://user-images.githubusercontent.com/78694043/233921372-bb57c347-9005-4b59-8f09-993698a87eb6.svg\" width=\"600\" alt=\"serpapi python library logo\">\n\n  <a href=\"https://badge.fury.io/py/serpapi-python\">![Package](https://badge.fury.io/py/serpapi.svg)</a>\n  \n  [![serpapi-python](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml/badge.svg)](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml)\n</div>\n\nThis repository is the home of the *soon\u2013to\u2013be* official Python API wrapper for [SerpApi](https://serpapi.com). This `serpapi` module allows you to access search data in your Python application.\n\n[SerpApi](https://serpapi.com) supports Google, Google Maps, Google Shopping, Bing, Baidu, Yandex, Yahoo, eBay, App Stores, and more. Check out the [documentation](https://serpapi.com/search-api) for a full list.\n\n\n## Installation\n\nTo install the `serpapi` package, simply run the following command:\n\n```bash\n$ pip install serpapi\n```\n\nPlease note that this package is separate from the legacy `serpapi` module, which is available on PyPi as `google-search-results`. This package is maintained by SerpApi, and is the recommended way to access the SerpApi service from Python.\n\n## Usage\n\nLet's start by searching for Coffee on Google:\n\n```pycon\n>>> import serpapi\n>>> s = serpapi.search(q=\"Coffee\", engine=\"google\", location=\"Austin, Texas\", hl=\"en\", gl=\"us\")\n```\n\nThe `s` variable now contains a `SerpResults` object, which acts just like a standard dictionary, with some convenient functions added on top.\n\nLet's print the first result:\n\n```pycon\n>>> s[\"organic_results\"][0][\"link\"]\n'https://en.wikipedia.org/wiki/Coffee'\n```\n\nLet's print the title of the first result, but in a more Pythonic way:\n\n```pycon\n>>> s[\"organic_results\"][0].get(\"title\")\n'Coffee - Wikipedia'\n```\n\nThe [SerpApi.com API Documentation](https://serpapi.com/search-api) contains a list of all the possible parameters that can be passed to the API.\n\n## Documentation\n\nDocumentation is [available on Read the Docs](https://serpapi-python.readthedocs.io/en/latest/).\n\n## Basic Examples in Python\n\n### Search Bing\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'bing',\n    'q': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/bing-search-api](https://serpapi.com/bing-search-api)\n\n### Search Baidu\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'baidu',\n    'q': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/baidu-search-api](https://serpapi.com/baidu-search-api)\n\n### Search Yahoo\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'yahoo',\n    'p': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/yahoo-search-api](https://serpapi.com/yahoo-search-api)\n\n### Search YouTube\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'youtube',\n    'search_query': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/youtube-search-api](https://serpapi.com/youtube-search-api)\n\n### Search Walmart\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'walmart',\n    'query': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/walmart-search-api](https://serpapi.com/walmart-search-api)\n\n### Search eBay\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'ebay',\n    '_nkw': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/ebay-search-api](https://serpapi.com/ebay-search-api)\n\n### Search Naver\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'naver',\n    'query': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/naver-search-api](https://serpapi.com/naver-search-api)\n\n### Search Home Depot\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'home_depot',\n    'q': 'table',\n})\n```\n- API Documentation: [serpapi.com/home-depot-search-api](https://serpapi.com/home-depot-search-api)\n\n### Search Apple App Store\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'apple_app_store',\n    'term': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/apple-app-store](https://serpapi.com/apple-app-store)\n\n### Search DuckDuckGo\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'duckduckgo',\n    'q': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/duckduckgo-search-api](https://serpapi.com/duckduckgo-search-api)\n\n### Search Google\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google',\n    'q': 'coffee',\n    'engine': 'google',\n})\n```\n- API Documentation: [serpapi.com/search-api](https://serpapi.com/search-api)\n\n### Search Google Scholar\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_scholar',\n    'q': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/google-scholar-api](https://serpapi.com/google-scholar-api)\n\n### Search Google Autocomplete\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_autocomplete',\n    'q': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/google-autocomplete-api](https://serpapi.com/google-autocomplete-api)\n\n### Search Google Product\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_product',\n    'q': 'coffee',\n    'product_id': '4887235756540435899',\n})\n```\n- API Documentation: [serpapi.com/google-product-api](https://serpapi.com/google-product-api)\n\n### Search Google Reverse Image\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_reverse_image',\n    'image_url': 'https://i.imgur.com/5bGzZi7.jpg',\n    'max_results': '1',\n})\n```\n- API Documentation: [serpapi.com/google-reverse-image](https://serpapi.com/google-reverse-image)\n\n### Search Google Events\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_events',\n    'q': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/google-events-api](https://serpapi.com/google-events-api)\n\n### Search Google Local Services\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_local_services',\n    'q': 'electrician',\n    'data_cid': '6745062158417646970',\n})\n```\n- API Documentation: [serpapi.com/google-local-services-api](https://serpapi.com/google-local-services-api)\n\n### Search Google Maps\n```python\nimport os\nimport serpapi\n\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_maps',\n    'q': 'pizza',\n    'll': '@40.7455096,-74.0083012,15.1z',\n    'type': 'search',\n})\n```\n- API Documentation: [serpapi.com/google-maps-api](https://serpapi.com/google-maps-api)\n\n### Search Google Jobs\n```python\nimport os\nimport serpapi\n\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_jobs',\n    'q': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/google-jobs-api](https://serpapi.com/google-jobs-api)\n\n### Search Google Play\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_play',\n    'q': 'kite',\n    'store': 'apps',\n    'max_results': '2',\n})\n```\n- API Documentation: [serpapi.com/google-play-api](https://serpapi.com/google-play-api)\n\n### Search Google Images\n```python\nimport os\nimport serpapi\n\nclient = serpapi.Client(api_key=os.getenv(\"API_KEY\"))\nresults = client.search({\n    'engine': 'google_images',\n    'tbm': 'isch',\n    'q': 'coffee',\n})\n```\n- API Documentation: [serpapi.com/images-results](https://serpapi.com/images-results)\n\n\n## License\n\nMIT License.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub. Once dependencies are installed, you can run the tests with `pytest`.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "The official Python client for SerpApi.com.",
    "version": "0.1.5",
    "project_urls": {
        "Documentation": "https://serpapi-python.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/serpapi/serpapi-python"
    },
    "split_keywords": [
        "scrape",
        "serp",
        "api",
        "serpapi",
        "scraping",
        "json",
        "search",
        "localized",
        "rank",
        "google",
        "bing",
        "baidu",
        "yandex",
        "yahoo",
        "ebay",
        "scale",
        "datamining",
        "training",
        "machine",
        "ml",
        "youtube",
        "naver",
        "walmart",
        "apple",
        "store",
        "app",
        "serpapi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df6a21deade04100d64844e494353a5d65e7971fbdfddf78eb1f248423593ad0",
                "md5": "0fcbf9d9163ab52e0e6d98f652752aef",
                "sha256": "6467b6adec1231059f754ccaa952b229efeaa8b9cae6e71f879703ec9e5bb3d1"
            },
            "downloads": -1,
            "filename": "serpapi-0.1.5-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0fcbf9d9163ab52e0e6d98f652752aef",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6.0",
            "size": 10966,
            "upload_time": "2023-11-01T14:00:38",
            "upload_time_iso_8601": "2023-11-01T14:00:38.885718Z",
            "url": "https://files.pythonhosted.org/packages/df/6a/21deade04100d64844e494353a5d65e7971fbdfddf78eb1f248423593ad0/serpapi-0.1.5-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0fa3fd8809287f3977a3e752bb88610e918d49cb1038b14f4bc51e13e594197",
                "md5": "96ed177557ba4c4746ba6524d0ef3f49",
                "sha256": "b9707ed54750fdd2f62dc3a17c6a3fb7fa421dc37902fd65b2263c0ac765a1a5"
            },
            "downloads": -1,
            "filename": "serpapi-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "96ed177557ba4c4746ba6524d0ef3f49",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.0",
            "size": 14191,
            "upload_time": "2023-11-01T14:00:43",
            "upload_time_iso_8601": "2023-11-01T14:00:43.602096Z",
            "url": "https://files.pythonhosted.org/packages/f0/fa/3fd8809287f3977a3e752bb88610e918d49cb1038b14f4bc51e13e594197/serpapi-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-01 14:00:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "serpapi",
    "github_project": "serpapi-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "serpapi"
}
        
Elapsed time: 0.17860s