The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
An API wrapper for Cryptowatch written in R
This R package provides a wrapper for the Cryptowatch API. You can get prices and other information (volume, trades, order books, bid and ask prices, live quotes, and more) about cryptocurrencies and crypto exchanges. Check https://docs.cryptowat.ch/rest-api for a detailed documentation. The API is free of charge and does not require you to create an API key. For example, you can easily retrieve historical prices for a large number of cryptocurrencies without setting up an account. However, for heavy users, this option is included in the package as well.
You can install the released version of cryptowatchR from CRAN with:
install.packages("cryptowatchR")
You can install the development version from GitHub with:
# install.packages("devtools")
::install_github("lorenzbr/cryptowatchR") devtools
## Examples
library(cryptowatchR)
# Settings
<- "kraken"
exchange <- "btcusd"
pair <- "ohlc"
route
# Daily prices for longest possible time period
<- get_markets(route, pair, exchange, list(periods = 86400))
markets.btcusd
# Daily prices of Bitcoin in USD
<- get_ohlc(pair)
df.ohlc.daily
# Hourly prices
<- get_ohlc(pair, periods = 3600, before = 1609851600, after = 1609506000,
df.ohlc.hourly datetime = FALSE)
exchange,
# Hourly prices using date/datetime variables
<- get_ohlc(pair, periods = 3600, before = "2021-01-05", after = "2021-01-01",
df.ohlc.hourly.datetime datetime = TRUE)
exchange,
# Daily prices using date/datetime variables
<- get_ohlc(pair, periods = 86400, before = "2021-05-12", after = "2021-01-01",
df.ohlc.daily.datetime datetime = TRUE)
exchange,
# Daily prices using POSIX time
<- get_ohlc(pair, periods = 86400, before = as.numeric(as.POSIXct("2021-05-12 14:00:00 UCT")),
df.ohlc.daily.posix after = as.numeric(as.POSIXct("2021-01-01 14:00:00 UCT")), exchange, datetime = FALSE)
# Current market price
<- get_current_price("btcusd")
current.price <- get_current_price()
current.prices
## Get trades
# Most recent trades (default is 50)
<- get_trades(pair)
trades # 100 trades
.100 <- get_trades(pair, limit = 100, datetime = FALSE)
trades# 200 trades (maximum is 1000) since 1589571417 (unix timestamp)
<- get_trades(pair, since = 1589571417, limit = 200, datetime = FALSE)
trades.unix # 1000 trades and datetime is TRUE
<- get_trades(pair, since = "2021-06-01", limit = 1000)
trades.datetime
# 24h-hour summary of cryptocurrency pairs
<- get_summary("btcusd")
summary <- get_summary()
summaries <- get_summary(keyBy = "id")
summaries.id <- get_summary(keyBy = "symbols")
summaries.symbols
# Orderbook for Bitcoin-USD (bid and ask with Price and Amount)
<- get_orderbook(pair, exchange = exchange)
orderbook <- get_orderbook(pair, exchange = exchange, depth = 100)
orderbook.depth <- get_orderbook(pair, exchange = exchange, span = 0.5)
orderbook.span <- get_orderbook(pair, exchange = exchange, limit = 1)
orderbook.limit
# Get liquidity sums in the order book of Bitcoin in USD
<- get_orderbook_liquidity("btcusd")
liquidity
# Live quote for 50 Bitcoins
<- get_orderbook_calculator("btcusd", amount = 50)
calculator
# Asset information
<- get_assets()
df.assets <- get_assets("btc")
asset.btc
# Information on pairs of currencies
<- get_pairs()
df.pairs <- get_pairs("btcusd")
pair.btcusd
# Information on crypto exchanges
<- get_exchanges()
df.exchanges <- get_exchanges("kraken")
exchange.kraken
# Current market price
<- get_markets(route = "price", pair, exchange)
markets.price.btcusd
# All current market prices for all exchanges
<- get_markets(route = "prices")
markets.price
# Most recent trades (default is 50)
<- get_markets(route = "trades", pair, exchange)
markets.trades
# 200 Trades (maximum is 1000) since 1589571417
<- list(since = 1589571417, limit = 200)
params.prices <- get_markets(route = "trades", pair, exchange, params.prices)
markets.trades2
# Last price and other stats for Bitcoin-USD pair
<- get_markets(route = "summary", pair, exchange)
markets.summary.btcusd
# Summaries for every pair and every exchange
<- get_markets(route = "summaries")
markets.summaries <- get_markets(route = "summaries", params = list(keyBy = "id"))
markets.summaries.id <- get_markets(route = "summaries", params = list(keyBy = "symbols"))
markets.summaries.symbols
# Orderbook for Bitcoin-USD (bid and ask with Price and Amount)
<- get_markets(route = "orderbook", pair, exchange)
markets.orderbook <- get_markets(route = "orderbook", pair, exchange,
markets.orderbook.depth params = list(depth = 100))
<- get_markets(route = "orderbook", pair, exchange, params = list(span = 0.5))
markets.orderbook.span <- get_markets(route = "orderbook", pair, exchange, params = list(limit = 1))
markets.orderbook.limit <- get_markets(route = "orderbook/liquidity", pair, exchange)
markets.orderbook.liquidity <- get_markets(route = "orderbook/calculator", pair, exchange,
markets.orderbook.calculator params = list(amount = 1))
Please contact lorenz.brachtendorf@gmx.de if you want to contribute to this project.
You can also submit bug reports and suggestions via e-mail or https://github.com/lorenzbr/cryptowatchR/issues
This R package is licensed under the GNU General Public License v3.0.
See here for further information.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.