Getting started with Coinmarketcapr


This vignette is to help you get started with Coinmarketcapr Package that helps to extract and monitor price and market cap of Cryptocurrencies from CoinMarketCap. Simply, Coinmarketcapr is an R-binding for Coinmarketcap API that lists Price, Marketcap, Transaction Volume of many Cryptocurrencies and tokens.

Basic Functions

This package contains three primary functions:

Getting Valid Currrenices

This function get_valid_currencies() lists a character vector with all the valid currencies (ISO Codes) supported by Coinmarketcap API. These currency codes can be used in other functions like get_global_marketcap() to extract values in the given currency.

#>  [1] "AUD" "BRL" "CAD" "CHF" "CLP" "CNY" "CZK" "DKK" "EUR" "GBP" "HKD"
#> [12] "HUF" "IDR" "ILS" "INR" "JPY" "KRW" "MXN" "MYR" "NOK" "NZD" "PHP"
#> [23] "PKR" "PLN" "RUB" "SEK" "SGD" "THB" "TRY" "TWD" "ZAR" "USD"

Getting Global Marketcap

This function get_global_marketcap() fetches the USD value of global marketcap of all cryptocurrencies.

#>   total_market_cap_usd total_24h_volume_usd
#> 1          3.32051e+11         134021632244
#>   bitcoin_percentage_of_market_cap active_currencies active_assets
#> 1                            62.58               886          1364
#>   active_markets        last_updated
#> 1          19047 2019-06-27 19:25:30

Extracting all Cryptocurrencies

This function get_marketcap_ticker_all() gets various useful values such as Price, Marketcap, Total Volume, 24-hour Change and much for all the cryptocurrencies.

#>  [1] "id"                 "name"               "symbol"            
#>  [4] "rank"               "price_usd"          "price_btc"         
#>  [7] "X24h_volume_usd"    "market_cap_usd"     "available_supply"  
#> [10] "total_supply"       "max_supply"         "percent_change_1h" 
#> [13] "percent_change_24h" "percent_change_7d"  "last_updated"

Plotting Top Cryptocurrencies

This function plot_top_currencies() makes it straightforward to make a barplot of top cryptocurrencies by their rank which is actually based on Market cap.

Plotting Top 5 Cryptocurrencies

Plotting Top 5 Cryptocurrencies

Plotting with Themes

plot_top_currencies() outputs a ggplot object hence using + operator a new ggplot2 theme can be applied. ggthemes package has got a rich set of out-of-box themes to use with.

#> Warning: package 'ggthemes' was built under R version 3.5.2
plot_top_currencies() + 
Plot with Themes

Plot with Themes

Cryptocurrencies Market - Tidy Analysis

Since coinmarketcapr’s get_marketcap_ticker_all() returns a dataframe, it could be fit in alongside with Tidy Data pipeline.

#> Warning: package 'dplyr' was built under R version 3.5.2
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>     filter, lag
#> The following objects are masked from 'package:base':
#>     intersect, setdiff, setequal, union
#> Warning: package 'ggplot2' was built under R version 3.5.2

get_marketcap_ticker_all() %>% 
        slice(1:30) %>% 
        mutate(price_usd = as.numeric(price_usd)) %>% 
        ggplot() + geom_histogram(aes(price_usd)) +
        ggtitle('Cryptocurrencies Price in USD Histogram')
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Cryptocurrencies Price in USD Histogram

Cryptocurrencies Price in USD Histogram


Coinmarketcapr is powered by