# exchangerateapi-rust
[](https://crates.io/crates/exchangerateapi-rust)
[](https://docs.rs/exchangerateapi-rust)
[](LICENSE)
Rust client for [exchangerateapi.net](https://exchangerateapi.net) with two focused endpoints.
## Install
Add to `Cargo.toml`:
```toml
exchangerateapi-rust = "0.1"
```
## Quick start
```rust
use exchangerateapi_rust::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("EXCHANGERATEAPI_KEY").unwrap_or_else(|_| "YOUR_API_KEY".into());
let client = Client::new(api_key)?;
let latest = client.latest("USD", None).await?;
println!("latest: {}", latest.rates);
Ok(())
}
```
## Usage
- Latest with optional symbols
- Historical by date and base
```rust
let subset = client.latest("EUR", Some(&["USD","GBP","JPY"])) .await?;
let hist = client.historical("2024-01-02", "USD", None).await?;
```
## Examples
Run with your API key:
```bash
EXCHANGERATEAPI_KEY=your_api_key cargo run --example latest
EXCHANGERATEAPI_KEY=your_api_key cargo run --example historical
```
## Free usage
A generous free tier exists for development and light workloads. Review current limits at [exchangerateapi.net](https://exchangerateapi.net).
## License
MIT