cli/README.md
The CCXT CLI is a lightweight command-line tool that enables you to interact directly with any supported cryptocurrency exchange using the CCXT library. It provides a convenient way to perform tasks such as checking balances, placing orders, and fetching market data — all from the terminal, with no need to write custom scripts.
You can install the CLI globally with npm.
npm install -g ccxt-cli
https://github.com/user-attachments/assets/09999217-07ee-4a0d-8bd9-715d4fe7f5a4
ccxt <exchange_id> <methodName> [...args] # if you're not sure about the args, use the `ccxt explain methodName` command
You can get a quick overview by using the --help flag:
ccxt --help
<exchange_id>: The ID of the exchange (e.g., binance, kraken, coinbasepro)<methodName>: Any method name available in the CCXT API (e.g., fetchBalance, createOrder, fetchTrades)args: Any required method parametersTo use private methods (e.g., fetchBalance, createOrder), you must provide API credentials. The CLI supports credentials via environment variables or config files.
export BINANCE_APIKEY=your_api_key
export BINANCE_SECRET=your_secret
Inside $CACHE/ccxt-cli/config.json you can add an object with the exchangeId as the key and apikeys/options inside.
{
"binance": {
"apiKey": "your apiKey here",
"secret": "your secret here",
"options": {
"customOptionKey": "customOptionValue"
}
}
}
$CACHE varies from OS to OS but by doing --help you can see which path is being used. You can also use the config command to set a different path for the config file.
You can generate and open interactive candlestick charts with volume in your browser using:
ccxt ohlcv binance BTC/USDT 1h
fetchOHLCV from the exchange's REST API🔍 Ideal for visualizing recent price action.
<details> <summary>Result</summary> </details>You can stream live ticker updates (websockets) from one or more exchanges:
ccxt ticker binance BTC/USDT
ccxt ticker binance,bybit,okx BTC/USDT
Render a live orderbook (websockets) for one or more exchanges:
ccxt orderbook binance BTC/USDT
ccxt orderbook binance,bybit,okx BTC/USDT
ccxt binance fetchOHLCV BTC/USDT 1h undefined 10 # we don't want to provide since but we want limit so undefined is provided as the placeholder for since
ccxt kraken fetchBalance
ccxt binance createOrder BTC/USDT market buy 0.01
ccxt coinbasepro fetchMyTrades BTC/USD
ccxt binance createOrder "BTC/USDT" market buy 0.01 undefined --param test=true --param clientOrderId=myOrderId # undefined is the place holder for price
ccxt binance fetchBalance --swap
If you are not sure which arguments should be provided you can always use the explain command.
ccxt explain createOrder
Result:
Method: createOrder
Usage:
binance createOrder <symbol> <type> <side> <amount> [price] [params]
Arguments:
- symbol (required) — Market symbol e.g., BTC/USDT
- type (required) — (no description available)
- side (required) — order side e.g., buy or sell
- amount (required) — (no description available)
- price (optional) — Price per unit of asset e.g., 26000.50
- params (optional) — Extra parameters for the exchange e.g., { "recvWindow": 5000 }
If you don't want to provide a value for an optional argument, you should still provide undefined as the "placeholder".
"2025-05-01T01:23:45Z" (where a method argument requires milliseconds)--verbose flag to inspect raw request/response data.--sandbox to place the request using the testnet/sandbox environmentccxt explain createOrder to view the required arguments for createOrder or any other method--param keyA=valueA keyB=valueB ... to provide the params argument.undefined to skip optional valuesWe’d love to hear from you! Open an issue or suggestion on GitHub and help us improve the CLI for everyone.
Use this CLI at your own risk. Trading cryptocurrencies involves substantial risk. Always ensure your API keys are protected and never share them.
MIT — © [CCXT]