cbat - Coinbase Advanced Trade API SDK for Rust
A Rust SDK for the Coinbase Advanced Trade API, providing async/await support for trading, account management, and real-time data via WebSocket.
Installation
Add this to your Cargo.toml:
[]
= "0.0.19"
Quick Start
Set your environment variables. The secret must be an EC key in sec1 format and will be converted to pkcs#8:
CBAT_KEY_NAME="organizations/{org_id}/apiKeys/{key_id}"
CBAT_KEY_SECRET="-----BEGIN EC PRIVATE KEY-----\nYOUR PRIVATE KEY\n-----END EC PRIVATE KEY-----\n"
use *;
async
Features
- Accounts: List accounts, get balances, manage portfolios
- Orders: Create, edit, cancel orders, preview orders
- Products: Get product info, order books, market trades, candles
- Public API: Server time, public products, market data
- WebSocket: Real-time feeds for tickers, candles, level2, user events
- Futures & Perpetuals: Support for futures and perpetual contracts
Usage Examples
Get Product Information
use *;
let product = get_public_product.await.unwrap;
println!;
Create a Limit Order
use *;
let request = CreateOrderRequest ;
let order = create_order.await.unwrap;
println!;
WebSocket Subscription
use *;
let mut ws_client = new.await.unwrap;
ws_client.subscribe.await.unwrap;
while let Some = ws_client.next.await
API Reference
Full API documentation is available at docs.rs/cbat.
License
MIT