| Crates.io | mexc-rs |
| lib.rs | mexc-rs |
| version | 0.6.3 |
| created_at | 2023-09-20 23:14:21.277749+00 |
| updated_at | 2025-04-28 23:56:29.440805+00 |
| description | Rust client for the mexc.com exchange |
| homepage | |
| repository | https://github.com/elertan/mexc-rs |
| max_upload_size | |
| id | 978912 |
| size | 245,510 |
mexc-rs is a Rust client library for the MEXC cryptocurrency exchange API.
It provides a lightweight and easy-to-use interface for interacting with market data, account information, and trading operations.
.env filesTo use your MEXC API keys securely, you can store them in an .env file. Here’s how to get started:
Create a .env file in the root of your project.
Add your MEXC API credentials to the .env file:
MEXC_API_KEY=your_api_key_here
MEXC_SECRET_KEY=your_secret_key_here
use mexc_rs::futures::v1::endpoints::get_kline::{GetKline, GetKlineParams};
use mexc_rs::futures::v1::models::KlineInterval;
use mexc_rs::futures::MexcFuturesApiClient;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = MexcFuturesApiClient::default();
let params = GetKlineParams {
symbol: "KAS_USDT",
interval: KlineInterval::FifteenMinutes,
start: None,
end: None,
};
let output = client.get_kline(params).await?;
// first 5 klines
tracing::info!("Output: {:#?}", &output.klines[0..5]);
Ok(())
}
More examples are available in the examples/ directory.
Testing all the inputs of the API is somewhat dangerous : the API is real and deals with real orders.
Four of the tests should fail :
The test_order is an invalid price and 3 others fails to catch a real order that should be in your account. If you really need to test, change the orders values, and create the expected orders in your account, at your own risk.