get_price_conversion: Price Conversion

View source: R/tools.R

get_price_conversionR Documentation

Price Conversion

Description

Convert an amount of one cryptocurrency or fiat currency into one or more different currencies utilizing the latest market rate for each currency. You may optionally pass a historical timestamp as time to convert values based on historical rates (as your API plan supports).

Usage

get_price_conversion(amount = NULL, id, symbol, time, convert, convert_id)

Arguments

amount

An amount of currency to convert. Example: 10.43

id

The CoinMarketCap currency ID of the base cryptocurrency or fiat to convert from. If id and symbol are both missing or NULL, 'BTC' is set as default symbol.

symbol

Alternatively the currency symbol of the base cryptocurrency or fiat to convert from. One id or symbol is required.

time

Optional timestamp to reference historical pricing during conversion. If not passed, the current time will be used. If passed, we'll reference the closest historic values available for this conversion.

convert

Pass up to 120 comma-separated fiat or cryptocurrency symbols to convert the source amount to. Default is 'USD'.

convert_id

Optionally calculate market quotes by CoinMarketCap ID instead of symbol. This option is identical to convert outside of ID format. Ex: convert_id=1,2781 would replace convert=BTC,USD in your query. This parameter cannot be used when convert is used.

Details

Cache / Update frequency:Every 60 seconds for the lastest cryptocurrency and fiat currency rates. Plan credit use: 1 call credit per call and 1 call credit per convert option beyond the first. CMC equivalent pages: Our cryptocurrency conversion page at converter.

Value

A dataframe with price conversion information

References

API documentation

Examples

## Not run: 
get_price_conversion(1)
get_price_conversion(amount = 1, symbol = "BTC", convert = c("EUR","LTC","USD"))
get_price_conversion(amount = 1, id=1, time = Sys.Date()-100)

## End(Not run)

coinmarketcapr documentation built on March 18, 2022, 6:19 p.m.