Crate currencyapi
source ·Expand description
currencyapi API library.
Note: experimental
The starting point of this library is the Rates
type for currency rates, which provides:
The Convert Exchange Rates endpoint is not provided but
conversion is implemented via Rates::convert
.
Example
ⓘ
async fn main() {
let mut rates = Rates::<rust_decimal::Decimal>::new(); // requires `rust_decimal` feature and crate
let request = request.base_currency(EUR).currencies([EUR,USD,GBP]).build();
let metadata = rates
.fetch_latest::<DateTime<Utc>, RateLimitIgnore>(&client, request) // DateTime<Utc> from the `chrono` crate
.await
.unwrap();
println!("Fetched {} rates as of {}", rates.len(), metadata.last_updated_at);
for (currency, value) in rates.iter() { println!("{currency} {value}"); }
}
Modules
- Currencies constants.
- API for the
latest
endpoint.
Structs
- Rate-limit data from response headers.
- Ignore rate limit data.
- Currency rates.
Enums
- Invalid currency code error.
- An error from the API or from the HTTP client.
Traits
- Scientific notation parsing.