Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

CCXT Command-Line Interface (CLI)

npm Discord Supported Exchanges Follow CCXT at x.com

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.


🚀 Features

  • Interact with any exchange supported by CCXT
  • Call any CCXT method directly from the CLI
  • Send authenticated requests (using API keys)
  • Perform quick actions like fetching balances, trades, tickers, order books, and more
  • Plot interactive OHLCV charts
  • Render live ticker/orderbook updates from one or more exchanges

📦 Install

You can install the CLI globally with npm.

npm install -g ccxt-cli

Demo

ccxt-demo-new.mp4

🛠️ Usage

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

Parameters for calling a ccxt method

  • <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 parameters

Authentication

To use private methods (e.g., fetchBalance, createOrder), you must provide API credentials. The CLI supports credentials via environment variables or config files.

Environment variables:

export BINANCE_APIKEY=your_api_key
export BINANCE_SECRET=your_secret

Config files

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.


📈 Plot Interactive OHLCV Charts

You can generate and open interactive candlestick charts with volume in your browser using:

ccxt ohlcv binance BTC/USDT 1h
  • Uses fetchOHLCV from the exchange's REST API
  • Automatically generates a self-contained HTML file

🔍 Ideal for visualizing recent price action.

Result

OHLCV

📟 Live Ticker

You can stream live ticker updates (websockets) from one or more exchanges:

ccxt ticker binance BTC/USDT
ccxt ticker binance,bybit,okx BTC/USDT
Result

ticker

📊 Live OrderBook

Render a live orderbook (websockets) for one or more exchanges:

ccxt orderbook binance BTC/USDT
ccxt orderbook binance,bybit,okx BTC/USDT
Result

orderbook

Examples

Fetch OHLCV with limit and no since

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

Fetch your balance

ccxt kraken fetchBalance

Create a market order

ccxt binance createOrder BTC/USDT market buy 0.01

Fetch recent private trades

ccxt coinbasepro fetchMyTrades BTC/USD

Create order (with params)

ccxt binance createOrder "BTC/USDT" market buy 0.01 undefined --param test=true --param clientOrderId=myOrderId # undefined is the place holder for price

Fetch your swap/perps balance

ccxt binance fetchBalance --swap

Check required args

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".


📝 Tips

  • CLI supports automatic conversions from ISO8601 datetime to milliseconds, users can specify datetimes in command-line arguments in ISO8601 format in quotes like "2025-05-01T01:23:45Z" (where a method argument requires milliseconds)
  • Use --verbose flag to inspect raw request/response data.
  • Use --sandbox to place the request using the testnet/sandbox environment
  • Always test with small amounts when placing orders.
  • Use ccxt explain createOrder to view the required arguments for createOrder or any other method
  • Use --param keyA=valueA keyB=valueB ... to provide the params argument.
  • Arguments must follow the correct order. Use undefined to skip optional values

📚 Documentation


💡 Found a bug or have a feature in mind?

We’d love to hear from you! Open an issue or suggestion on GitHub and help us improve the CLI for everyone.


🛡 Disclaimer

Use this CLI at your own risk. Trading cryptocurrencies involves substantial risk. Always ensure your API keys are protected and never share them.


🧑‍💻 License

MIT — © [CCXT]