CNB.cz .NET Standard 2.0 Library (netstandard2.0). By ČNB
- Daily Exchange Rates [documentation. Uses public plain-text API - CSV]
- Bank codes [plain-text API - CSV]
Supports
- Dependency injection by IHttpClientFactory
- CurrencyCode as enum (Generator project included)
- direct query for exchange-rate by ExchangeRateCode
Dependency injection
More in CNB.Tests project, file: TestFixture.cs and BasicTest.cs.
// DI configuration
services.AddHttpClient();
services.AddScoped<CnbClient>();
// in constructor
_cnb = test.Services.GetRequiredService<CnbClient>();
Using
// return decimal value of Exchange rate for EUR
await _cnb.ExchangeRateCode(CurrencyCode.EUR);
// return all Exchange rates
await _cnb.ExchangeRateAll();
// return all Bank codes
await _cnb.BankCodeAll();
ExchangeRate.cs contains:
- Country - country name (in Czech)
- CurrencyName - currency name (in Czech)
- Amount - currency amount (example: 1, 100)
- Code - currency code (as string; example: EUR, USD, ...)
- Rate - exchange rate (as decimal; example: 25.877)
- CurrencyCode - code (as nullable enum; example: CurrencyCode.EUR, CurrencyCode.GBR, ...)
BankCode.cs contains:
- Code - bank code
- Name - bank name (in Czech)
- BIC - BIC (SWIFT)
- CERTIS - CERTIS