# 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 Stream operations
#' @description binanceRapi.Stream
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ ApiV3UserDataStreamDelete } \emph{ Close a ListenKey (USER_STREAM) }
#' Close out a user data stream. Weight: 1
#'
#' \itemize{
#' \item \emph{ @param } listen.key character
#'
#'
#' \item status code : 200 | OK
#'
#' \item return type : object
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3UserDataStreamPost } \emph{ Create a ListenKey (USER_STREAM) }
#' Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active `listenKey`, that `listenKey` will be returned and its validity will be extended for 60 minutes. Weight: 1
#'
#' \itemize{
#' \item \emph{ @returnType } \link{InlineResponse20080} \cr
#'
#'
#' \item status code : 200 | Listen key
#'
#' \item return type : InlineResponse20080
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ ApiV3UserDataStreamPut } \emph{ Ping/Keep-alive a ListenKey (USER_STREAM) }
#' Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 30 minutes. Weight: 1
#'
#' \itemize{
#' \item \emph{ @param } listen.key character
#'
#'
#' \item status code : 200 | OK
#'
#' \item return type : object
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 400 | Bad Request
#'
#' \item return type : Error
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' #################### ApiV3UserDataStreamDelete ####################
#'
#' library(binanceRapi)
#' var.listen.key <- 'pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1' # character | User websocket listen key
#'
#' #Close a ListenKey (USER_STREAM)
#' api.instance <- StreamApi$new()
#'
#' result <- api.instance$ApiV3UserDataStreamDelete(listen.key=var.listen.key)
#'
#'
#' #################### ApiV3UserDataStreamPost ####################
#'
#' library(binanceRapi)
#'
#' #Create a ListenKey (USER_STREAM)
#' api.instance <- StreamApi$new()
#'
#' result <- api.instance$ApiV3UserDataStreamPost()
#'
#'
#' #################### ApiV3UserDataStreamPut ####################
#'
#' library(binanceRapi)
#' var.listen.key <- 'pqia91ma19a5s61cv6a81va65sdf19v8a65a1a5s61cv6a81va65sdf19v8a65a1' # character | User websocket listen key
#'
#' #Ping/Keep-alive a ListenKey (USER_STREAM)
#' api.instance <- StreamApi$new()
#'
#' result <- api.instance$ApiV3UserDataStreamPut(listen.key=var.listen.key)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
StreamApi <- R6::R6Class(
'StreamApi',
public = list(
apiClient = NULL,
initialize = function(apiClient){
if (!missing(apiClient)) {
self$apiClient <- apiClient
}
else {
self$apiClient <- ApiClient$new()
}
},
ApiV3UserDataStreamDelete = function(listen.key=NULL, ...){
apiResponse <- self$ApiV3UserDataStreamDeleteWithHttpInfo(listen.key, ...)
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
}
},
ApiV3UserDataStreamDeleteWithHttpInfo = function(listen.key=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
queryParams['listenKey'] <- listen.key
body <- NULL
urlPath <- "/api/v3/userDataStream"
# 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 = "DELETE",
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)
}
},
ApiV3UserDataStreamPost = function(...){
apiResponse <- self$ApiV3UserDataStreamPostWithHttpInfo(...)
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
}
},
ApiV3UserDataStreamPostWithHttpInfo = function(...){
args <- list(...)
queryParams <- list()
headerParams <- c()
body <- NULL
urlPath <- "/api/v3/userDataStream"
# 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 = "POST",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
deserializedRespObj <- tryCatch(
self$apiClient$deserialize(resp, "InlineResponse20080", 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)
}
},
ApiV3UserDataStreamPut = function(listen.key=NULL, ...){
apiResponse <- self$ApiV3UserDataStreamPutWithHttpInfo(listen.key, ...)
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
}
},
ApiV3UserDataStreamPutWithHttpInfo = function(listen.key=NULL, ...){
args <- list(...)
queryParams <- list()
headerParams <- c()
queryParams['listenKey'] <- listen.key
body <- NULL
urlPath <- "/api/v3/userDataStream"
# 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 = "PUT",
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)
}
}
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.