allratestoday
Official Rust SDK for AllRatesToday -- real-time mid-market exchange rates for 160+ currencies.
Installation
Add the crate to your project:
Or add it manually to your Cargo.toml:
[]
= "1"
Quick Start
use AllRatesToday;
Authentication
Sign up at allratestoday.com to get your API key. Keys follow the format art_live_....
The SDK sends the key as a Bearer token in the Authorization header.
API Methods
latest(base, symbols) -- Get Latest Rates
Fetch the most recent exchange rates for a base currency.
// All currencies
let rates = client.latest?;
// Specific currencies only
let rates = client.latest?;
println!;
println!;
convert(from, to, amount) -- Convert Currency
Convert an amount from one currency to another.
let result = client.convert?;
println!;
println!;
for_date(date, base, symbols) -- Historical Rates
Get exchange rates for a specific historical date.
let rates = client.for_date?;
println!;
println!;
time_series(start_date, end_date, base, symbols) -- Time Series
Get exchange rates over a date range.
let series = client.time_series?;
for in series.rates.unwrap_or_default
symbols() -- List Supported Currencies
Retrieve all supported currency codes and names.
let symbols = client.symbols?;
for in symbols.symbols.unwrap_or_default
get_rate(from, to) -- Single Pair Rate
Get the exchange rate for a single currency pair.
let rate = client.get_rate?;
println!;
get_historical_rates(source, target, period) -- Preset Period Historical Rates
Get historical rates for a currency pair over a preset period.
Supported periods: 1d, 7d, 30d, 1y.
let history = client.get_historical_rates?;
for point in history.rates.unwrap_or_default
Error Handling
All methods return Result<T, AllRatesTodayError>. The error enum has three variants:
| Variant | Description |
|---|---|
HttpError |
Network or transport-level failure (timeout, DNS, TLS) |
ApiError |
Non-2xx HTTP response from the API |
ParseError |
Failed to deserialize the response body |
use ;
let client = new;
match client.latest
Custom Base URL
For testing or self-hosted instances, you can override the base URL:
let client = with_base_url;
Examples
Run the included example:
License
This project is licensed under the MIT License.
Links
- Website: allratestoday.com
- API Documentation: allratestoday.com/docs
- Crate: crates.io/crates/allratestoday
- Docs: docs.rs/allratestoday
- Repository: github.com/allratestoday/allratestoday-rust