4 releases (1 stable)

1.0.0 Sep 17, 2023
0.3.1 Sep 1, 2022
0.3.0 Sep 1, 2022
0.2.0 Apr 2, 2022
0.1.0 Apr 1, 2022

#72 in Finance

MIT/Apache

33KB
601 lines

currencyapi

Wraps the currencyapi (previously: freecurrencyapi) API.

Currently only supports the latest endpoint.


lib.rs:

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}"); }
}

Dependencies

~4–18MB
~253K SLoC