Client
A class that handles API requests to SerpApi in a user-friendly manner.
Usage
Client()Store your API key in an environment variable, then create a client with serpapi.Client(api_key=os.environ["SERPAPI_KEY"]).
Parameters
api_key=None-
The API Key to use for SerpApi.com.
timeout=None- The default timeout to use for requests.
Attributes
| Name | Description |
|---|---|
| DASHBOARD_URL | str(object=’’) -> str |
DASHBOARD_URL
str(object=’’) -> str
DASHBOARD_URL="https://serpapi.com/dashboard"
str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to ‘utf-8’. errors defaults to ‘strict’.
Methods
| Name | Description |
|---|---|
| account() | Get SerpApi account information. |
| locations() | Get a list of supported Google locations. |
| search() | Fetch a page of results from SerpApi. |
| search_archive() | Get a result from the SerpApi Search Archive API. |
account()
Get SerpApi account information.
Usage
account(params=None, **kwargs)Parameters
params: dict = None-
Account API parameters.
kwargs={}-
Additional account parameters or request options.
timeout,proxies,verify,stream, andcertare passed to the underlying HTTP request. Learn more: https://serpapi.com/account-api
locations()
Get a list of supported Google locations.
Usage
locations(params=None, **kwargs)Parameters
params: dict = None-
Location API parameters such as
qandlimit. kwargs={}-
Additional location parameters or request options.
timeout,proxies,verify,stream, andcertare passed to the underlying HTTP request. Learn more: https://serpapi.com/locations-api
search()
Fetch a page of results from SerpApi.
Usage
search(params=None, **kwargs)Returns a serpapi.SerpResults object for JSON responses, or text when output="html" is requested. Prefer passing SerpApi engine parameters as keyword arguments. A parameter dictionary is also accepted when your code already has parameters in a mapping.
Parameters
params: dict = None-
Optional mapping of SerpApi search parameters such as
engine,q,location, andoutput. kwargs={}-
Additional SerpApi parameters or request options.
timeout,proxies,verify,stream, andcertare passed to the underlying HTTP request. Learn more: https://serpapi.com/search-api
search_archive()
Get a result from the SerpApi Search Archive API.
Usage
search_archive(params=None, **kwargs)Parameters
params: dict = None-
Archive parameters. Must include
search_id. kwargs={}-
Additional archive parameters or request options.
timeout,proxies,verify,stream, andcertare passed to the underlying HTTP request. Learn more: https://serpapi.com/search-archive-api