exchangerateapi-rust 0.1.0

Rust client for exchangerateapi.net: latest and historical endpoints
Documentation

exchangerateapi-rust

Crates.io Docs License: MIT

Rust client for exchangerateapi.net with two focused endpoints.

Install

Add to Cargo.toml:

exchangerateapi-rust = "0.1"

Quick start

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
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:

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.

License

MIT