Skip to content

Commit 74741b4

Browse files
committed
cleanups to docs
1 parent 0ce1089 commit 74741b4

File tree

3 files changed

+51
-28
lines changed

3 files changed

+51
-28
lines changed

docs/source/index.rst

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ To install ``serpapi-python``, simply use `pip`::
2828

2929
Please note that Python 3.6+ is required.
3030

31+
32+
Usage
33+
-----
34+
35+
To use this module,
36+
37+
TODO write this.
38+
39+
3140
API Reference
3241
=============
3342

@@ -38,18 +47,55 @@ This part of the documentation covers all the interfaces of :class:`serpapi` Pyt
3847
.. module:: serpapi
3948
:platform: Unix, Windows
4049
:synopsis: SerpApi Python Library
50+
:members:
51+
:undoc-members:
4152

42-
Primary interface
43-
-----------------
53+
.. autofunction:: serpapi.search
54+
.. autofunction:: serpapi.search_archive
55+
.. autofunction:: serpapi.locations
56+
.. autofunction:: serpapi.account
57+
58+
API Client
59+
----------
4460

4561
The primary interface to `serpapi-python` is through the :class:`serpapi.Client` class.
62+
The primary benefit of using this class is to benefit from Requests' HTTP Connection Pooling.
63+
This class also alleviates the need to pass an ``api_key``` along with every search made to the platform.
4664

4765
.. autoclass:: serpapi.Client
48-
:members:
4966

50-
.. autoclass:: serpapi.client.SerpResults
51-
:members:
67+
.. automethod:: Client.search
68+
.. automethod:: Client.search_archive
69+
.. automethod:: Client.account
70+
.. automethod:: Client.locations
71+
5272

73+
Results from SerpApi.com
74+
------------------------
75+
76+
When a successful ``serpapi.search`` has been executed, the call returns
77+
an :class:`SerpResults <serpapi.SerpResults>` object, which acts just like a standard dictionary,
78+
with some convenient functions added on top.
79+
80+
81+
.. code-block:: python
82+
83+
>>> s = serpapi.search("Coffee", engine="google", location="Austin, Texas", hl="en", gl="us")
84+
>>> type(s)
85+
<class 'serpapi.models.SerpResults'>
86+
87+
>>> s["organic_results"][0]["link"]
88+
'https://en.wikipedia.org/wiki/Coffee'
89+
90+
>>> s["search_metadata"]
91+
{'id': '64c148d35119a60ab1e00cc9', 'status': 'Success', 'json_endpoint': 'https://serpapi.com/searches/a15e1b92727f292c/64c148d35119a60ab1e00cc9.json', 'created_at': '2023-07-26 16:24:51 UTC', 'processed_at': '2023-07-26 16:24:51 UTC', 'google_url': 'https://www.google.com/search?q=Coffee&oq=Coffee&uule=w+CAIQICIdQXVzdGluLFRYLFRleGFzLFVuaXRlZCBTdGF0ZXM&hl=en&gl=us&sourceid=chrome&ie=UTF-8', 'raw_html_file': 'https://serpapi.com/searches/a15e1b92727f292c/64c148d35119a60ab1e00cc9.html', 'total_time_taken': 1.55}
92+
93+
94+
.. autoclass:: serpapi.SerpResults
95+
96+
.. automethod:: SerpResults.next_page
97+
.. automethod:: SerpResults.yield_pages
98+
.. autoproperty:: SerpResults.next_page_url
5399

54100

55101
Exceptions
@@ -58,9 +104,6 @@ Exceptions
58104
.. autoexception:: serpapi.SerpAPIError
59105
:members:
60106

61-
.. autoexception:: serpapi.APIKeyNotProvided
62-
:members:
63-
64107
.. autoexception:: serpapi.SearchIDNotProvided
65108
:members:
66109

serpapi/core.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,3 @@ def account(
103103
search_archive = _client.search_archive
104104
locations = _client.locations
105105
account = _client.account
106-
107-
# def search(**params):
108-
# client = Client()
109-
# return client.search(**params)
110-
111-
112-
# def search_archive(**params):
113-
# client = Client()
114-
# return client.search_archive(**params)
115-
116-
117-
# def locations(**params):
118-
# client = Client()
119-
# return client.locations(**params)
120-
121-
122-
# def account(**params):
123-
# client = Client()
124-
# return client.account(**params)

serpapi/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class SerpResults(UserDict):
1414
1515
.. code-block:: python
1616
17-
>>> serpapi = SerpAPI(api_key=os.environ["API_KEY"])
1817
>>> search = serpapi.search(q="Coffee", location="Austin, Texas, United States")
1918
2019
>>> print(search["search_metadata"].keys())

0 commit comments

Comments
 (0)