cmc

Crates.io docs.rs MIT licensed Apache-2.0 licensed

Unofficial Rust Library for the CoinMarketCap API

Usage

Get your API key here


CoinMarketCap ID Map

NOTE: CoinMarketCap recommend utilizing CMC ID instead of cryptocurrency symbols to securely identify cryptocurrencies with other endpoints and in your own application logic. ```rust use cmc::{Cmc, Sort};

let cmc = Cmc::new("");

match cmc.id_map(1, 50, Sort::CmcRank) { Ok(map) => println!("{}", map), Err(err) => println!("{}", err), } ```

Price cryptocurrency

```rust use cmc::Cmc;

let cmc = Cmc::new("");

match cmc.price("BTC") { Ok(price) => println!("Price: {}", price), Err(err) => println!("Error: {}", err), } ```

Price with custom settings

```rust use cmc::{CmcBuilder, Pass};

let cmc = CmcBuilder::new("") .pass(Pass::Id) .convert("EUR") .build();

match cmc.price("1027") { // 1027 is Ethereum id. Ok(price) => println!("Price: {}", price), // In Euro instead default USD Err(err) => println!("Error: {}", err), } ```

Price conversion

```rust use cmc::Cmc;

let cmc = Cmc::new("");

// 2.5 BTC in EUR (using symbols) match cmc.price_conversion(2.5, "BTC", None, "EUR") { Ok(price) => println!("Total price: {}", price), Err(err) => println!("Error: {}", err), }

// 1.6 ETH in XMR (using id's) match cmc.priceconversionid(1.6, "1027", None, "328") { Ok(price) => println!("Total price: {}", price), Err(err) => println!("Error: {}", err), } ```

Exchange ID Map

```rust use cmc::{Cmc, ListingStatusExchange, SortExchange};

let cmc = Cmc::new("");

match cmc.exchangeidmap(ListingStatusExchange::Active, 1, 10, SortExchange::Id, None) { Ok(map) => println!("{}", map), Err(err) => println!("{}", err), } ```


See the documentation for the rest.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.