A simple CLI that interacts with the Binance API
# download the code
git clone git@github.com:binance/binance-cli.git
cd binance-cli
npm install -g
# Display help command
binance-cli -h
# Set the API key and secret as global variables
# For SPOT
export BINANCE_API_KEY=<the_api_key>
export BINANCE_API_SECRET=<the_api_secret>
# For Futures
export BINANCE_FUTURES_API_KEY=<the_api_key>
export BINANCE_FUTURES_API_SECRET=<the_api_secret>
# It's possible to change the base URL to connect to testnet
# For SPOT
export SERVER=https://testnet.binance.vision
# For Futures
export FUTURES_SERVER=https://testnet.binancefuture.com
# then the command request will be sent to the testnet.
binance-cli t
binance-cli time
binance-cli i
# get BTCUSDT pair's filters. jq is required.
binance-cli i | jq '.symbols[] | select(.symbol == "BNBUSDT") |.filters'
# binance-cli book <symbol>
# binance-cli book -l <limit> <symbol>
binance-cli book bnbusdt
binance-cli book --limit 10 bnbusdt
# binance-cli trades <symbol>
binance-cli trades bnbusdt
binance-cli trades -l 10 bnbusdt
# binance-cli at <symbol>
binance-cli at bnbusdt
# get aggregate Trades List with parameters
# binance-cli at <symbol>
binance-cli at --limit 10 --startTime 1595937694913 --endTime 1595937794913 bnbusdt
# binance-cli k <symbol> <interval>
binance-cli k bnbusdt 1m
binance-cli k -l 1 bnbusdt 1m
# binance-cli ap <symbol>
binance-cli ap bnbusdt
# binance-cli ticker -s <symbol>
binance-cli ticker -s bnbusdt
binance-cli price
# or with a symbol
binance-cli price -s bnbusdt
# binance-cli bt
# binance-cli bt -s <symbol>
binance-cli bt -s bnbusdt
# binance-cli listen <stream> <stream> <listenKey>
binance-cli listen bnbusdt@depth bnbusdt@bookTicker
# place a limit buy order on BNBUSDT with price=350 and qty=0.05
binance-cli buy -s BNBUSDT -t LIMIT -q 0.05 -p 350 -f GTC
# place a limit sell order on BNBUSDT with price=500 and qty=0.03
binance-cli sell -s bnbusdt -t limit -q 0.03 -p 500 -f GTC
binance-cli get bnbusdt -i 12345
binance-cli get bnbusdt -c my_order_123
binance-cli cancel bnbusdt -i 12345
binance-cli cancel bnbusdt -c my_order_123
binance-cli cancel_all bnbusdt
binance-cli um_t
binance-cli um_time
binance-cli um_i
# get BTCUSDT pair's filters. jq is required.
binance-cli um_info | jq '.symbols[] | select(.symbol == "BNBUSDT") |.filters'
# binance-cli um_book <symbol>
# binance-cli um_book -l <limit> <symbol>
binance-cli um_book bnbusdt
binance-cli um_book --limit 10 bnbusdt
# binance-cli um_trades <symbol>
binance-cli um_trades bnbusdt
binance-cli um_trades -l 10 bnbusdt
# binance-cli um_at <symbol>
binance-cli um_at bnbusdt
# get aggregate Trades List with parameters
# binance-cli um_at <symbol>
binance-cli um_at --limit 10 --startTime 1595937694913 --endTime 1595937794913 bnbusdt
# binance-cli um_k <symbol> <interval>
binance-cli um_k bnbusdt 1m
binance-cli um_k -l 1 bnbusdt 1m
# binance-cli um_ticker -s <symbol>
binance-cli um_ticker -s bnbusdt
binance-cli um_price
# or with a symbol
binance-cli um_price -s bnbusdt
# binance-cli um_bt
# binance-cli um_bt -s <symbol>
binance-cli um_bt -s bnbusdt
# place a limit buy order on BNBUSDT with price=350 and qty=0.05
binance-cli um_buy -s BNBUSDT -t LIMIT -q 0.05 -p 350 -f GTC
# place a limit sell order on BNBUSDT with price=600 and qty=0.03
binance-cli um_sell -s bnbusdt -t limit -q 0.03 -p 600 -f GTC
binance-cli um_get bnbusdt -i 12345
binance-cli um_get bnbusdt -c my_order_123
binance-cli um_cancel bnbusdt -i 12345
binance-cli um_cancel bnbusdt -c my_order_123
binance-cli um_cancel_all bnbusdt
binance-cli cm_t
binance-cli cm_time
binance-cli cm_i
# get BTCUSDT pair's filters. jq is required.
binance-cli cm_info | jq '.symbols[] | select(.symbol == "BNBUSD_PERP") |.filters'
# binance-cli cm_book <symbol>
# binance-cli cm_book -l <limit> <symbol>
binance-cli cm_book BNBUSD_PERP
binance-cli cm_book --limit 10 BNBUSD_PERP
# binance-cli cm_t <symbol>
binance-cli cm_trades BNBUSD_PERP
binance-cli cm_trades -l 10 BNBUSD_PERP
# binance-cli cm_at <symbol>
binance-cli cm_at BNBUSD_PERP
# get aggregate Trades List with parameters
# binance-cli cm_at <symbol>
binance-cli cm_at --limit 10 --startTime 1701367424920 --endTime 1702037809993 BNBUSD_PERP
# binance-cli cm_k <symbol> <interval>
binance-cli cm_k BNBUSD_PERP 1m
binance-cli cm_k -l 1 BNBUSD_PERP 1m
# binance-cli cm_ticker -s <symbol>
binance-cli cm_ticker -s BNBUSD_PERP
binance-cli cm_price
# or with a symbol
binance-cli cm_price -s BNBUSD_PERP
# binance-cli cm_bt
# binance-cli cm_bt -s <symbol>
binance-cli cm_bt -s BNBUSD_PERP
# place a limit buy order on BNBUSDT with price=350 and qty=1
binance-cli cm_buy -s BNBUSD_PERP -t LIMIT -q 1 -p 350 -f GTC
# place a limit sell order on BNBUSDT with price=600 and qty=1
binance-cli cm_sell -s BNBUSD_PERP -t limit -q 1 -p 600 -f GTC
binance-cli cm_get BNBUSD_PERP -i 12345
binance-cli cm_get BNBUSD_PERP -c my_order_123
binance-cli cm_cancel BNBUSD_PERP -i 12345
binance-cli cm_cancel BNBUSD_PERP -c my_order_123
binance-cli cm_cancel_all BNBUSD_PERP
Use --help
to consult all the available commands
binance-cli --help
MIT