Minimal, idiomatic Rust client for OpenExchangeAPI
- All endpoints supported
- API key is optional
- Async/await support
- Strong types and precise decimal support
Add to your Cargo.toml
:
[dependencies]
openexchangeapi = "*"
use openexchangeapi::OpenExchangeApiClient;
#[tokio::main]
async fn main() -> Result<(), openexchangeapi::OpenExchangeApiError> {
let client = OpenExchangeApiClient::new(None); // API key optional
// Get latest rates
let latest = client.get_latest(None).await?;
println!("{:?}", latest);
// Convert currency
let result = client.convert("USD", "EUR", 100.0).await?;
println!("{:?}", result);
Ok(())
}
get_latest(base)
get_latest_precise(base)
get_historical(date, base)
get_historical_precise(date, base)
convert(from, to, amount)
convert_precise(from, to, amount)
list_currencies(type)
get_currency(code)
All methods return Result<T, OpenExchangeApiError>
.
All errors are returned as OpenExchangeApiError
.
MIT