Rust Exchange Rate API | AllRatesToday Rust SDK
Integrate exchange rates into Rust apps with the official AllRatesToday SDK: blocking client, 160+ currencies, conversion, history and official central-bank rates. cargo add allratestoday.
Rust Exchange Rate API — AllRatesToday SDK
The allratestoday
crate is the official Rust SDK for the AllRatesToday currency API: live mid-market rates
and conversion for 160+ currencies, historical series, and the official rates published by
123 central banks and 6 tax authorities — with typed responses and a single error enum.
The client is blocking (built on reqwest's blocking API with
rustls), so it needs no async runtime. In an async application, call it from
tokio::task::spawn_blocking. The crate is on
crates.io, API docs are on
docs.rs, and the source is on
GitHub.
Installation
cargo add allratestoday Or in Cargo.toml:
[dependencies]
allratestoday = "1.1" Quick Start
use allratestoday::AllRatesToday;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = AllRatesToday::new("art_live_xxxxx");
// Latest rates for USD against EUR and GBP
let rates = client.latest("USD", Some(&["EUR", "GBP"]))?;
println!("{:?} as of {:?}", rates.rates, rates.date);
// Convert 100 USD to EUR
let result = client.convert("USD", "EUR", 100.0)?;
println!("100 USD = {:?} EUR", result.result);
Ok(())
} Authentication
Market-rate methods send your API key as a Bearer token:
- Sign up at allratestoday.com/register (free, no card).
- Copy the key from your dashboard. It begins with
art_live_. - Load it from the environment rather than hard-coding it:
let api_key = std::env::var("ALLRATES_API_KEY")
.expect("ALLRATES_API_KEY must be set");
let client = AllRatesToday::new(api_key); symbols(), official_rates() and official_sources() need no
key — use AllRatesToday::keyless(). Latest rates and conversion work on every plan,
including free. Historical methods (for_date, time_series,
get_historical_rates, convert_on_date) need a
paid plan.
All Methods
Every method is blocking and returns Result<T, AllRatesTodayError>.
| Method | Key | Returns |
|---|---|---|
latest(base, symbols) | yes | Latest rates for a base currency |
get_rates(source, targets) | yes | One Rate per target |
get_rate(from, to) | yes | A single pair |
convert(from, to, amount) | yes | Converted amount and rate |
convert_on_date(from, to, amount, date) | paid plan | Conversion at a past date |
for_date(date, base, symbols) | paid plan | Rates on a past date |
time_series(start, end, base, symbols) | paid plan | Rates across a date range |
get_historical_rates(source, target, period) | paid plan | 1d / 7d / 30d / 1y series |
symbols() | no | Every supported currency |
official_rates(bank, source, target) | no | A central bank's latest published table, or one pair |
official_sources() | no | Every official source with its latest publication date |
latest(base, symbols)
Most recent mid-market rates for a base currency. Pass None for every currency.
let all = client.latest("USD", None)?;
let some = client.latest("USD", Some(&["EUR", "GBP", "JPY"]))?;
println!("{:?}", some.rates); get_rates(source, targets) and get_rate(from, to)
for r in client.get_rates("USD", &["EUR", "GBP"])? {
println!("{}/{}: {}", r.source, r.target, r.rate);
}
let rate = client.get_rate("GBP", "USD")?;
println!("1 GBP = {:?} USD", rate.rate); convert(from, to, amount)
let result = client.convert("EUR", "JPY", 250.0)?;
println!("rate {:?}, result {:?}", result.rate, result.result); for_date(date, base, symbols) — paid plan
Rates on a date in the last 365 days. symbols is required; each symbol is one request.
let past = client.for_date("2026-10-01", "USD", Some(&["EUR", "GBP"]))?;
println!("{:?}: {:?}", past.date, past.rates); time_series(start, end, base, symbols) — paid plan
let series = client.time_series("2026-10-01", "2026-10-15", "USD", Some(&["EUR"]))?;
for (date, day) in series.rates.unwrap_or_default() {
println!("{date}: {day:?}");
} get_historical_rates(source, target, period) — paid plan
let history = client.get_historical_rates("USD", "EUR", "30d")?;
for point in history.rates.unwrap_or_default() {
println!("{}: {:?}", point.date.unwrap_or_default(), point.rate);
} symbols() — no key
let symbols = AllRatesToday::keyless().symbols()?;
for c in symbols.currencies.unwrap_or_default() {
println!("{:?} {:?}", c.code, c.name);
} official_rates(bank, source, target) — no key
The latest table published by a central bank or tax authority — the fixed, citable rate for
invoicing, tax and accounting. Record rate_date, not today's date.
Dated official tables need a paid plan.
let keyless = AllRatesToday::keyless();
let ecb = keyless.official_rates("ecb", Some("EUR"), Some("USD"))?;
println!("ECB {}: 1 EUR = {:?} USD", ecb.rate_date, ecb.rate);
for s in keyless.official_sources()?.sources {
println!("{} {} {:?}", s.code, s.name, s.latest);
} Error Handling
use allratestoday::{AllRatesToday, AllRatesTodayError};
match client.latest("USD", None) {
Ok(rates) => println!("{rates:?}"),
Err(AllRatesTodayError::HttpError(e)) => eprintln!("Network error: {e}"),
Err(AllRatesTodayError::ApiError { status, message }) => {
eprintln!("API error {status}: {message}");
}
Err(AllRatesTodayError::ParseError(msg)) => eprintln!("Parse error: {msg}"),
Err(AllRatesTodayError::InvalidArgument(msg)) => eprintln!("Invalid argument: {msg}"),
} | Variant | Cause |
|---|---|
HttpError(reqwest::Error) | Network or transport failure: timeout, DNS, TLS. |
ApiError { status, message } | Non-2xx response: 401 invalid key, 403 plan does not include the call, 429 quota or rate limit. |
ParseError(String) | The response could not be deserialised, or held no rate. |
InvalidArgument(String) | Rejected before sending: missing key, missing symbols, bad or out-of-range date, bad source code. |
Configuration
The client talks to https://allratestoday.com. Point it elsewhere, for example at a test server:
let client = AllRatesToday::with_base_url("art_live_xxxxx", "http://localhost:8787"); Resources
- Source and issues: github.com/AllRates-Today/allratestoday-rust
- crates.io:
allratestoday· docs.rs: API docs - All SDKs: /docs/sdks/ · REST reference: /docs/
- Status: allratestoday.com/status · Support: support@allratestoday.com
Ready to add live FX data to your Rust app?
One cargo add. Free tier. No credit card.