Skip to content

Commit 6493de6

Browse files
authored
Update README for better clarity and usage examples
1 parent 67c6bcc commit 6493de6

File tree

1 file changed

+23
-28
lines changed

1 file changed

+23
-28
lines changed

README.md

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1+
# SerpApi Python Library & Package
2+
[![Package](https://badge.fury.io/py/serpapi.svg)](https://pypi.org/project/serpapi) [![serpapi-python](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml/badge.svg)](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml)
13

2-
<div align="center">
3-
<h1 align="center">SerpApi Python Library & Package</h1>
4-
<img src="https://user-images.githubusercontent.com/78694043/233921372-bb57c347-9005-4b59-8f09-993698a87eb6.svg" width="600" alt="serpapi python library logo">
4+
Integrate search data into your AI workflow, RAG / fine-tuning, or Python application using this official wrapper for [SerpApi](https://serpapi.com).
55

6-
<a href="https://pypi.org/project/serpapi">![Package](https://badge.fury.io/py/serpapi.svg)</a>
7-
8-
[![serpapi-python](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml/badge.svg)](https://github.com/serpapi/serpapi-python/actions/workflows/ci.yml)
9-
</div>
10-
11-
This repository is the home of the official Python API wrapper for [SerpApi](https://serpapi.com). This `serpapi` module allows you to access search data in your Python application.
12-
13-
[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-engine-apis) for a full list.
6+
SerpApi supports Google, Google Maps, Google Shopping, Baidu, Yandex, Yahoo, eBay, App Stores, and [more](https://serpapi.com).
147

8+
Query a vast range of data at scale, including web search results, flight schedules, stock market data, news headlines, and [more](https://serpapi.com).
159

1610
## Installation
1711

@@ -23,32 +17,33 @@ $ pip install serpapi
2317

2418
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.
2519

26-
## Usage
20+
## Simple Usage
2721

2822
Let's start by searching for Coffee on Google:
2923

30-
```pycon
31-
>>> import serpapi
32-
>>> s = serpapi.search(q="Coffee", engine="google", location="Austin, Texas", hl="en", gl="us")
33-
```
34-
35-
The `s` variable now contains a `SerpResults` object, which acts just like a standard dictionary, with some convenient functions added on top.
24+
```python
25+
import os
26+
import serpapi
3627

37-
Let's print the first result:
28+
client = serpapi.Client(api_key=os.getenv("SERPAPI_KEY"))
29+
results = client.search({
30+
"engine": "google",
31+
"q": "coffee"
32+
})
3833

39-
```pycon
40-
>>> s["organic_results"][0]["link"]
41-
'https://en.wikipedia.org/wiki/Coffee'
34+
print(results)
4235
```
4336

44-
Let's print the title of the first result, but in a more Pythonic way:
37+
The `results` variable now contains a `SerpResults` object, which acts just like a standard dictionary, with some convenient functions added on top.
4538

46-
```pycon
47-
>>> s["organic_results"][0].get("title")
48-
'Coffee - Wikipedia'
49-
```
39+
This example runs a search for "coffee" on Google. It then returns the results as a regular Python Hash.
40+
See the [playground](https://serpapi.com/playground) to generate your own code.
41+
42+
The SerpApi key can be obtained from [serpapi.com/signup](https://serpapi.com/users/sign_up?plan=free).
5043

51-
The [SerpApi.com API Documentation](https://serpapi.com/search-engine-apis) contains a list of all the possible parameters that can be passed to the API.
44+
Environment variables are a secure, safe, and easy way to manage secrets.
45+
Set `export SERPAPI_KEY=<secret_serpapi_key>` in your shell.
46+
Python accesses these variables from `os.environ["SERPAPI_KEY"]`.
5247

5348
### Error handling
5449

0 commit comments

Comments
 (0)