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 <prod|demo|testnet>binance-cli profile select --name new-namebinance-cli profile viewbinance-cli profile listThe active profile will be shown with an asterisk.
binance-cli profile delete --name profile-nameIt 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 profileIt can also be used to update an existing profile.
binance-cli profile select -i # select the profile to activatebinance-cli profile view- Algo Trading
- Alpha
- C2C
- Convert
- Copy Trading
- Crypto Loan
- Derivatives Trading (COIN-M Futures)
- Derivatives Trading (Options)
- Derivatives Trading (Portfolio Margin)
- Derivatives Trading (Portfolio Margin Pro)
- Derivatives Trading (USDS-M Futures)
- Dual Investment
- Fiat
- Gift Card
- Margin Trading
- Mining
- Pay
- Rebate
- Simple Earn
- Spot Trading
- Staking
- Sub Account
- VIP Loan
- Wallet
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

