Learn R Programming

cryptowatchR (version 0.2.0)

get_markets: 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

Run this code
# 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 = 1609851600, after = 1609506000))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab