Free Rust Exchange Rate API

Welcome to the UniRate API Rust documentation. Our free exchange rate API gives you real-time and historical currency conversion — drop it into your Tokio/axum/warp service, CLI, or embedded data pipeline and you're done.

The official Rust client crate uses modern async/await, returns Send + Sync models via serde, and pulls in reqwest with rustls so there's no OpenSSL dependency to manage.

With UniRate API, you get:

  • Real-time exchange rates for 170+ currencies (fiat + crypto)
  • Historical rates back to 1999 and time-series up to 5 years
  • VAT rates for countries worldwide
  • Free tier with no credit card required

The Rust crate is designed to be:

  • Modern Rust: async/await, Send + Sync, serde-derived models
  • Minimal deps: reqwest (rustls) + serde + thiserror — no OpenSSL
  • Rust 1.74+ stable with a Tokio-friendly async API
  • Strongly typed UniRateError via thiserror
  • Open source on GitHub, published to crates.io

For full reference on endpoints, rate limits, and advanced options, see our main API documentation.

Below you'll find examples using the official UniRate Rust crate.

Getting Started with Rust

Add the crate to your Cargo.toml with cargo add unirate-api, or declare it manually alongside a Tokio async runtime.


// Cargo.toml
// [dependencies]
// unirate-api = "0.1"
// tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

use unirate_api::Client;

#[tokio::main]
async fn main() -> Result<(), Box> {
    let client = Client::new("YOUR_API_KEY");

    // Current rate
    let rate = client.get_rate("USD", "EUR").await?;
    println!("USD -> EUR: {rate}");

    // Convert an amount
    let euros = client.convert(100.0, "USD", "EUR").await?;
    println!("100 USD = {euros} EUR");

    // All rates for a base
    let rates = client.get_all_rates("USD").await?;
    println!("{} rates for USD", rates.len());

    // Supported currencies
    let codes = client.get_supported_currencies().await?;
    println!("{} currencies supported", codes.len());

    // Historical rate on a specific date
    let hist = client.get_historical_rate("2024-01-01", "USD", "EUR").await?;
    println!("USD -> EUR on 2024-01-01: {hist}");

    // Time series (up to 5 years)
    let series = client
        .get_time_series(
            "2024-01-01",
            "2024-01-07",
            "USD",
            Some(&["EUR", "GBP"]),
            1.0,
        )
        .await?;
    let _ = series;

    // VAT rate for a country (ISO-3166 alpha-2)
    let germany = client.get_vat_rate("DE").await?;
    println!("Germany VAT: {}%", germany.vat_data.vat_rate);

    Ok(())
}

Response Example


USD -> EUR: 0.9245
100 USD = 92.45 EUR
593 rates for USD
593 currencies supported
USD -> EUR on 2024-01-01: 0.9056
Germany VAT: 19%

Important Notes

  • Replace 'YOUR_API_KEY' with your actual API key from unirateapi.com
  • Install with: cargo add unirate-api (requires a tokio runtime)
  • Requires Rust 1.74+ (stable)
  • Uses reqwest with rustls — no OpenSSL dependency to manage
  • Historical endpoints require a Pro API key; surfaced as UniRateError::Api { status: 403, .. }
  • All errors are typed via the UniRateError enum — match on the variant, not the message
  • Prefer loading your API key from an environment variable or secret manager

Not a Developer?

We offer paid implementation services to integrate our API into your application without you needing to write any code.

Contact Us for a Quote

Ready to Get Started?

Sign up now to get your API key and start converting currencies in your Rust applications.

Get Your API Key