A simple CLI that interacts with the Binance API
- If global npm package
@binance/binance-cliexists andbinance-cli --versionis< 2.0.0, uninstall it:
npm uninstall -g @binance/binance-cli
- Install the latest release:
curl --proto '=https' --tlsv1.2 -LsSf \ https://github.com/binance/binance-cli/releases/latest/download/binance-cli-installer.sh \ | sh
- Verify:
binance-cli --version
Use --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.com
binance-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-name
binance-cli profile view
binance-cli profile list
The active profile will be shown with an asterisk.
binance-cli profile delete --name profile-name
It is also possible to specify the profile for a single command.
binance-cli spot get-account --profile my_profile
binance-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 activate
binance-cli profile view
- Algo Trading: Rest API
- Alpha: Rest API - WebSocket Streams
- C2C: Rest API
- CMS: WebSocket Streams
- Convert: Rest API
- Copy Trading: Rest API
- Crypto Loan: Rest API
- Derivatives Trading (COIN-M Futures): Rest API - WebSocket Streams
- Derivatives Trading (Options): Rest API - WebSocket Streams
- Derivatives Trading (Portfolio Margin): Rest API - WebSocket Streams
- Derivatives Trading (Portfolio Margin Pro): Rest API - WebSocket Streams
- Derivatives Trading (USDS-M Futures): Rest API - WebSocket Streams
- Dual Investment: Rest API
- Fiat: Rest API
- Gift Card: Rest API
- Margin Trading: Rest API
- Mining: Rest API
- Pay: Rest API
- Rebate: Rest API
- Simple Earn: Rest API
- Spot Trading: Rest API - WebSocket Streams
- Stocks: Rest API - WebSocket Streams
- Staking: Rest API
- Sub Account: Rest API
- VIP Loan: Rest API
- Web3 Prediction: Rest API - WebSocket Streams
- Wallet: Rest API
binance-cli spot klines --symbol "BNBUSDT" --interval "1s"
echo '{"symbol": "BNBUSDT", "interval": "1s"}' | binance-cli spot klines
binance-cli spot klines -i
In order to add completion, the following steps can be followed:
Append the output to the .bashrc file:
binance-cli completion bash >> ~/.bashrc
Append the output to the .zshrc file:
binance-cli completion zsh >> ~/.zshrc
After 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 5
Signed endpoints are also supported.
binance-cli request GET https://testnet.binance.vision/api/v3/account --signed
MIT

