api_request: Make an API call

Description Usage Arguments Details Value

View source: R/api_request.R

Description

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

Usage

1
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.

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).

Value

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


geckor documentation built on Nov. 1, 2021, 5:07 p.m.