| Crates.io | dceapi-rs |
| lib.rs | dceapi-rs |
| version | 0.1.1 |
| created_at | 2026-01-07 11:20:34.190124+00 |
| updated_at | 2026-01-20 07:03:23.66592+00 |
| description | Dalian Commodity Exchange (DCE) API client library |
| homepage | |
| repository | https://github.com/pseudocodes/dceapi-rs |
| max_upload_size | |
| id | 2028058 |
| size | 222,506 |
A high-performance, asynchronous Rust client library for the Dalian Commodity Exchange (DCE) API.
Ported from the dceapi-go library, this SDK provides a type-safe and efficient way to interact with DCE market data, news, delivery, and trading services.
tokio and reqwest for modern async/await workflows.thiserror.Add this to your Cargo.toml:
[dependencies]
dceapi = { path = "./path/to/dceapi-rs" } # Adjust the path accordingly
tokio = { version = "1", features = ["full"] }
export DCE_API_KEY="your-api-key"
export DCE_SECRET="your-secret"
use dceapi::{Client, Config};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client from environment variables
let client = Client::from_env()?;
// Get current trade date
let trade_date = client.common.get_curr_trade_date(None).await?;
println!("Current trade date: {}", trade_date.date);
// Get variety list
let varieties = client.common.get_variety_list(None).await?;
for v in varieties.iter().take(5) {
println!("Variety: {} ({})", v.name, v.code);
}
Ok(())
}
The project includes two examples:
Basic: Simple demonstration of trade date and variety list retrieval.
cargo run --example basic
Complete: Comprehensive demonstration of all 36+ API endpoints across 7 services:
All API calls are spaced 1 second apart to respect rate limits.
cargo run --example complete
You can also configure the client manually:
use dceapi::{Client, Config};
use std::time::Duration;
let config = Config::new()
.with_api_key("your-api-key")
.with_secret("your-secret")
.with_timeout(Duration::from_secs(30))
.with_lang("zh");
let client = Client::new(config)?;
MIT / Apache-2.0