Skip to main content

unirate_api/
lib.rs

1//! # UniRate API — Rust client
2//!
3//! Official Rust client for the [UniRate API](https://unirateapi.com) — free,
4//! real-time and historical currency exchange rates plus VAT rates.
5//!
6//! ## Quick start
7//!
8//! ```no_run
9//! use unirate_api::Client;
10//!
11//! #[tokio::main]
12//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
13//!     let client = Client::new("your-api-key");
14//!
15//!     let rate = client.get_rate("USD", "EUR").await?;
16//!     println!("USD → EUR: {}", rate);
17//!
18//!     let converted = client.convert(100.0, "USD", "EUR").await?;
19//!     println!("100 USD = {} EUR", converted);
20//!
21//!     Ok(())
22//! }
23//! ```
24//!
25//! Get a free API key at <https://unirateapi.com>.
26
27#![deny(missing_debug_implementations)]
28#![warn(rust_2018_idioms)]
29
30pub mod client;
31pub mod endpoints;
32pub mod error;
33pub mod models;
34
35pub use client::{Client, ClientBuilder};
36pub use error::UniRateError;
37pub use models::{
38    HistoricalLimit, HistoricalLimitsResponse, VatRate, VatRateResponse, VatRatesResponse,
39};
40
41/// Default UniRate API base URL.
42pub const DEFAULT_BASE_URL: &str = "https://api.unirateapi.com";
43
44/// Crate version, exposed as the `User-Agent` suffix.
45pub const VERSION: &str = env!("CARGO_PKG_VERSION");