binance-trader-cli
v1.0.3
Published
Binance API CLI — trade spot, futures, margin, algo from command line. Binance REST API for crypto trading, wallets, convert. 150+ commands.
Maintainers
Readme
binance-trader-cli — Binance API Command Line Tool
Binance CLI for the full Financial Trading REST API. Trade spot, futures, margin, wallet, algo from the command line. 150+ commands. No boilerplate.
One command to check prices, place orders, manage funds, trade futures. The Binance API command line tool you can use directly or via npx.
Install
npm install -g binance-trader-cliOr use with npx (no install):
npx binance-trader-cli spot ticker --symbol BTCUSDTConfiguration
| Variable | Description |
|----------|-------------|
| BINANCE_API_KEY | Your Binance API key |
| BINANCE_SECRET_KEY | Your Binance secret key |
| BINANCE_TESTNET | Set to 1 for testnet |
Or use global options: --apiKey, --secretKey, --testnet, --baseUrl, --futuresUrl.
Command Rules
Format
binance <module> <command> [options]- Module — One of:
spot,futures,margin,algo,wallet,copy-trading,convert,alpha,institutional-loan - Command — The API action (e.g.
ticker,order,balance,klines) - Options — All option names match the Binance API parameter names exactly:
--symbol,--side,--type,--quantity, etc.
Global Options
| Option | Description |
|--------|-------------|
| --apiKey | Override API key |
| --secretKey | Override secret key |
| --baseUrl | Spot/Margin/Wallet base URL (default: https://api.binance.com) |
| --futuresUrl | Futures base URL (default: https://fapi.binance.com) |
| --testnet | Use testnet |
Parameter Naming
CLI options use the exact Binance API parameter names in camelCase:
- API:
symbol→ CLI:--symbol - API:
timeInForce→ CLI:--timeInForce - API:
quoteOrderQty→ CLI:--quoteOrderQty
Refer to the Binance API docs for full parameter definitions.
Quick Start
# Market data (no API key)
binance spot ping
binance spot ticker --symbol BTCUSDT
binance spot klines --symbol BTCUSDT --interval 1h --limit 24
binance futures funding-rate --symbol BTCUSDT
# Trading (requires credentials)
export BINANCE_API_KEY="your-key"
export BINANCE_SECRET_KEY="your-secret"
binance spot account
binance spot order --symbol BTCUSDT --side BUY --type MARKET --quoteOrderQty 100
binance futures order --symbol BTCUSDT --side BUY --type MARKET --quantity 0.01Module Reference
spot — Spot Trading & Market Data
| Auth | Commands | API Docs | |------|----------|----------| | No | ticker, ticker-24hr, ticker-trading-day, klines, depth, trades, historical-trades, agg-trades, avg-price, book-ticker, exchange-info, ping, time | Spot Market Data | | Yes | order, test-order, cancel-order, cancel-all-orders, cancel-replace | Spot Trading | | Yes | get-order, open-orders, all-orders, my-trades, my-allocations, my-prevented-matches, rate-limit-order | Spot Order Management | | Yes | account, commission | Spot Account |
Examples:
binance spot ticker --symbol BTCUSDT
binance spot klines --symbol BTCUSDT --interval 1h --limit 24
binance spot order --symbol BTCUSDT --side BUY --type LIMIT --timeInForce GTC --quantity 0.001 --price 60000
binance spot account --omitZeroBalancesKey parameters: symbol, side (BUY/SELL), type (LIMIT/MARKET/STOP_LOSS/STOP_LOSS_LIMIT/TAKE_PROFIT/TAKE_PROFIT_LIMIT/LIMIT_MAKER), timeInForce (GTC/IOC/FOK), quantity, quoteOrderQty, price, stopPrice, interval (1s,1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M)
futures — USDS-M Futures
| Auth | Commands | API Docs | |------|----------|----------| | No | ticker, ticker-24hr, klines, depth, historical-trades, agg-trades, premium-index, funding-rate, funding-info, open-interest, index-info, book-ticker, exchange-info | Futures Market Data | | Yes | order, batch-orders, cancel-order, cancel-all-orders, cancel-batch-orders, countdown-cancel-all | Futures Trading | | Yes | get-order, open-orders, all-orders, user-trades, force-orders | Futures Order Management | | Yes | balance, account, position-risk, income, adl-quantile | Futures Account | | Yes | leverage, margin-type, position-margin, position-margin-history, leverage-bracket, commission-rate | Futures Leverage & Margin | | Yes | position-side-dual, set-position-side, multi-assets-margin, set-multi-assets-margin | Futures Position Mode |
Examples:
binance futures leverage --symbol BTCUSDT --leverage 10
binance futures order --symbol BTCUSDT --side BUY --type MARKET --quantity 0.01
binance futures order --symbol BTCUSDT --side SELL --type STOP_MARKET --stopPrice 58000 --closePosition true
binance futures position-risk --symbol BTCUSDTKey parameters: symbol, side, type (LIMIT/MARKET/STOP_MARKET/TAKE_PROFIT_MARKET/TRAILING_STOP_MARKET), positionSide (BOTH/LONG/SHORT), leverage, marginType (ISOLATED/CROSSED), closePosition, callbackRate
margin — Margin Trading
| Auth | Commands | API Docs | |------|----------|----------| | Yes | order, cancel-order, cancel-all-orders, get-order, open-orders, all-orders, my-trades | Margin Trading | | Yes | borrow-repay, borrow-repay-records | Margin Borrow | | Yes | account, isolated-account, max-borrowable, max-transferable, interest-history | Margin Account | | Yes | interest-rate-history, force-liquidation | Margin Reference | | No | all-assets, all-pairs, isolated-all-pairs, cross-margin-data, isolated-margin-data, isolated-margin-tier | Margin Reference | | Yes | small-liability, small-liability-exchange, small-liability-history | Margin Small Liability |
Examples:
binance margin borrow-repay --asset USDT --isIsolated FALSE --symbol BTCUSDT --amount 1000 --type BORROW
binance margin order --symbol BTCUSDT --side BUY --type MARKET --quantity 0.001 --isIsolated TRUE --sideEffectType AUTO_BORROW_REPAY
binance margin accountKey parameters: symbol, isIsolated (TRUE/FALSE), sideEffectType (NO_SIDE_EFFECT/MARGIN_BUY/AUTO_REPAY/AUTO_BORROW_REPAY), asset, type (BORROW/REPAY)
algo — Algorithmic Trading (TWAP / VP)
| Auth | Commands | API Docs | |------|----------|----------| | Yes | futures-twap, futures-vp, futures-cancel, futures-open-orders, futures-historical-orders, futures-sub-orders | Algo Futures | | Yes | spot-twap, spot-cancel, spot-open-orders, spot-historical-orders, spot-sub-orders | Algo Spot |
Examples:
binance algo futures-twap --symbol BTCUSDT --side BUY --quantity 1 --duration 300
binance algo futures-vp --symbol BTCUSDT --side BUY --quantity 1 --urgency LOW
binance algo spot-twap --symbol BTCUSDT --side BUY --quantity 0.1 --duration 300Key parameters: symbol, side, quantity, duration (seconds), urgency (LOW/MEDIUM/HIGH), limitPrice, positionSide, algoId
wallet — Wallet & Asset Management
| Auth | Commands | API Docs | |------|----------|----------| | Yes | balance, user-asset, funding-asset, asset-detail | Wallet Balances | | Yes | deposit-address, deposit-address-list, deposit-history | Wallet Deposits | | Yes | withdraw, withdraw-history, withdraw-quota | Wallet Withdrawals | | Yes | transfer, transfer-history | Wallet Transfers | | Yes | dust-btc, dust, dust-log | Dust Conversion | | Yes | all-coins, trade-fee, account-snapshot, account-info, api-restrictions, system-status, delist-schedule | Wallet Info |
Examples:
binance wallet balance
binance wallet transfer --type MAIN_UMFUTURE --asset USDT --amount 1000
binance wallet withdraw --coin USDT --address ADDR --amount 100 --network TRXTransfer types: MAIN_UMFUTURE, UMFUTURE_MAIN, MAIN_FUNDING, FUNDING_MAIN, MAIN_MARGIN, MARGIN_MAIN
copy-trading — Copy Trading
| Auth | Commands | API Docs | |------|----------|----------| | Yes | lead-symbol, user-status | Copy Trading |
Examples:
binance copy-trading lead-symbol
binance copy-trading user-statusconvert — Flash Swap / Token Conversion
| Auth | Commands | API Docs | |------|----------|----------| | Yes | exchange-info, asset-info | Convert Info | | Yes | get-quote, accept-quote, order-status | Convert Instant | | Yes | limit-order, cancel-limit, open-limit-orders, trade-flow | Convert Limit |
Examples:
binance convert get-quote --fromAsset USDT --toAsset BTC --fromAmount 100
binance convert accept-quote --quoteId QUOTE_ID
binance convert limit-order --baseAsset BTC --quoteAsset USDT --limitPrice 60000 --side BUY --baseAmount 0.001 --expiredType 7_DKey parameters: fromAsset, toAsset, fromAmount, toAmount, quoteId, expiredType (1_D, 3_D, 7_D, 30_D)
alpha — Alpha Token Trading
| Auth | Commands | API Docs | |------|----------|----------| | No | exchange-info, ticker, klines | Alpha Market | | Yes | order, get-order, all-orders, account | Alpha Trading |
Examples:
binance alpha ticker --symbol TOKENUSDT
binance alpha order --symbol TOKENUSDT --side BUY --type MARKET --quoteOrderQty 100institutional-loan — Institutional Loans
| Auth | Commands | API Docs | |------|----------|----------| | Yes | margin-data, ongoing-orders, repay, adjust-ltv | Institutional Loan | | Yes | repay-history, ltv-history, borrow-history | Institutional Loan History |
Examples:
binance institutional-loan ongoing-orders
binance institutional-loan repay --orderId 123456 --amount 1000
binance institutional-loan adjust-ltv --orderId 123456 --amount 0.1 --direction ADDITIONALKey parameters: orderId, loanCoin, collateralCoin, amount, direction (ADDITIONAL/REDUCED)
Response Format
All responses are JSON. Error responses include code and msg fields. See Binance Error Codes.
FAQ
How do I trade on Binance from the command line?
Install: npm install -g binance-trader-cli. Set BINANCE_API_KEY and BINANCE_SECRET_KEY in .env or environment. Run binance spot order, binance futures order, etc.
Is there a Binance API CLI?
Yes. This package (binance-trader-cli) is a full Binance REST API CLI for spot, futures, margin, wallet, algo, convert, copy trading, and institutional loan.
Does it work without API keys?
Market data endpoints (ticker, klines, depth, funding-rate) work without authentication. Trading and account endpoints require API credentials.
Can I use npx without installing?
Yes: npx binance-trader-cli spot ticker --symbol BTCUSDT
Where is the Binance API documentation?
developers.binance.com. All CLI option names match the official API parameters.
Links
| Resource | URL | |----------|-----| | Binance API (Spot) | https://developers.binance.com/docs/binance-spot-api-docs | | Binance API (Futures) | https://developers.binance.com/docs/derivatives/usds-margined-futures | | Binance API (Margin) | https://developers.binance.com/docs/margin_trading | | Binance API (Wallet) | https://developers.binance.com/docs/wallet | | Binance API (Convert) | https://developers.binance.com/docs/convert | | Binance API (Algo) | https://developers.binance.com/docs/algo | | Binance API (Copy Trading) | https://developers.binance.com/docs/copy_trading | | Binance API (Alpha) | https://developers.binance.com/docs/alpha | | Binance API (Institutional Loan) | https://developers.binance.com/docs/institutional_loan | | Apply for API Key | https://www.binance.com/en/my/settings/api-management | | Testnet | https://testnet.binance.vision/ | | GitHub | https://github.com/open-crab-ai/binance-plugin |
License
Apache-2.0
