Performs GET requests, with a built-in exponential backoff mechanism for retries

api_request(url, max_attempts = 3)

Arguments

url

(character): URL to call.

max_attempts

(double, positive): specifies the maximum number of attempts to call the CoinGecko API (e.g., if the first call fails for some reason). Additional attempts are implemented with an exponential backoff. Defaults to 3.

Value

A named list, the structure of which will vary depending on the actual GET request made.

Details

This function only performs GET requests. The url is expected to be built properly before passing onto this function. The returned data are expected to be in JSON format. This function will automatically parse the response object and return a named R list with the respective elements. If no data can be retrieved (e.g. because of a misspecified query parameter), the function will return nothing (NULL).