Description Usage Arguments Details Value Examples
View source: R/current_price.R
Retrieves current prices of supported coins
1 2 3 4 5 6 7 8 | current_price(
coin_ids,
vs_currencies = c("usd"),
include_market_cap = TRUE,
include_24h_vol = TRUE,
include_24h_change = TRUE,
max_attempts = 3
)
|
coin_ids |
(character): a vector with IDs of the coins of
interest. An up-to-date list of supported coins and their
IDs can be obtained with the |
vs_currencies |
(character): a vector with
names of the reference currencies to express the price in, e.g.
|
include_market_cap |
(boolean, defaults to
|
include_24h_vol |
(boolean, defaults to |
include_24h_change |
(boolean, defaults to
|
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.
If no data can be retrieved (e.g. because of a misspecified
query parameter), nothing (NULL
) will be returned.
A tibble, which by the default will contain the following columns (use
arguments include_market_cap
, include_24h_vol
and include_24h_change
to control the inclusion of the corresponding columns):
coin_id
(character): coin IDs, ordered alphabetically;
price
(double): coin price;
vs_currency
(character): reference currency, in which the price of
coin_id
is expressed;
market_cap
(double): current market capitalisation;
vol_24h
(double): trading volume in the last 24 hours;
price_percent_change_24h
(double): percentage change of the price as
compared to 24 hours ago;
last_updated_at
(POSIXct, UTC time zone): timestamp of the last price
update.
1 2 3 4 5 | r <- current_price(
coin_ids = c("aave", "tron", "bitcoin"),
vs_currencies = c("usd", "eur", "gbp")
)
print(r)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.