ads.client

Client for handling API requests to ADS.

Classes

APIResponse(http_response[, _json])

A response from an ADS API end point.

Client()

A class for handling API requests to ADS.

RateLimits(*args, **kwargs)

A singleton to store ADS service rate limits.

SearchQuery(**kwargs)

class ads.client.APIResponse(http_response, _json=None)[source]

A response from an ADS API end point.

__init__(http_response, _json=None)[source]
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.

classmethod set_from_http_response(http_response: requests.models.Response) None[source]

Set the current rate limits from the given HTTP response.

Parameters
  • service – The ADS service name.

  • http_response – The HTTP response.

set(service: str, **kwargs) None[source]

Set the limits for an ADS service.

Parameters
  • service – The service name (e.g., solr).

  • kwargs – The keyword arguments to set for the limits (e.g., limit, remaining, reset).