current_price: Current coin prices

Description Usage Arguments Details Value Examples

View source: R/current_price.R

Description

Retrieves current prices of supported coins

Usage

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
)

Arguments

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 supported_coins() function.

vs_currencies

(character): a vector with names of the reference currencies to express the price in, e.g. c("usd", "eur", "btc"). An up-to-date list of supported vs_currencies (both fiat and cryptocurrencies) can be obtained with the supported_currencies() function. If vs_currencies contains at least one unsupported currency, the call will fail with the respective error message.

include_market_cap

(boolean, defaults to TRUE): whether to return the market capitalisation information.

include_24h_vol

(boolean, defaults to TRUE): whether to return the trading volume for the last 24 hours.

include_24h_change

(boolean, defaults to TRUE): whether to return the price percentage change compared to 24 hours ago.

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.

If no data can be retrieved (e.g. because of a misspecified query parameter), nothing (NULL) will be returned.

Value

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

Examples

1
2
3
4
5
r <- current_price(
  coin_ids = c("aave", "tron", "bitcoin"),
  vs_currencies = c("usd", "eur", "gbp")
)
print(r)

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