A Rust port of the popular CCXT cryptocurrency exchange trading library.
- 100+ Exchanges - CEX (Binance, Bybit, OKX, ...) and DEX (Hyperliquid, dYdX, Paradex, ...)
- Unified API - Consistent interface across all exchanges
- REST & WebSocket - Full support for both protocols
- Async/Await - Built on Tokio for high-performance operations
- Type Safety - Strongly typed with Rust's type system
| Type | Exchanges |
|---|---|
| CEX | Binance, Bybit, OKX, Kraken, KuCoin, Coinbase, Gate.io, Bitget, MEXC, HTX, Upbit, Bithumb, +90 more |
| DEX | Hyperliquid, dYdX v4, Paradex, Apex, Defx, Derive, WavesExchange |
See docs/exchanges.md for the full list.
[dependencies]
ccxt-rust = "0.1"tokio = { version = "1.0", features = ["full"] }| Feature | Default | Description |
|---|---|---|
cex | ✅ | Centralized exchange support (Binance, OKX, etc.) |
dex | ❌ | Decentralized exchange support (Hyperliquid, dYdX, Paradex) + crypto primitives |
native | ✅ | Native Rust build with tokio runtime |
wasm | ❌ | WebAssembly build for browser environments |
full | ❌ | All features enabled (native) |
# CEX only (default, smaller binary)ccxt-rust = "0.1"# DEX support (includes EVM, StarkNet, Cosmos crypto)ccxt-rust = { version = "0.1", features = ["dex"] }
# All featuresccxt-rust = { version = "0.1", features = ["full"] }
# DEX only (no CEX)ccxt-rust = { version = "0.1", default-features = false, features = ["dex"] }ccxt-rust can be compiled to WebAssembly for use in browsers.
# Install wasm-pack
cargo install wasm-pack
# Build for web
wasm-pack build --target web --no-default-features --features "wasm,cex"<scripttype="module">importinit,{WasmBinance,WasmUpbit,version}from'./pkg/ccxt_rust.js';asyncfunctionmain(){awaitinit();console.log('ccxt-rust version:',version());// Create exchange instanceconstbinance=newWasmBinance();// Fetch tickerconstticker=awaitbinance.fetchTicker('BTC/USDT');console.log('BTC/USDT:',ticker.last);// Fetch order bookconstorderbook=awaitbinance.fetchOrderBook('BTC/USDT',10);console.log('Bids:',orderbook.getBids());console.log('Asks:',orderbook.getAsks());}main();</script>| Exchange | REST Class | WebSocket Class | REST Methods | WS Methods |
|---|---|---|---|---|
| Binance | WasmBinance | WasmBinanceWs | fetchTicker, fetchOrderBook, fetchMarkets, fetchTickers, fetchTrades, fetchOhlcv | watchTicker, watchOrderBook, watchTrades |
| Upbit | WasmUpbit | WasmUpbitWs | fetchTicker, fetchOrderBook, fetchMarkets, fetchTickers, fetchTrades, fetchOhlcv | watchTicker, watchOrderBook |
| Bybit | WasmBybit | WasmBybitWs | fetchTicker, fetchOrderBook, fetchMarkets, fetchTickers, fetchTrades, fetchOhlcv | watchTicker, watchOrderBook |
| OKX | WasmOkx | - | fetchTicker, fetchOrderBook, fetchMarkets, fetchTickers, fetchTrades, fetchOhlcv | - |
| Kraken | WasmKraken | - | fetchTicker, fetchOrderBook, fetchMarkets, fetchTickers, fetchTrades, fetchOhlcv | - |
import{WasmBinanceWs}from'./pkg/ccxt_rust.js';// Create WebSocket clientconstws=newWasmBinanceWs();// Watch ticker with callbackws.watchTicker('BTC/USDT',(msg)=>{if(msg.message_type==='ticker'){constdata=JSON.parse(msg.data);console.log('BTC/USDT:',data.c);// Last price}elseif(msg.message_type==='connected'){console.log('WebSocket connected');}});import{hmacSha256,// HMAC-SHA256 signinghmacSha512,// HMAC-SHA512 signingsha256,// SHA256 hashsha512,// SHA512 hashbase64Encode,// Base64 encodebase64Decode,// Base64 decodeurlEncode,// URL encodegenerateUuid,// Generate UUID v4getCurrentTimestamp,// Current timestamp (ms)getSupportedExchanges// List of supported exchanges}from'./pkg/ccxt_rust.js';Note: WASM builds have some limitations compared to native builds:
- No private trading APIs (for security reasons)
- Subject to CORS restrictions (may need a proxy server)
use ccxt_rust::exchanges::Binance;use ccxt_rust::types::Exchange;use ccxt_rust::ExchangeConfig;#[tokio::main]asyncfnmain() -> Result<(),Box<dyn std::error::Error>>{let exchange = Binance::new(ExchangeConfig::default())?;// Fetch tickerlet ticker = exchange.fetch_ticker("BTC/USDT").await?;println!("BTC/USDT: {:?}", ticker.last);// Fetch order booklet orderbook = exchange.fetch_order_book("BTC/USDT",Some(5)).await?;println!("Best bid: {}, Best ask: {}",
orderbook.bids[0].price,
orderbook.asks[0].price
);Ok(())}See examples/ for more examples including WebSocket and trading.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.