Bodu.Financial.ExchangeRates.ExchangeRateHost
1.3.0
dotnet add package Bodu.Financial.ExchangeRates.ExchangeRateHost --version 1.3.0
NuGet\Install-Package Bodu.Financial.ExchangeRates.ExchangeRateHost -Version 1.3.0
<PackageReference Include="Bodu.Financial.ExchangeRates.ExchangeRateHost" Version="1.3.0" />
<PackageVersion Include="Bodu.Financial.ExchangeRates.ExchangeRateHost" Version="1.3.0" />
<PackageReference Include="Bodu.Financial.ExchangeRates.ExchangeRateHost" />
paket add Bodu.Financial.ExchangeRates.ExchangeRateHost --version 1.3.0
#r "nuget: Bodu.Financial.ExchangeRates.ExchangeRateHost, 1.3.0"
#:package Bodu.Financial.ExchangeRates.ExchangeRateHost@1.3.0
#addin nuget:?package=Bodu.Financial.ExchangeRates.ExchangeRateHost&version=1.3.0
#tool nuget:?package=Bodu.Financial.ExchangeRates.ExchangeRateHost&version=1.3.0
Bodu.Financial.ExchangeRates.ExchangeRateHost
API stability - Stable. The public API surface is committed: breaking changes are reserved for a major-version bump per SemVer, except a deliberate break that is recorded in the release notes and in the package's
CompatibilitySuppressions.xml. See versioning and support.
A Bodu.Financial exchange-rate provider backed by the exchangerate.host
(api.exchangerate.host) foreign-exchange REST service.
It fetches the exchangerate.host timeframe and single-date endpoints, parses the JSON
response, and serves the results as Bodu.Financial.ExchangeRates.ExchangeRate values
through the standard IDatedRateProvider and IRateProvider contracts - so it composes
with Money.ConvertTo, the caching and aggregating providers, and the rest of the
Bodu.Financial FX stack. The same interfaces and DI shape as every other provider, a
different data source.
using Bodu.Financial.ExchangeRates;
// The provider builds and owns its HttpClient from the options; dispose it to release the client.
using var provider = new ExchangeRateHostRateProvider(new ExchangeRateHostRateProviderOptions { ApiKey = "…" });
// Warm a pair for a range (recommended), then look rates up synchronously.
await provider.LoadPairAsync("EUR", "USD", new DateOnly(2023, 1, 1), new DateOnly(2023, 6, 30));
RateLookupResult usd = provider.GetRate("EUR", "USD", new DateOnly(2023, 1, 3));
Behaviour
- Source + quote. exchangerate.host denominates its response against a source currency
and returns the requested quote currencies, keyed by the concatenated
{SOURCE}{QUOTE}currency code (for exampleUSDEUR). A pair is fetched by denominating against the source currency and requesting the destination currency as the quote currency. - Endpoint selection. A one-day request uses the single-date endpoint (the date is
carried in the
datequery parameter); a multi-day range uses thetimeframeendpoint (the bounds are carried instart_dateandend_date). - Plan limits. The free plan supports a USD source currency and single-date requests;
changing the source currency and the
timeframe(multi-day) endpoint require a paid plan (source-currency switching from the Basic plan, time-frame queries from the Professional Plus plan). A request the account's plan does not permit surfaces as a fetch failure, not a pre-empted request. On a plan without time-frame queries, warm one day at a time (LoadPairAsyncwith equal start and end dates): the on-demand and latest-rate lookups fetch theDefaultLookbackwindow, a multi-day request. On the free plan, request pairs whose source currency is USD; a request for the reverse pair sends that pair's own source currency, so to readEUR/USDwarmUSD/EURfirst, and its reverse then resolves by inversion from the loaded series. - API key required. Set
ApiKey; it is presented as theaccess_keyquery parameter. - No provider-local disk cache. For durable caching, compose with
AddCachedRateProvider<…>from theBodu.Financial.ExchangeRates.Cachingpackage.
Endpoint configuration
| Option | Default | Purpose |
|---|---|---|
ApiKey |
(required) | The exchangerate.host access key, sent as access_key. |
BaseAddress |
https://api.exchangerate.host/ |
The API host. |
TimeSeriesPath |
timeframe |
The multi-day time-frame endpoint. |
HistoricalPath |
historical |
The single-date endpoint (date sent as date). |
HttpTimeout |
30 s | Applied to the HttpClient the provider creates, or by the DI registration. |
AllowSynchronousNetworkAccess |
false |
Opt in to blocking on-demand fetches from synchronous lookups. |
DefaultLookback |
7 days | The look-back window, ending on the requested date, fetched for on-demand and latest-rate lookups. |
CurrencyAliases |
empty | Maps ISO codes to exchangerate.host symbol components where they differ. |
Dependency injection
The package ships its own AddExchangeRateHostExchangeRates registration in the
Bodu.Financial.ExchangeRates namespace - there is no separate *.DependencyInjection
package.
services
.AddFinancialService(configuration)
.AddExchangeRateHostExchangeRates(configuration, configure: o => o.ApiKey = "…");
Part of the Bodu utility library.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- Bodu.Core (>= 1.3.0)
- Bodu.Financial (>= 1.3.0)
- Bodu.Financial.DependencyInjection (>= 1.3.0)
- Bodu.Financial.ExchangeRates (>= 1.3.0)
- Bodu.Financial.ExchangeRates.DependencyInjection (>= 1.3.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Http (>= 10.0.12)
- Microsoft.Extensions.Http.Resilience (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Options (>= 10.0.12)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.12)
-
net8.0
- Bodu.Core (>= 1.3.0)
- Bodu.Financial (>= 1.3.0)
- Bodu.Financial.DependencyInjection (>= 1.3.0)
- Bodu.Financial.ExchangeRates (>= 1.3.0)
- Bodu.Financial.ExchangeRates.DependencyInjection (>= 1.3.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.1)
- Microsoft.Extensions.Http.Resilience (>= 8.10.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.