Free C# / .NET Exchange Rate API

Welcome to the UniRate API C# / .NET documentation. Our free exchange rate API lets you add real-time and historical currency conversion to any .NET application — ASP.NET Core services, Blazor apps, MAUI, Xamarin, WPF, or background workers.

We ship an official .NET client library on NuGet. It uses async/await, supports CancellationToken on every method, parses responses with System.Text.Json, and has zero external dependencies — pure BCL.

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 .NET library is designed to be:

  • Modern .NET: async/await, CancellationToken, System.Text.Json
  • Zero external dependencies — pure BCL
  • Typed exception hierarchy rooted at UniRateException
  • Works with dependency injection and IHttpClientFactory
  • Open source on GitHub, published to NuGet

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

Below you'll find examples using the official UniRate .NET client.

Getting Started with csharp

Install the official NuGet package with dotnet add package UniRateApi. The library targets modern .NET and uses System.Text.Json under the hood.


// Install: dotnet add package UniRateApi

using UniRateApi;
using UniRateApi.Exceptions;

using var client = new UniRateClient("YOUR_API_KEY");

// Current rate
decimal rate = await client.GetRateAsync("USD", "EUR");
Console.WriteLine($"USD -> EUR: {rate}");

// Convert an amount
decimal euros = await client.ConvertAsync(100m, "USD", "EUR");
Console.WriteLine($"100 USD = {euros} EUR");

// All rates for a base currency
IReadOnlyDictionary rates = await client.GetAllRatesAsync("USD");
Console.WriteLine($"{rates.Count} rates for USD");

// Supported currencies
IReadOnlyList codes = await client.GetSupportedCurrenciesAsync();
Console.WriteLine($"{codes.Count} currencies supported");

// Historical rate on a specific date
var historical = await client.GetHistoricalRateAsync("2024-01-01", "USD", "EUR");

// Time series (up to 5 years)
var series = await client.GetTimeSeriesAsync(
    startDate:  "2024-01-01",
    endDate:    "2024-01-07",
    @base:      "USD",
    currencies: new[] { "EUR", "GBP" });

// VAT rate for a country (ISO-3166 alpha-2)
var germany = await client.GetVatRateAsync("DE");
Console.WriteLine($"Germany VAT: {germany.VatData.VatRateValue}%");

// Error handling — typed exceptions
try
{
    var bad = await client.GetRateAsync("USD", "ZZZ");
}
catch (AuthenticationException)  { /* invalid API key */ }
catch (InvalidCurrencyException) { /* unknown currency code */ }
catch (RateLimitException)       { /* back off and retry */ }
catch (ApiException ex)          { Console.Error.WriteLine($"{ex.StatusCode}: {ex.Body}"); }

Response Example


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

Important Notes

  • Replace 'YOUR_API_KEY' with your actual API key from unirateapi.com
  • Install with: dotnet add package UniRateApi
  • Targets modern .NET — check the NuGet page for the exact TFM requirements
  • Always dispose the client (using var) or register it via IHttpClientFactory in DI
  • Every async method accepts a CancellationToken — pass it through from your request context
  • Typed exception hierarchy: AuthenticationException, InvalidCurrencyException, RateLimitException, ApiException
  • Store your API key in appsettings.json (user-secrets in development) or an environment variable

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 csharp applications.

Get Your API Key