exchange_rate: Exchange rate

Description Usage Arguments Details Value Examples

View source: R/exchange_rate.R

Description

Retrieves the current exchange rate for a crypto- of fiat currency in Bitcoin

Usage

1
exchange_rate(currency = NULL, max_attempts = 3)

Arguments

currency

(character or NULL): a vector with abbreviated names of the currencies of interest. An up-to-date list of supported currencies (both fiat and cryptocurrencies) can be retrieved with the supported_currencies() function. If an unsupported currency is requested, the call will fail with the respective error message. If currency = NULL (default), the function will return exchange rates for all supported currencies.

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 is based on the public CoinGecko API, which has a limit of 50 calls per minute. Please keep this limit in mind when developing your applications.

Value

A tibble with the following columns:

Examples

1
2
3
4
5
6
7
# get exchange rates for all supported currencies
r1 <- exchange_rate()
print(r1)

# get exchange rates for a set of currencies:
r2 <- exchange_rate(currency = c("usd", "eur", "gbp"))
print(r2)

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