# Quick Start Guide
Get started with ccxt-rust in under 5 minutes. This guide will help you fetch your first market data from a cryptocurrency exchange.
## Prerequisites
- Rust 1.91+ installed
- Basic understanding of cryptocurrency trading concepts
## Installation
Add ccxt-rust to your `Cargo.toml`:
```toml
[dependencies]
ccxt-core = { path = "ccxt-core" }
ccxt-exchanges = { path = "ccxt-exchanges" }
tokio = { version = "1.35", features = ["full"] }
rust_decimal = "1.39"
```
## Your First API Call
### Example 1: Fetch Market Data (No API Key Required)
```rust
use ccxt_exchanges::binance::Binance;
use ccxt_core::exchange::Exchange;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create exchange instance (no credentials needed for public data)
let exchange = Binance::builder()
.build()?;
// Fetch ticker for BTC/USDT
let ticker = exchange.fetch_ticker("BTC/USDT").await?;
println!("BTC/USDT Ticker:");
println!(" Last Price: {:?}", ticker.last);
println!(" 24h Volume: {:?}", ticker.base_volume);
println!(" 24h High: {:?}", ticker.high);
println!(" 24h Low: {:?}", ticker.low);
Ok(())
}
```
### Example 2: Fetch Order Book
```rust
use ccxt_exchanges::binance::Binance;
use ccxt_core::exchange::Exchange;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let exchange = Binance::builder()
.build()?;
// Fetch order book with top 5 bids and asks
let orderbook = exchange.fetch_order_book("BTC/USDT", Some(5)).await?;
println!("BTC/USDT Order Book:");
println!(" Best Bid: {:?}", orderbook.bids.first());
println!(" Best Ask: {:?}", orderbook.asks.first());
Ok(())
}
```
## Trading with API Credentials
For trading operations, you'll need API credentials from your exchange:
```rust
use ccxt_exchanges::binance::Binance;
use ccxt_core::exchange::Exchange;
use ccxt_core::types::{OrderType, OrderSide};
use rust_decimal_macros::dec;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create exchange with credentials
let exchange = Binance::builder()
.api_key("your_api_key")
.secret("your_secret")
.sandbox(false) // Use true for testnet
.build()?;
// Fetch account balance
let balance = exchange.fetch_balance().await?;
println!("USDT Balance: {:?}", balance.total.get("USDT"));
// Create a limit order
let order = exchange.create_order(
"BTC/USDT",
OrderType::Limit,
OrderSide::Buy,
dec!(0.001), // Amount
Some(dec!(50000.0)), // Price
).await?;
println!("Order created: {}", order.id);
Ok(())
}
```
## Running the Examples
The project includes several examples you can run:
```bash
# Basic usage
cargo run --example basic_usage
# Market data
cargo run --example binance_market_data_example
# Order management
cargo run --example binance_order_management_example
# WebSocket streaming
cargo run --example binance_ws_example
```
## Next Steps
- Read the [README.md](README.md) for a complete feature overview
- Check the [docs/](docs/) directory for detailed guides
- Explore [examples/](examples/) for more code samples
- Visit [API Documentation](https://docs.rs/ccxt-rust) for detailed API reference
## Common Issues
**Q: I get "missing documentation" warnings**
A: Run `cargo doc --no-deps` to build docs, warnings indicate incomplete API docs.
**Q: Examples don't compile**
A: Make sure you're using Rust 1.91+ and run `cargo build` first.
**Q: API authentication fails**
A: Check your API credentials, system clock sync, and IP whitelist settings.
## Support
- GitHub Issues: [Report bugs or request features](https://github.com/Praying/ccxt-rust/issues)
- Documentation: [Full API docs](https://docs.rs/ccxt-rust)
- Examples: [Code samples](examples/)