A simple CLI that interacts with the Binance API
# Install from npm
npm install -g @binance/binance-cliUse --help to consult all the available commands
binance-cli --help--help is supported for each product and each command.
# Display help command
binance-cli -h
# Set the API key and secret as global variables
export BINANCE_API_KEY=<the_api_key>
export BINANCE_SECRET_KEY=<the_api_secret> # Can be secret key, path to private key or content of private key
# Set the environment (prod by default, valid options: prod, demo and testnet)
export BINANCE_API_ENV=testnet
# It is possible to have a custom base URL
export BINANCE_SPOT_BASE_PATH=https://testnet.binance.vision
export BINANCE_FUTURES_USDS_BASE_PATH=https://testnet.binancefuture.combinance-cli profile create --name new-name --api-key <the_api_key> --api-secret <the_api_secret> --env prodbinance-cli profile change --name new-namebinance-cli profile viewIt is also possible to specify the profile for a single command.
binance-cli spot get-account --profile my_profilebinance-cli profile create -i # binance-cli will prompt the questions to create a new profilebinance-cli profile change -i # select the profile to activatebinance-cli profile view-
Convert - Convert connector
-
Spot - Spot Trading connector
-
Derivatives Trading (USDS-M Futures) - Derivatives Trading (USDS-M Futures) connector
binance-cli spot klines --symbol "BNBUSDT" --interval "1s"echo '{"symbol": "BNBUSDT", "interval": "1s"}' | binance-cli spot klinesbinance-cli spot klines -iIn order to add completion, the following steps can be followed:
Append the output to the .bashrc file:
binance-cli completion >> ~/.bashrcAppend the output to the .zshrc file:
binance-cli completion >> ~/.zshrcAfter updating the file, the terminal needs to be restarted or activate the completion with source ~/.bashrc (or .zshrc).
Custom request can also be sent using binance-cli, any parameter can be added to the command and will be sent in the request.
binance-cli request GET https://api.binance.com/api/v3/trades --symbol BNBUSDT --limit 5Signed endpoints are also supported.
binance-cli request GET https://testnet.binance.vision/api/v3/account --signedMIT

