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§
- currency
- Currencies constants.
- latest
- API for the
latest
endpoint.
Structs§
- Currency
Code - Currency code.
- Rate
Limit - Rate-limit data from response headers.
- Rate
Limit Ignore - Ignore rate limit data.
- Rates
- Currency rates.
Enums§
- Currency
Error - Invalid currency code error.
- Error
- An error from the API or from the HTTP client.
Traits§
- From
Scientific - Scientific notation parsing.