whitebit-cli
v1.0.8
Published
WhiteBIT Exchange CLI — Trade, manage accounts, and query market data from the terminal
Downloads
179
Maintainers
Readme
WhiteBIT CLI
WhiteBIT Exchange CLI — trade, manage accounts, and query market data directly from your terminal. Built for scripting, CI/CD pipelines, and anyone who prefers the command line over a browser UI.
Features
| | |
|---|---|
| 110+ commands | Full WhiteBIT API surface: spot, collateral, earn, sub-accounts, deposits, withdrawals |
| Multi-profile | Named profiles in ~/.whitebit/config.toml — switch between different API keys with --profile |
| --dry-run mode | Preview the exact request payload before it hits the API |
| JSON output | --json flag on every command — pipe directly into jq or any automation tool |
| Shell completion | Tab-completion for Bash, Zsh, and Fish |
| Rate-limit aware | Built-in token-bucket limiter per API category — no accidental bursts |
| Cross-platform | macOS (ARM + x64), Linux, and Windows binaries |
Installation
Homebrew (macOS/Linux)
brew install whitebit-exchange/tap/whitebitNPM/Bunx
# Run directly with bunx (recommended)
bunx whitebit-cli market list
# Or install globally with npm
npm install -g whitebit-cli
# Or run with npx
npx whitebit-cli market listQuick Start
# 1. Set credentials (required for account and trading commands)
export WHITEBIT_API_KEY="your-key"
export WHITEBIT_API_SECRET="your-secret"
# 2. Verify setup — no auth needed
whitebit market list
# 3. Check your balance
whitebit balance trade
# 4. Place a limit order
whitebit trade spot limit-order BTC_USDT buy 0.001 50000Public market data commands work without credentials. See Authentication for all credential options.
Running from source? Replace
whitebitwithbun src/cli.tsin all commands.
Authentication
Credentials are resolved in priority order (highest first):
| Method | Best For | Persistence | Security |
|--------|----------|-------------|----------|
| CLI flags (--api-key, --api-secret) | Quick testing, scripts | None | Visible in process list ⚠️ |
| Environment variables | CI/CD, Docker, one-off scripts | Per-session | Depends on environment |
| Config file (~/.whitebit/config.toml) | Daily use, multiple profiles | Permanent | 0600 permissions recommended |
Config file
Create ~/.whitebit/config.toml with one or more named profiles:
[default]
api_key = "your-api-key"
api_secret = "your-api-secret"
format = "table" # or "json"
[work]
api_key = "work-api-key"
api_secret = "work-api-secret"Switch profiles with --profile:
whitebit balance trade --profile workCommands
| Module | Commands | Auth | Description |
|--------|:--------:|:----:|-------------|
| market | 14 | No | Tickers, order book, trades, klines, funding rates, platform status |
| mining-pool | 2 | No | Pool statistics and hashrate |
| balance | 3 | Yes | Spot, main, and personal fee balances |
| deposit | 4 | Yes | Crypto and fiat deposit addresses |
| withdraw | 4 | Yes | Crypto and fiat withdrawals + history |
| transfer | 1 | Yes | Transfer between main / spot / collateral accounts |
| codes | 4 | Yes | Create, apply, and list redemption codes |
| earn | 13 | Yes | Fixed and flexible staking, interest history |
| trade spot | 18 | Yes | Limit, market, stop, bulk orders; cancel, modify, kill-switch |
| trade collateral | 22 | Yes | Margin: leverage, positions, OCO, OTO, conditional orders |
| trade convert | 3 | Yes | Estimate and execute asset conversions |
| sub-account | 17 | Yes | Sub-account management, API keys, IP whitelists |
Market Data (Public)
Query real-time market data without authentication.
market server-time— Server timestampmarket status— Platform operational statusmarket list— All available trading pairsmarket market-status— Market status listmarket asset-status <asset>— Asset deposit/withdrawal statusmarket futures-markets— Futures trading pairsmarket collateral-markets— Collateral marketsmarket tickers— All market tickersmarket depth <pair>— Order book depthmarket trades <pair>— Recent trades historymarket kline <pair> <interval>— Candlestick datamarket fee— Trading fee schedulemarket funding-history <pair>— Futures funding rate historymarket activity <pair>— 24h trading activity
Mining Pool
Mining pool statistics and hashrate.
mining-pool overview— Mining pool statisticsmining-pool hashrate— Mining hashrate
Balance (Requires Auth)
View account balances and fees.
balance main— Main account balancebalance trade [asset]— Spot/trading balancebalance fee— Personal trading fee rates
Deposit (Requires Auth)
Manage deposit addresses and requests.
deposit address <asset> <network>— Get deposit addressdeposit fiat-address <provider> <currency>— Fiat deposit addressdeposit create-address <asset> <network>— Create new deposit addressdeposit refund <hash>— Request deposit refund
Withdraw (Requires Auth)
Manage withdrawals and view history.
withdraw crypto <asset> <amount> <address>— Withdraw cryptowithdraw crypto-amount <asset> <address> <amount>— Withdraw crypto where recipient gets exact amount (fee added on top)withdraw fiat <currency> <amount> <provider>— Withdraw fiatwithdraw history— Withdrawal history
Transfer (Requires Auth)
Internal account transfers.
transfer internal <asset> <amount> <from> <to>— Transfer between accounts (valid accounts:main,spot,collateral)
Codes (Requires Auth)
Manage redemption codes.
codes create <asset> <amount>— Create redemption codecodes apply <code>— Redeem codecodes history— Redemption history (codes you have applied)codes list— Active codes
Earn (Requires Auth)
Staking and yield products.
Fixed Staking (earn fixed <command>)
earn fixed plans— Fixed staking plansearn fixed invest <plan_id> <amount>— Create fixed stakingearn fixed investments-history— Staking historyearn fixed close-investment <id>— Close staking early
Flexible Staking (earn flex <command>)
earn flex plans— Flexible staking plansearn flex invest <plan_id> <amount>— Flexible staking investearn flex investments— Active flexible stakingsearn flex investment-history— Flexible staking historyearn flex payment-history— Flexible payment historyearn flex withdraw <id> <amount>— Withdraw from flexibleearn flex close <id>— Close flexible stakingearn flex auto-reinvest <id> <enabled>— Toggle auto-reinvest
Interest History
earn interest-history— Interest payment history
Account Data (Requires Auth)
Account and credit information.
credit-lines— Credit linesws-token— WebSocket auth token
Trading (Requires Auth)
Place, modify, and cancel orders across spot, collateral, and convert markets.
Spot Trading (trade spot <command>)
trade spot limit-order <pair> <side> <amount> <price>— Create a limit ordertrade spot market-order <pair> <side> <amount>— Create a market ordertrade spot bulk-order <pair> --orders '<json>'— Create multiple orders in bulktrade spot stop-limit <pair> <side> <amount> <price> <activation_price>— Create a stop-limit ordertrade spot stop-market <pair> <side> <amount> <activation_price>— Create a stop-market ordertrade spot buy-stock <pair> <amount>— Create a buy stock market order (buy for fixed money amount)trade spot cancel <pair> <order_id>— Cancel a specific ordertrade spot cancel-all— Cancel all orders (optionally filtered by market)trade spot modify <pair> <order_id>— Modify an existing ordertrade spot executed— List executed orderstrade spot unexecuted— List unexecuted (open) orderstrade spot deals <order_id>— Get executed deals for a specific ordertrade spot history— Get trades historytrade spot balance— Get trade balance for all assetstrade spot fee <pair>— Get trading fee for a specific markettrade spot all-fees— Get trading fees for all marketstrade spot kill-switch-status— Get kill switch statustrade spot kill-switch-sync <pair> <timeout>— Sync kill switch timer
Collateral Trading (trade collateral <command>)
trade collateral balance— Fetch collateral account balancetrade collateral summary— Fetch collateral account summarytrade collateral balance-summary— Fetch collateral account balance summary with detailed asset breakdowntrade collateral hedge-mode— Get collateral account hedge mode statustrade collateral set-hedge-mode <enabled>— Update collateral account hedge modetrade collateral limit-order <pair> <side> <amount> <price>— Create a collateral limit ordertrade collateral market-order <pair> <side> <amount>— Create a collateral market ordertrade collateral bulk-order <pair> --orders '<json>'— Create multiple collateral limit orderstrade collateral stop-limit <pair> <side> <amount> <price> <activation_price>— Create a collateral stop-limit ordertrade collateral trigger-market <pair> <side> <amount> <activation_price>— Create a collateral trigger market ordertrade collateral set-leverage <pair> <leverage>— Set leverage for a collateral markettrade collateral close-position <pair>— Close a collateral positiontrade collateral open-positions— Get all open collateral positionstrade collateral position-history— Get collateral positions historytrade collateral funding-history— Get collateral funding historytrade collateral conditional-orders— Get unexecuted conditional orderstrade collateral cancel-conditional <pair> <order_id>— Cancel a conditional ordertrade collateral oco-orders— Get unexecuted OCO orderstrade collateral create-oco <pair> <side> <amount> <price> <stop_price>— Create an OCO (One-Cancels-Other) ordertrade collateral create-oto <pair> <side> <amount> <price> <trigger_price>— Create an OTO (One-Triggers-Other) ordertrade collateral cancel-oco <pair> <order_id>— Cancel an OCO ordertrade collateral cancel-oto <pair> <order_id>— Cancel an OTO order
Convert (trade convert <command>)
trade convert estimate <from> <to> <amount>— Estimate conversion rate and amounttrade convert confirm <estimate_id>— Confirm and execute a conversiontrade convert history— Get conversion history
Sub-Accounts (Requires Auth)
Manage sub-accounts and transfers.
sub-account list— List all sub-accountssub-account create <alias>— Create sub-accountsub-account balance <id>— Sub-account balancesub-account transfer <asset> <amount> [--fromId <id>] [--toId <id>]— Transfer funds to/from sub-accountsub-account transfer-history <sub_account_id>— Sub-account transfer historysub-account edit <id> <alias>— Edit sub-account detailssub-account delete <id>— Delete a sub-accountsub-account block <id>— Block a sub-accountsub-account unblock <id>— Unblock a sub-accountsub-account api-key-list <sub_account_id>— List all sub-account API keyssub-account api-key-create <sub_account_id> <label> <permissions>— Create API key for sub-accountsub-account api-key-edit <sub_account_id> <api_key_id>— Edit sub-account API keysub-account api-key-reset <sub_account_id> <api_key_id>— Reset sub-account API keysub-account api-key-delete <sub_account_id> <api_key_id>— Delete sub-account API keysub-account ip-list <sub_account_id> <api_key_id>— List IP addresses for API keysub-account ip-add <sub_account_id> <api_key_id> <ip>— Add IP address to API key whitelistsub-account ip-delete <sub_account_id> <api_key_id> <ip>— Remove IP address from API key whitelist
Configuration
Manage CLI settings and profiles.
config show— Show resolved configuration valuesconfig set --api-key <key> --api-secret <secret>— Store API credentials
General Commands
help— Show top-level CLI help and exampleslogin— Login and save API credentials (interactive or with flags)completion --shell <bash|zsh|fish>— Generate shell completion script
Shell Completion
Generate and activate tab-completion for your shell:
# Bash — add to ~/.bashrc for permanent activation
source <(whitebit completion --shell bash)
# or append to completion file:
whitebit completion --shell bash >> ~/.bash_completion
# Zsh — save to a directory in $fpath
mkdir -p ~/.zfunc
whitebit completion --shell zsh > ~/.zfunc/_whitebit
# Add to ~/.zshrc if not already present:
# fpath=(~/.zfunc $fpath) && autoload -Uz compinit && compinit
# Fish — drop into completions directory
whitebit completion --shell fish > ~/.config/fish/completions/whitebit.fishGlobal Options
Available for all commands:
--profile <name>— Use specific config profile (default:default)--api-key <key>— Override API key--api-secret <secret>— Override API secret--api-url <url>— Override API URL--format <table|json>— Output format--json— Shortcut for--format json--verbose,-V— Verbose output (show raw API responses)--dry-run— Show what would be sent without executing
Output Formats
Table (Default)
Human-readable table output:
whitebit market list --format tableJSON
Machine-readable JSON output:
whitebit market list --format json
# or
whitebit market list --jsonUse with jq for filtering:
whitebit market list --json | jq '.[] | select(.name | contains("BTC"))'Scripting & Automation
# Preview a large order before submitting — inspect the request payload
whitebit trade spot limit-order BTC_USDT buy 1.0 50000 --dry-run
# Monitor open orders, refreshing every 5 seconds
watch -n 5 'whitebit trade spot unexecuted --json | jq'
# Use in a CI script — fail the job if the balance check returns an error
whitebit balance trade --json
if [ $? -ne 0 ]; then echo "Balance check failed (exit $?)"; exit 1; fi
# Filter tickers to BTC pairs only
whitebit market tickers --json | jq '[.[] | select(.name | contains("BTC"))]'
# Use a dedicated profile for CI pipelines
whitebit trade spot limit-order BTC_USDT buy 0.001 50000 --profile ci --dry-runExit Codes
| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | General error |
| 2 | Authentication / credential error |
| 3 | Network error |
| 4 | Usage / bad arguments |
| 5 | Rate limit (HTTP 429) |
Useful for conditional shell logic:
whitebit balance trade && echo "OK" || echo "Failed with exit $?"Security Best Practices
- Never commit credentials to version control
- Use environment variables for CI/CD pipelines
- Set restrictive permissions on config file:
chmod 600 ~/.whitebit/config.toml - Use API key restrictions in WhiteBIT dashboard (IP whitelist, read-only keys)
- Avoid
--api-keyflags in production scripts (visible in process list)
Reporting Issues
Open an issue at GitHub Issues and include:
- The exact command you ran
- The full error output from stderr
- Output of
whitebit --version
For API errors, re-run with --verbose to capture the full request and response, and include that output in the issue.
Development
Dependencies
The following tools must be installed before working with this project:
- Bun ≥ 1.0 — runtime, package manager, test runner, and bundler. Install via:
curl -fsSL https://bun.sh/install | bash - Node.js ≥ 18 — required only if using
npm/npxinstead of Bun directly. - Git — to clone the repository.
Setup
# Clone repository
git clone https://github.com/whitebit-exchange/whitebit-cli
cd cli
# Install dependencies
bun install
# Run locally
bun src/cli.ts market list
# Build binaries
bun run build
# Run tests
bun testLicense
Apache 2.0 — See LICENSE for details.
Resources
| | | |---|---| | WhiteBIT API Documentation | Official API reference | | API Platform Overview | REST, WebSocket, authentication, rate limits | | Use with AI | Use API docs with Claude, Cursor, VS Code via MCP | | GitHub Repository | Source code | | Releases | Binaries and changelog | | Contributing | Development setup and contribution guide | | Security | Vulnerability reporting and security practices | | Report an Issue | Bug reports and feature requests | | WhiteBIT Exchange | The exchange |
