# Binance Public Spot API
#
# OpenAPI Specifications for the Binance Public Spot API API documents: - [https://github.com/binance/binance-spot-api-docs](https://github.com/binance/binance-spot-api-docs) - [https://binance-docs.github.io/apidocs/spot/en](https://binance-docs.github.io/apidocs/spot/en)
#
# The version of the OpenAPI document: 1.0
#
# Generated by: https://openapi-generator.tech
#' @docType class
#' @title Market operations
#' @description binanceRapi.Market
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ ApiV3AggTradesGet } \emph{ Compressed/Aggregate Trades List }
#' Get compressed, aggregate trades. Trades that fill at the time, from the same order, with the same price will have the quantity aggregated. - If `startTime` and `endTime` are sent, time between startTime and endTime must be less than 1 hour. - If `fromId`, `startTime`, and `endTime` are not sent, the most recent aggregate trades will be returned. Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } from.id integer
#' \item \emph{ @param } start.time integer
#' \item \emph{ @param } end.time integer
#' \item \emph{ @param } limit integer
#' \item \emph{ @returnType } list( \link{aggTrade} ) \cr
#'
#'
#' \item status code : 200 | Trade list
#'
#' \item return type : array[AggTrade]
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3AvgPriceGet } \emph{ Current Average Price }
#' Current average price for a symbol. Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @returnType } \link{InlineResponse2003} \cr
#'
#'
#' \item status code : 200 | Average price
#'
#' \item return type : InlineResponse2003
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3DepthGet } \emph{ Order Book }
#' | Limit | Weight(IP) | |---------------------|-------------| | 1-100 | 1 | | 101-500 | 5 | | 501-1000 | 10 | | 1001-5000 | 50 |
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } limit integer
#' \item \emph{ @returnType } \link{InlineResponse2002} \cr
#'
#'
#' \item status code : 200 | Order book
#'
#' \item return type : InlineResponse2002
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3ExchangeInfoGet } \emph{ Exchange Information }
#' Current exchange trading rules and symbol information - If any symbol provided in either symbol or symbols do not exist, the endpoint will throw an error. Weight(IP): 10
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } symbols character
#' \item \emph{ @returnType } \link{InlineResponse2001} \cr
#'
#'
#' \item status code : 200 | Current exchange trading rules and symbol information
#'
#' \item return type : InlineResponse2001
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3HistoricalTradesGet } \emph{ Old Trade Lookup (MARKET_DATA) }
#' Get older market trades. Weight(IP): 5
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } limit integer
#' \item \emph{ @param } from.id integer
#' \item \emph{ @returnType } list( \link{trade} ) \cr
#'
#'
#' \item status code : 200 | Trade list
#'
#' \item return type : array[Trade]
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 401 | Unauthorized Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3KlinesGet } \emph{ Kline/Candlestick Data }
#' Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time. - If `startTime` and `endTime` are not sent, the most recent klines are returned. Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } interval Enum < [1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M] >
#' \item \emph{ @param } start.time integer
#' \item \emph{ @param } end.time integer
#' \item \emph{ @param } limit integer
#' \item \emph{ @returnType } list( \link{array} ) \cr
#'
#'
#' \item status code : 200 | Kline data
#'
#' \item return type : array[array[OneOflongstring]]
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3PingGet } \emph{ Test Connectivity }
#' Test connectivity to the Rest API. Weight(IP): 1
#'
#' \itemize{
#'
#'
#' \item status code : 200 | OK
#'
#' \item return type : object
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3Ticker24hrGet } \emph{ 24hr Ticker Price Change Statistics }
#' 24 hour rolling window price change statistics. Careful when accessing this with no symbol. - If the symbol is not sent, tickers for all symbols will be returned in an array. Weight(IP): - `1` for a single symbol; - `40` when the symbol parameter is omitted;
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } symbols character
#' \item \emph{ @returnType } \link{OneOftickertickerList} \cr
#'
#'
#' \item status code : 200 | 24hr ticker
#'
#' \item return type : OneOftickertickerList
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3TickerBookTickerGet } \emph{ Symbol Order Book Ticker }
#' Best price/qty on the order book for a symbol or symbols. - If the symbol is not sent, bookTickers for all symbols will be returned in an array. Weight(IP): - `1` for a single symbol; - `2` when the symbol parameter is omitted;
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } symbols character
#' \item \emph{ @returnType } \link{OneOfbookTickerbookTickerList} \cr
#'
#'
#' \item status code : 200 | Order book ticker
#'
#' \item return type : OneOfbookTickerbookTickerList
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3TickerPriceGet } \emph{ Symbol Price Ticker }
#' Latest price for a symbol or symbols. - If the symbol is not sent, prices for all symbols will be returned in an array. Weight(IP): - `1` for a single symbol; - `2` when the symbol parameter is omitted;
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } symbols character
#' \item \emph{ @returnType } \link{OneOfpriceTickerpriceTickerList} \cr
#'
#'
#' \item status code : 200 | Price ticker
#'
#' \item return type : OneOfpriceTickerpriceTickerList
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3TimeGet } \emph{ Check Server Time }
#' Test connectivity to the Rest API and get the current server time. Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @returnType } \link{InlineResponse200} \cr
#'
#'
#' \item status code : 200 | Binance server UTC timestamp
#'
#' \item return type : InlineResponse200
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3TradesGet } \emph{ Recent Trades List }
#' Get recent trades. Weight(IP): 1
#'
#' \itemize{
#' \item \emph{ @param } symbol character
#' \item \emph{ @param } limit integer
#' \item \emph{ @returnType } list( \link{trade} ) \cr
#'
#'
#' \item status code : 200 | Trade list
#'
#' \item return type : array[Trade]
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' #################### ApiV3AggTradesGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.from.id <- 56 # integer | Trade id to fetch from. Default gets most recent trades.
#' var.start.time <- 56 # integer | UTC timestamp in ms
#' var.end.time <- 56 # integer | UTC timestamp in ms
#' var.limit <- 500 # integer | Default 500; max 1000.
#'
#' #Compressed/Aggregate Trades List
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3AggTradesGet(var.symbol, from.id=var.from.id, start.time=var.start.time, end.time=var.end.time, limit=var.limit)
#'
#'
#' #################### ApiV3AvgPriceGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#'
#' #Current Average Price
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3AvgPriceGet(var.symbol)
#'
#'
#' #################### ApiV3DepthGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.limit <- 100 # integer | If limit > 5000, then the response will truncate to 5000
#'
#' #Order Book
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3DepthGet(var.symbol, limit=var.limit)
#'
#'
#' #################### ApiV3ExchangeInfoGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.symbols <- '[\"BTCUSDT\",\"BNBBTC\"]' # character |
#'
#' #Exchange Information
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3ExchangeInfoGet(symbol=var.symbol, symbols=var.symbols)
#'
#'
#' #################### ApiV3HistoricalTradesGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.limit <- 500 # integer | Default 500; max 1000.
#' var.from.id <- 56 # integer | Trade id to fetch from. Default gets most recent trades.
#'
#' #Old Trade Lookup (MARKET_DATA)
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3HistoricalTradesGet(var.symbol, limit=var.limit, from.id=var.from.id)
#'
#'
#' #################### ApiV3KlinesGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.interval <- 'interval_example' # character | kline intervals
#' var.start.time <- 56 # integer | UTC timestamp in ms
#' var.end.time <- 56 # integer | UTC timestamp in ms
#' var.limit <- 500 # integer | Default 500; max 1000.
#'
#' #Kline/Candlestick Data
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3KlinesGet(var.symbol, var.interval, start.time=var.start.time, end.time=var.end.time, limit=var.limit)
#'
#'
#' #################### ApiV3PingGet ####################
#'
#' library(binanceRapi)
#'
#' #Test Connectivity
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3PingGet()
#'
#'
#' #################### ApiV3Ticker24hrGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.symbols <- '[\"BTCUSDT\",\"BNBBTC\"]' # character |
#'
#' #24hr Ticker Price Change Statistics
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3Ticker24hrGet(symbol=var.symbol, symbols=var.symbols)
#'
#'
#' #################### ApiV3TickerBookTickerGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.symbols <- '[\"BTCUSDT\",\"BNBBTC\"]' # character |
#'
#' #Symbol Order Book Ticker
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3TickerBookTickerGet(symbol=var.symbol, symbols=var.symbols)
#'
#'
#' #################### ApiV3TickerPriceGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.symbols <- '[\"BTCUSDT\",\"BNBBTC\"]' # character |
#'
#' #Symbol Price Ticker
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3TickerPriceGet(symbol=var.symbol, symbols=var.symbols)
#'
#'
#' #################### ApiV3TimeGet ####################
#'
#' library(binanceRapi)
#'
#' #Check Server Time
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3TimeGet()
#'
#'
#' #################### ApiV3TradesGet ####################
#'
#' library(binanceRapi)
#' var.symbol <- 'BNBUSDT' # character | Trading symbol, e.g. BNBUSDT
#' var.limit <- 500 # integer | Default 500; max 1000.
#'
#' #Recent Trades List
#' api.instance <- MarketApi$new()
#'
#' result <- api.instance$ApiV3TradesGet(var.symbol, limit=var.limit)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
MarketApi <- R6::R6Class(
'MarketApi',
public = list(
apiClient = NULL,
initialize = function(apiClient){
if (!missing(apiClient)) {
self$apiClient <- apiClient
}
else {
self$apiClient <- ApiClient$new()
}
},
ApiV3AggTradesGet = function(symbol, from.id=NULL, start.time=NULL, end.time=NULL, limit=NULL, ...){
apiResponse <- self$ApiV3AggTradesGetWithHttpInfo(symbol, from.id, start.time, end.time, limit, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3AggTradesGetWithHttpInfo = function(symbol, from.id=NULL, start.time=NULL, end.time=NULL, limit=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`symbol`)) {
stop("Missing required parameter `symbol`.")
}
queryParams['symbol'] <- symbol
queryParams['fromId'] <- from.id
queryParams['startTime'] <- start.time
queryParams['endTime'] <- end.time
queryParams['limit'] <- limit
body <- NULL
urlPath <- "/api/v3/aggTrades"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "array[AggTrade]", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3AvgPriceGet = function(symbol, ...){
apiResponse <- self$ApiV3AvgPriceGetWithHttpInfo(symbol, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3AvgPriceGetWithHttpInfo = function(symbol, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`symbol`)) {
stop("Missing required parameter `symbol`.")
}
queryParams['symbol'] <- symbol
body <- NULL
urlPath <- "/api/v3/avgPrice"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "InlineResponse2003", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3DepthGet = function(symbol, limit=100, ...){
apiResponse <- self$ApiV3DepthGetWithHttpInfo(symbol, limit, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3DepthGetWithHttpInfo = function(symbol, limit=100, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`symbol`)) {
stop("Missing required parameter `symbol`.")
}
queryParams['symbol'] <- symbol
queryParams['limit'] <- limit
body <- NULL
urlPath <- "/api/v3/depth"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "InlineResponse2002", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3ExchangeInfoGet = function(symbol=NULL, symbols=NULL, ...){
apiResponse <- self$ApiV3ExchangeInfoGetWithHttpInfo(symbol, symbols, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3ExchangeInfoGetWithHttpInfo = function(symbol=NULL, symbols=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
queryParams['symbol'] <- symbol
queryParams['symbols'] <- symbols
body <- NULL
urlPath <- "/api/v3/exchangeInfo"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "InlineResponse2001", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3HistoricalTradesGet = function(symbol, limit=NULL, from.id=NULL, ...){
apiResponse <- self$ApiV3HistoricalTradesGetWithHttpInfo(symbol, limit, from.id, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3HistoricalTradesGetWithHttpInfo = function(symbol, limit=NULL, from.id=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`symbol`)) {
stop("Missing required parameter `symbol`.")
}
queryParams['symbol'] <- symbol
queryParams['limit'] <- limit
queryParams['fromId'] <- from.id
body <- NULL
urlPath <- "/api/v3/historicalTrades"
# API key authentication
if (nchar(self$apiClient$credentials$key) > 0) {
headerParams['X-MBX-APIKEY'] <- self$apiClient$credentials$key
}
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "array[Trade]", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3KlinesGet = function(symbol, interval, start.time=NULL, end.time=NULL, limit=NULL, ...){
apiResponse <- self$ApiV3KlinesGetWithHttpInfo(symbol, interval, start.time, end.time, limit, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3KlinesGetWithHttpInfo = function(symbol, interval, start.time=NULL, end.time=NULL, limit=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`symbol`)) {
stop("Missing required parameter `symbol`.")
}
if (missing(`interval`)) {
stop("Missing required parameter `interval`.")
}
queryParams['symbol'] <- symbol
queryParams['interval'] <- interval
queryParams['startTime'] <- start.time
queryParams['endTime'] <- end.time
queryParams['limit'] <- limit
body <- NULL
urlPath <- "/api/v3/klines"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "array[array[OneOflongstring]]", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3PingGet = function(...){
apiResponse <- self$ApiV3PingGetWithHttpInfo(...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3PingGetWithHttpInfo = function(...){
args <- list(...)
queryParams <- list()
headerParams <- c()
body <- NULL
urlPath <- "/api/v3/ping"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "object", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3Ticker24hrGet = function(symbol=NULL, symbols=NULL, ...){
apiResponse <- self$ApiV3Ticker24hrGetWithHttpInfo(symbol, symbols, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3Ticker24hrGetWithHttpInfo = function(symbol=NULL, symbols=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
queryParams['symbol'] <- symbol
queryParams['symbols'] <- symbols
body <- NULL
urlPath <- "/api/v3/ticker/24hr"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "OneOftickertickerList", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3TickerBookTickerGet = function(symbol=NULL, symbols=NULL, ...){
apiResponse <- self$ApiV3TickerBookTickerGetWithHttpInfo(symbol, symbols, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3TickerBookTickerGetWithHttpInfo = function(symbol=NULL, symbols=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
queryParams['symbol'] <- symbol
queryParams['symbols'] <- symbols
body <- NULL
urlPath <- "/api/v3/ticker/bookTicker"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "OneOfbookTickerbookTickerList", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3TickerPriceGet = function(symbol=NULL, symbols=NULL, ...){
apiResponse <- self$ApiV3TickerPriceGetWithHttpInfo(symbol, symbols, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3TickerPriceGetWithHttpInfo = function(symbol=NULL, symbols=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
queryParams['symbol'] <- symbol
queryParams['symbols'] <- symbols
body <- NULL
urlPath <- "/api/v3/ticker/price"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "OneOfpriceTickerpriceTickerList", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3TimeGet = function(...){
apiResponse <- self$ApiV3TimeGetWithHttpInfo(...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3TimeGetWithHttpInfo = function(...){
args <- list(...)
queryParams <- list()
headerParams <- c()
body <- NULL
urlPath <- "/api/v3/time"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "InlineResponse200", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
},
ApiV3TradesGet = function(symbol, limit=NULL, ...){
apiResponse <- self$ApiV3TradesGetWithHttpInfo(symbol, limit, ...)
resp <- apiResponse$response
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
apiResponse$content
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
apiResponse
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
apiResponse
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
apiResponse
}
},
ApiV3TradesGetWithHttpInfo = function(symbol, limit=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
if (missing(`symbol`)) {
stop("Missing required parameter `symbol`.")
}
queryParams['symbol'] <- symbol
queryParams['limit'] <- limit
body <- NULL
urlPath <- "/api/v3/trades"
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "array[Trade]", loadNamespace("binanceRapi")),
error = function(e){
stop("Failed to deserialize response")
}
)
ApiResponse$new(deserializedRespObj, resp)
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
ApiResponse$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
ApiResponse$new("API server error", resp)
}
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.