Skip to content

Commit a2a89dd

Browse files
committed
usage docs
1 parent 7049ba1 commit a2a89dd

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

docs/source/index.rst

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,25 @@ Please note that Python 3.6+ is required.
3232
Usage
3333
-----
3434

35-
To use this module,
35+
Usage of this module is fairly straight-forward. In general, this module attempts to be as close to the actual API as possible, while still being Pythonic.
3636

37-
TODO write this.
37+
For example, the API endpoint ``https://serpapi.com/search.json`` is represented by the method ``serpapi.search()``.
38+
39+
.. code-block:: python
40+
41+
>>> import serpapi
42+
>>> s = serpapi.search(q="Coffee", engine="google", location="Austin, Texas", hl="en", gl="us")
43+
>>> s["organic_results"][0]["link"]
44+
'https://en.wikipedia.org/wiki/Coffee'
45+
46+
Any parameters that you pass to ``search()`` will be passed to the API. This includes the ``api_key`` parameter, which is required for all requests.
47+
48+
To make this less repetitive, and gain the benefit of connection pooling, let's start using the API Client directly::
49+
50+
>>> client = serpapi.Client(api_key="secret_api_key")
51+
>>> s = client.search(q="Coffee", engine="google", location="Austin, Texas", hl="en", gl="us")
52+
53+
The ``api_key`` parameter is now automatically passed to all requests made by the client.
3854

3955

4056
API Reference

0 commit comments

Comments
 (0)