Description Usage Arguments Details Value Examples
View source: R/exchange_rate.R
Retrieves the current exchange rate for a crypto- of fiat currency in Bitcoin
1 | exchange_rate(currency = NULL, max_attempts = 3)
|
currency |
(character or |
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. |
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.
A tibble with the following columns:
timestamp
(POSIXct): date and time of the API request;
currency
(character): abbreviated name of the currency;
name
(character): common name of the currency;
price_in_btc
(double): price in Bitcoin;
type
(character): type of the currency ("fiat"
or "crypto"
).
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.