Skip to content

Binance US

Trevor French edited this page Dec 9, 2023 · 3 revisions

Binance.US

Logo Name Code cryptotrackr Docs Exchange Docs Source Code
binance_us Binance.US binance_us /docs/binance_us.md 🏢 /R/binance_us.R

Functions:

binance_us_time, binance_us_signature, binance_us_api_call, binance_us_account_info, binance_us_recent_trades, binance_us_ping, binance_us_server_time, binance_us_system_status

binance_us_time

  • Returns: a timestamp in the format that Binance.US expects

  • The following example retrieves the formatted Binance.US time for use in a Binance.US API call and stores it in a variable named "time"

time <- binance_us_time()

binance_us_signature

  • Parameters: (data, secret)

  • data: your URL encoded query parameters

  • secret: your Binance.US secret key

  • Returns: your Binance.US signature for use in API calls

  • The following example retrieves the formatted binance_us_time and puts it into the message data then passes the message data and the secret into the function to retrieve a signature for use in a Binance.US API call

time <- binance_us_time()
data <- paste('timestamp=', time, sep = '')
secret <- "..."
signature <- binance_us_signature(data, secret)

binance_us_api_call

  • Parameters: (url, key, data, secret)

  • url: the base url and endpoint followed by '?' for your API call

  • key: your Binance.US API key

  • data: your URL encoded query parameters

  • secret: your Binance.US secret key

  • Returns: an executed and authenticated API call

  • The following example retrieves the formatted binance_us_time and puts it into the message data then passes the message data, the secret, the URL, and the key into the function to execute a Binance.US API call

key <- "..."
secret <- "..."
time <- binance_us_time()
data <- paste('timestamp=', time, sep = '')
url <- 'https://api.binance.us/api/v3/account'
data <- binance_us_api_call(url, key, data, secret)

binance_us_account_info

  • Parameters: (url, key, data, secret)

  • key: your Binance.US API key

  • secret: your Binance.US secret key

  • Returns: a list containing information about your account

  • The following example passes the key and the secret into the function and stores the account information in a variable named "account_info"

key <- "..."
secret <- "..."
account_info <- binance_us_account_info(key, secret)

binance_us_recent_trades

  • Parameters: (symbol, limit)

  • symbol: the trading pair for which you wish to retrieve data

  • limit: the number of results to return. The maximum is 1,000.

  • Returns: a dataframe containing the most recent trades executed for the designated currency pair on Binance.US

  • The following example passes the symbol "LTCBTC" and the limit of "1000" into the function and stores the recent trades in a variable named "recent_trades"

symbol <- 'LTCBTC'
limit <- '1000'
recent_trades <- binance_us_recent_trades(symbol, limit)

binance_us_ping

  • Returns: a response from the Binance.US API server

  • The following example pings the Binance.US API server and stores the response in a variable named "ping".

ping <- binance_us_ping()

binance_us_server_time

  • Returns: the Binance.US server time

  • The following example gets the Binance.US server time and stores the response in a variable named "server_time".

server_time <- binance_us_server_time()

binance_us_system_status

  • Parameters: (key, secret)

  • key: your Binance.US API key

  • secret: your Binance.US secret key

  • Returns: the status of the Binance.US API. The response will either be a "0" for normal or a "1" for system maintenance.

  • The following example gets the Binance.US system status and stores the response in a variable named "system_status".

key <- "..."
secret <- "..."
system_status <- binance_us_system_status(key, secret)
Clone this wiki locally