Frankfurter.API.Client.DependencyInjection 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Frankfurter.API.Client.DependencyInjection --version 1.1.0                
NuGet\Install-Package Frankfurter.API.Client.DependencyInjection -Version 1.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Frankfurter.API.Client.DependencyInjection" Version="1.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Frankfurter.API.Client.DependencyInjection --version 1.1.0                
#r "nuget: Frankfurter.API.Client.DependencyInjection, 1.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Frankfurter.API.Client.DependencyInjection as a Cake Addin
#addin nuget:?package=Frankfurter.API.Client.DependencyInjection&version=1.1.0

// Install Frankfurter.API.Client.DependencyInjection as a Cake Tool
#tool nuget:?package=Frankfurter.API.Client.DependencyInjection&version=1.1.0                

Frankfurter .NET API Client

Tests CI

Introduction

The Frankfurter API is a powerful currency conversion API that allows you to retrieve up-to-date currency exchange rates for over 30 different currencies. With this .NET API client, you can easily integrate the Frankfurter API into your .NET applications and start converting currencies with just a few lines of code.

This API client is designed to make it simple and easy for developers to interact with the Frankfurter API. It provides a simple and intuitive interface that abstracts away the details of the underlying HTTP requests and responses, allowing you to focus on building great applications.

The client is built using the latest .NET technologies and follows modern best practices for software development. It is fully open source and actively maintained by a team of experienced developers, so you can be sure that it will be reliable, well-documented, and up-to-date with the latest features and bug fixes.

Whether you're building a financial application, a travel app, or any other type of application that needs currency conversion functionality, this .NET API client for the Frankfurter API is the perfect tool to get the job done quickly and easily.

Packages

Package Version Downloads Workflow
Frankfurter.API.Client NuGet Version NuGet Downloads Deploy
Frankfurter.API.Client.DependencyInjection NuGet Version NuGet Downloads Deploy

Domain

Here I am going to explain the entities containning on this API client. In this solution we not only wraps the API, but we shape the data in a way that is going to be easier to use:

  • <b>Currency</b>:Represents a currency, with its own enum code and name. Its a more informative thing;
  • <b>CurrencyCode</b>: Where we store all avaliable currencies codes, in that way developers can know what currencies are currently avaliable;
  • <b>Exchange</b>: Represents a exchange from a currency to multiple others;
  • <b>CurrencyRate</b>: Is just used inside the <i>Exchange</i> entity, where we represent the result of a conversion of a currency to another.

Avaliable Currencies

Currency Code Name
AUD Australian Dollar
BGN Bulgarian Lev
BRL Brazilian Real
CAD Canadian Dollar
CHF Swiss Franc
CNY Chinese Renminbi Yuan
CZK Czech Koruna
DKK Danish Kron
EUR Euro
GBP British Pound
HKD Hong Kong Dollar
HUF Hungarian Forint
IDR Indonesian Rupiah
ILS Israeli New Sheqel
INR Indian Rupee
ISK Icelandic Króna
JPY Japanese Ye
KRW South Korean Won
MXN Mexican Peso
MYR Malaysian Ringgit
NOK Norwegian Krone
NZD New Zealand Dollar
PHP Philippine Peso
PLN Polish Złoty
RON Romanian Leu
SEK Swedish Krona
SGD Singapore Dollar
THB Thai Baht
TRY Turkish Lira
USD United States Dollar
ZAR South African Rand

Note: We just wrap the API, so the currencies missing must be added on the Frankfurter API. We just consume its data.

Methods

  1. <b>GetAllAvaliableCurrenciesAsync</b>: Returns all the currently avaliable currencies on the API
var currencies = await frankfurter
    .GetAllAvaliableCurrenciesAsync()
    .ConfigureAwait(false);
  1. <b>CurrencyConvertAsync</b>: Do a currency convertion to a currency to another using a base amount.
var exchange = await frankfurter
    .CurrencyConvertAsync(
        10, // Reference Amount
        CurrencyCode.BRL, // Reference Currency
        CurrencyCode.USD // Currency to Convert
    ).ConfigureAwait(false);
  1. <b>CurrencyConvertByDateAsync</b>: Do a currency convertion to a currency to another using a base amount and a base date.
var exchange = await frankfurter
    .CurrencyConvertByDateAsync(
        DateTime.UtcNow, // Reference Date
        10, // Reference Amount
        CurrencyCode.BRL // Reference Currency
    ).ConfigureAwait(false);
  1. <b>CurrencyConvertByLastPublishedDateAsync</b>: Do a currency convertion to a currency to another using a base amount on the last published date;
var exchange = await frankfurter
    .CurrencyConvertByLastPublishedDateAsync(
        10, // Reference Amount
        CurrencyCode.BRL // Reference Currency
    ).ConfigureAwait(false);

this method returns the conversation for all avaliable currencies. You can pass an extra parameter and do the conversion only for the currencies that you want:

var toCurrencies = new List<CurrencyCode>
{
    CurrencyCode.EUR,
    CurrencyCode.USD
};

var exchange = await frankfurter
    .CurrencyConvertByLastPublishedDateAsync(
        10, // Reference Amount
        CurrencyCode.BRL, // Reference Currency
        toCurrencies // Currencies to convert
    ).ConfigureAwait(false);

  1. <b>CurrencyConvertByDateIntervalAsync</b>: Do a currency convertion to a currency to another using a base amount on a date interval;
var toCurrencies = new List<CurrencyCode>
{
    CurrencyCode.EUR,
    CurrencyCode.USD
};

var exchanges = await frankfurter
    .CurrencyConvertByDateIntervalAsync(
        10, // Reference Amount
        CurrencyCode.BRL, // Reference Currency
        toCurrencies, // Currencies to convert
        new DateTime(2020,1,1), // Start date
        new DateTime(2021,1,1) // End Date
    ).ConfigureAwait(false);

Configuration

This Api integration is ver simple, there is no authentication/authorization requirements, you can use it with almost no configurations.

You can instanciate this client in three different ways:

  1. Using default configs: This uses the default baseUrl, timeout and Throw on any error flag.
var frankfurter = new FrankfurterClient();

or by dependency injection:

services.AddFrankfurterApiClient();

2.Only configurating the API base url:

var frankfurter = new FrankfurterClient(baseUrl);

or by dependency injection:

services.AddFrankfurterApiClient(baseUrl);

3.And setup manually all configurations with your preferences:


var configuration = new FrankfurterClientConfiguration
{
  BaseApiUrl = baseUrl,
  MaxTimeout = 5000,
  ThrowOnAnyError = true
};

var frankfurter = new FrankfurterClient(configuration);

or by dependency injection:


var configuration = new FrankfurterClientConfiguration
{
  BaseApiUrl = baseUrl,
  MaxTimeout = 5000,
  ThrowOnAnyError = true
};

services.AddFrankfurterApiClient(configuration);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.5.0 163 5/19/2023
1.1.0 148 5/12/2023
1.0.0 158 5/1/2023