get_markets: Get prices of cryptocurrencies

View source: R/get_markets.R

get_marketsR Documentation

Get prices of cryptocurrencies

Description

Get prices of cryptocurrencies using the REST API of cryptowat.ch.

Usage

get_markets(route, pair = NULL, exchange = NULL, params = NULL,
            api_key = NULL, allowance = FALSE)

Arguments

route

A character string containing a market endpoint. Possible values: price, prices, trades, summary, summaries, orderbook, orderbook/liquidity, orderbooks/calculator, ohlc (required argument). See https://docs.cryptowat.ch/rest-api/markets for further information.

pair

A character string containing a pair symbol, e.g. btcusd (optional argument). Run get_pairs() to find other available pairs.

exchange

A character string containing the exchange (optional argument). Run get_exchanges() to find other available exchanges.

params

A list containing query parameters. E.g., for the route ohlc, this is before, after and periods (optional). See https://docs.cryptowat.ch/rest-api/markets for further information.

api_key

A character string containing the API key. See https://docs.cryptowat.ch/rest-api/rate-limit to learn how to create an account and how to generate an API key.

allowance

A logical (default is FALSE). If TRUE the function returns a list which includes allowance information, i.e., cost of the request, remaining credits and your account name.

Value

A list containing markets data.

References

See https://docs.cryptowat.ch/rest-api for further information

See Also

markets, get_assets, get_exchanges, get_pairs

Examples

## Not run: 
# Prices of Bitcoin in USD for all periods
btcusd_ohlc_all <- get_markets(route = "ohlc", pair = "btcusd", exchange = "kraken")
# Hourly prices of Bitcoin in USD for a specific time period
btcusd_ohlc_hourly <- get_markets(route = "ohlc", pair = "btcusd", exchange = "kraken",
                            list(periods = 3600, before = as.numeric(as.POSIXct(Sys.Date())),
                                 after = as.numeric(as.POSIXct(Sys.Date() - 5))))

## End(Not run)


lorenzbr/cryptowatchR documentation built on April 15, 2022, 4:41 a.m.