Get Crypto Prices Using R Without httr2

If you are not comfortable with API requests, R has some built-in libraries that handles these things for you. One example of such is the cryptoQuotes package, which provides access to latest crypto prices and volumes without having to do the requests yourself.

We can use the getQuotes function to get the prices of any pair listed on major exchanges. Below is an example,

Getting Crypto Prices Using cryptoQuotes:

R
# 1) get latest
# BTC prices using
# getQuote
tail(
  btc_price <- cryptoQuotes::getQuote(
    ticker   = 'BTCUSDT',
    source   = 'binance',
    futures  = FALSE,
    interval = '1d'
  )
)

Output:

R
               Open     High      Low    Close   Volume
2023-12-17 42278.02 42424.07 41252.00 41374.65 27722.11
2023-12-18 41374.64 42757.81 40542.93 42657.80 46734.09
2023-12-19 42657.80 43497.00 41811.10 42275.99 40927.86
2023-12-20 42275.99 44283.00 42206.00 43668.93 48710.29
2023-12-21 43668.92 44242.35 43286.72 43861.80 34624.29
2023-12-22 43861.79 44398.26 43412.54 43939.81 27436.58


All extracted prices can charted using candlesticks and various indicators, such as Bollinger Bands. Here is an example using getQuote and chart from the package to chart the Ethereum daily price,

R
# 1) get latest
# ethereum prices
# on 15 minute intervals
eth_price <- cryptoQuotes::getQuote(
  ticker   = 'ETHUSDT',
  source   = 'binance',
  futures  = FALSE,
  interval = '1d'
)

# 2) chart prices with
# candlesticks and 
# add Bollinger Bands
cryptoQuotes::chart(
  chart = cryptoQuotes::kline(quote = eth_price) %>% 
    cryptoQuotes::addVolume() %>% 
    cryptoQuotes::addBBands(),
  slider = FALSE
)

Output:



Daily Ethereum Prices with Candlesticks and Bollinger Bands



The cryptoQuotes package supports Spot and Futures market in all available intervals, and can be installed using the following code,

R
## install cryptoQuotes
install.packages('cryptoQuotes', dependencies = TRUE)





Get Real-Time Crypto Currencies Price Using R and Binance API

 In this article, we are going to see how to get the real-time price of cryptocurrencies using Binance API  in R Programming Language.

Similar Reads

Binance API

Binance API is a method that allows you to connect to the Binance servers using several programming languages. With it, you can automate your trading and make HTTP requests to send and receive data. Here we access Binance API using R with httr2 package. We will be sending requests to Binance API and extracting the real-time price of the required cryptocurrency in JSON format....

Get Crypto Prices Using R Without httr2

If you are not comfortable with API requests, R has some built-in libraries that handles these things for you. One example of such is the cryptoQuotes package, which provides access to latest crypto prices and volumes without having to do the requests yourself....

Contact Us