Practice.Backend.CurrencyConverter.Client
1.0.93
dotnet add package Practice.Backend.CurrencyConverter.Client --version 1.0.93
NuGet\Install-Package Practice.Backend.CurrencyConverter.Client -Version 1.0.93
<PackageReference Include="Practice.Backend.CurrencyConverter.Client" Version="1.0.93" />
<PackageVersion Include="Practice.Backend.CurrencyConverter.Client" Version="1.0.93" />
<PackageReference Include="Practice.Backend.CurrencyConverter.Client" />
paket add Practice.Backend.CurrencyConverter.Client --version 1.0.93
#r "nuget: Practice.Backend.CurrencyConverter.Client, 1.0.93"
#:package Practice.Backend.CurrencyConverter.Client@1.0.93
#addin nuget:?package=Practice.Backend.CurrencyConverter.Client&version=1.0.93
#tool nuget:?package=Practice.Backend.CurrencyConverter.Client&version=1.0.93
Practice.Backend.CurrencyConverter.Client
A typed, DI-friendly HTTP client library for the Currency Converter API. Publish as a NuGet package to share across services or environments.
Features
- Typed
ICurrencyConverterClientinterface — easy to mock in tests - Configurable base URL — supports local, staging, and production environments
- JWT bearer authentication via pluggable
ITokenProvider - Built-in resilience: exponential retry + circuit breaker (via
Microsoft.Extensions.Http.Resilience) - Options validation on startup — misconfiguration fails fast
- Fully compatible with
IHttpClientFactoryand Microsoft's generic host
Installation
dotnet add package Practice.Backend.CurrencyConverter.Client
Quick Start
1. Configure via appsettings.json
{
"CurrencyConverterClient": {
"BaseUrl": "https://api.example.com",
"ApiVersion": "1",
"TimeoutSeconds": 30,
"Retry": {
"MaxAttempts": 3,
"InitialDelaySeconds": 2
},
"CircuitBreaker": {
"FailureRatio": 0.5,
"BreakDurationSeconds": 60,
"SamplingDurationSeconds": 60,
"MinimumThroughput": 30
}
}
}
2. Register in DI
// From configuration section (recommended)
services.AddCurrencyConverterClient(
builder.Configuration.GetSection(CurrencyConverterClientOptions.SectionName));
// Or inline
services.AddCurrencyConverterClient(options =>
{
options.BaseUrl = "http://localhost:9081";
options.TimeoutSeconds = 15;
});
3. Add Authentication (optional)
Option A — forward the incoming bearer token (ASP.NET Core apps):
services.AddDefaultHttpContextTokenProvider();
This forwards the Authorization: Bearer ... header from the current HTTP context — useful when the calling service already has a Keycloak token.
Option B — custom provider:
public class KeycloakTokenProvider(IKeycloakClient keycloak) : ITokenProvider
{
public async Task<string?> GetTokenAsync(CancellationToken ct = default)
=> await keycloak.GetAccessTokenAsync(ct);
}
services.AddSingleton<ITokenProvider, KeycloakTokenProvider>();
If no ITokenProvider is registered, requests are sent without an Authorization header.
4. Inject and use
public class MyService(ICurrencyConverterClient client)
{
public async Task<decimal> GetEurToUsdRateAsync(CancellationToken ct)
{
var response = await client.GetLatestExchangeRatesAsync(
new LatestExchangeRatesRequest { BaseCurrency = "EUR" },
ct);
return response.Rates.GetValueOrDefault("USD");
}
public async Task<decimal> ConvertAsync(decimal amount, CancellationToken ct)
{
var response = await client.GetConversionAsync(
new ConversionRequest { BaseCurrency = "EUR", ToCurrency = "USD", Amount = amount },
ct);
return response.Rates.GetValueOrDefault("USD");
}
}
API
ICurrencyConverterClient
| Method | Returns | Description |
|---|---|---|
GetLatestExchangeRatesAsync(request, ct) |
ExchangeRateResponse |
Latest rates for a base currency |
GetHistoricalExchangeRatesAsync(request, ct) |
HistoricalExchangeRateResponse |
Historical rates with optional date range and pagination |
GetConversionAsync(request, ct) |
ExchangeRateResponse |
Convert an amount between two currencies |
All methods throw CurrencyConverterApiException on API errors.
CurrencyConverterApiException
| Property | Description |
|---|---|
StatusCode |
HTTP status code from the API |
RequestUri |
The URI that produced the error |
ResponseContent |
Raw response body (for diagnostics) |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
- Microsoft.AspNetCore.WebUtilities (>= 10.0.5)
- Microsoft.Extensions.Http (>= 10.0.5)
- Microsoft.Extensions.Http.Resilience (>= 10.4.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.5)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.5)
- Practice.Backend.CurrencyConverter.Messages (>= 1.0.93)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.93 | 164 | 4/2/2026 |
| 1.0.91-dev | 115 | 4/2/2026 |
| 1.0.89 | 147 | 4/1/2026 |
| 1.0.87-dev | 117 | 4/1/2026 |
| 1.0.85 | 108 | 4/1/2026 |
| 1.0.83-dev | 112 | 4/1/2026 |
| 1.0.81 | 123 | 3/31/2026 |
| 1.0.79-dev | 115 | 3/31/2026 |
| 1.0.78 | 115 | 3/31/2026 |
| 1.0.75-dev | 123 | 3/31/2026 |
| 1.0.72 | 116 | 3/31/2026 |
| 1.0.70-dev | 109 | 3/31/2026 |
| 1.0.68 | 142 | 3/31/2026 |
| 1.0.66-dev | 115 | 3/31/2026 |
| 1.0.64 | 119 | 3/31/2026 |
| 1.0.62-dev | 113 | 3/31/2026 |
| 1.0.60 | 119 | 3/31/2026 |
| 1.0.58-dev | 112 | 3/31/2026 |
| 1.0.55-dev | 120 | 3/30/2026 |
| 1.0.52-dev | 104 | 3/30/2026 |