cryptodatapy.util.api_requester

Attributes

logger

Classes

APIRequester

A robust client for making external API GET requests.

Module Contents

cryptodatapy.util.api_requester.logger
class cryptodatapy.util.api_requester.APIRequester

A robust client for making external API GET requests.

Encapsulates retry logic, error handling, and throttling based on parameters supplied by the DataRequest object.

static get_request(url: str, params: Dict[str, str | int], headers: Dict[str, str] | None = None, trials: int = 3, pause: float = 0.1) Dict[str, Any] | None

Submits a resilient GET request to the API with retry logic.

Parameters:
  • url (str) – The target endpoint URL for the GET request.

  • params (dict) – Dictionary containing query parameters for the request.

  • headers (dict, optional) – Dictionary containing HTTP headers for the request.

  • trials (int, default=3) – Maximum number of attempts to make for the request.

  • pause (float, default=0.1) – Number of seconds to pause between failed attempts.

Returns:

Data response in JSON format (dict) if successful, otherwise None.

Return type:

Optional[Dict[str, Any]]