| Crates.io | kucoin |
| lib.rs | kucoin |
| version | 0.7.4 |
| created_at | 2025-11-26 16:00:11.672997+00 |
| updated_at | 2026-01-07 14:03:10.510543+00 |
| description | A robust and asynchronous Rust client for the KuCoin exchange API. |
| homepage | |
| repository | https://github.com/blackh-t/kucoin |
| max_upload_size | |
| id | 1951625 |
| size | 181,407 |
An asynchronous, strongly typed Rust client for the KuCoin REST API.
Designed for reliability and production use, this crate provides ergonomic wrappers for KuCoin endpoints covering spot trading, wallet activity, and sub-account management.
Async-first — built on tokio and reqwest
Spot trading
Wallet & deposits
Sub-accounts
Typed requests
[dependencies]
kucoin = "0.4.0"
tokio = { version = "1", features = ["full"] }
dotenv = "0.15" # optional
use std::env;
use kucoin::client::rest::{Credentials, KuCoinClient};
#[tokio::main]
async fn main() {
let credentials = Credentials::new(
&env::var("API_KEY").expect("API_KEY not set"),
&env::var("API_SECRET").expect("API_SECRET not set"),
&env::var("API_PASSPHRASE").expect("API_PASSPHRASE not set"),
);
let client = KuCoinClient::new(credentials);
}
use kucoin::types::spot::{SpotOrderRequest, TradeType, Side};
async fn place_order(client: &KuCoinClient) {
let order = SpotOrderRequest::new(TradeType::Market, "BTC-USDT", Side::Buy)
.set_funds(100.0)
.set_remark("example-order");
client.spot().place_order(order).await.unwrap();
}
use kucoin::types::spot::{BatchSpotContract, SpotOrderRequest, TradeType, Side};
async fn batch_orders(client: &KuCoinClient) {
let batch = BatchSpotContract::new()
.add_order(
SpotOrderRequest::new(TradeType::Market, "BTC-USDT", Side::Buy)
.set_funds(50.0),
)
.add_order(
SpotOrderRequest::new(TradeType::Market, "SOL-USDT", Side::Buy)
.set_funds(20.0),
);
client.spot().place_multi_orders(batch).await.unwrap();
}
use kucoin::types::spot::SpotCancelRequest;
async fn cancel(client: &KuCoinClient, order_id: &str) {
let req = SpotCancelRequest::new(order_id, 0.0, "BTC-USDT");
client.spot().cancel_order(req).await.unwrap();
}
async fn open_orders(client: &KuCoinClient) {
let res = client.spot().list_orders_open("BTC-USDT").await.unwrap();
println!("{:#?}", res.data);
}
use kucoin::types::deposit::{DepositHistoryRequest, DepositStatus};
async fn deposits(client: &KuCoinClient) {
let req = DepositHistoryRequest::new("SOL")
.set_status(DepositStatus::Success)
.set_page_size(20);
client.deposit().history(req).await.unwrap();
}
async fn lookup(client: &KuCoinClient, tx: &str) {
let res = client.deposit().by_tx_hash(tx).await.unwrap();
println!("{:#?}", res);
}
use kucoin::types::sup_account::{SubAccRequest, Expire};
async fn create_sub(client: &KuCoinClient) {
let req = SubAccRequest::new("SubUser01", "Trading Bot", "StrongPass123!")
.set_permission("General,Spot")
.add_ipwhitelist("192.168.1.1")
.set_expire(Expire::Never);
client.sub_account().add_api(req).await.unwrap();
}
async fn list_subs(client: &KuCoinClient) {
let res = client.sub_account().fetchall().await.unwrap();
println!("{:#?}", res.data);
}
async fn balance(client: &KuCoinClient, uid: &str) {
let res = client.sub_account().balance(uid).await.unwrap();
println!("{:#?}", res.data);
}
This crate is used in CoinBot, an automated crypto trading platform built in Rust.
This serves as a production reference for high-frequency and automated trading workloads.
client/ — authentication & HTTP layerendpoints/ — KuCoin API endpointstypes/ — request and response modelsutils/ — shared helpersIssues and pull requests are welcome.