ads.client¶
Client for handling API requests to ADS.
Classes
|
A response from an ADS API end point. |
|
A class for handling API requests to ADS. |
|
A singleton to store ADS service rate limits. |
|
- class ads.client.APIResponse(http_response, _json=None)[source]¶
A response from an ADS API end point.
- class ads.client.Client[source]¶
A class for handling API requests to ADS.
- property token: str¶
Return the ADS API token by following the logic below, and stopping whenever a token is found:
The environment variables in
ads.config.TOKEN_ENVIRON_VARS
:ADS_API_TOKEN
ADS_DEV_KEY
File containing plaintext as the contents in
ads.config.TOKEN_FILES
:~/.ads/token
~/.ads/dev_key
The value in
ads.config.token
.
- property async_session¶
A client session for performing asynchronous HTTP requests.
- property session¶
A client session for performing synchronous HTTP requests.
- api_request(end_point: str, method: str = 'get', **kwargs) ads.client.APIResponse [source]¶
Perform a synchronous API request.
- Parameters
end_point – The API end-point (e.g., ‘/search/query’).
method – [optional] The HTTP method to use for the request (default: get).
kwargs – [optional] Keyword arguments to pass to the requests.request method. Examples include data, params, etc.
- Returns
A
ads.client.APIResponse
object.
- class ads.client.RateLimits(*args, **kwargs)[source]¶
A singleton to store ADS service rate limits.
- classmethod get_service(url: str) str [source]¶
Return the ADS service given a URL.
- Parameters
url – The requested URL.