CurrencyLayer4NET 2.0.1

dotnet add package CurrencyLayer4NET --version 2.0.1                
NuGet\Install-Package CurrencyLayer4NET -Version 2.0.1                
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="CurrencyLayer4NET" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CurrencyLayer4NET --version 2.0.1                
#r "nuget: CurrencyLayer4NET, 2.0.1"                
#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 CurrencyLayer4NET as a Cake Addin
#addin nuget:?package=CurrencyLayer4NET&version=2.0.1

// Install CurrencyLayer4NET as a Cake Tool
#tool nuget:?package=CurrencyLayer4NET&version=2.0.1                

CurrencyLayer4NET: A .NET library for CurrencyLayer API

NuGet Apache 2

CurrencyLayer4NET is a .NET library that makes it easier to do API calls to CurrencyLayer.com.

Using CurrencyLayer4NET

CurrencyLayer4NET provides 3 different levels of how you can make CurrencyLayer API calls: CLClient, CLManager, CLQueryBuilder.

CLClient

This is high-level class that operates its own entities like Currency, Quote, etc. For example, getting all currencies looks like that:

ICLClient clClient = new CLClient("YOUR_API_ACCESS_KEY");
IEnumerable<Currency> currencies = clClient.GetCurrencies();

Getting currencies exchange rates:

Currency eur = Currency.FromCode("EUR");
Currency cad = Currency.FromCode("CAD");

ICLClient clClient = new CLClient("YOUR_API_ACCESS_KEY");
IEnumerable<Quote> quotes = clClient.GetRates(new[] { eur, usd });
// or
IEnumerable<Quote> quotes = clClient.GetRates(new[] { "EUR", "USD" });

Pros:

  • You can operate simple objects

Cons:

  • Some methods are not implemented
  • Async methods not implemented

CLManager

This is low-level class that operates entities that are nearly exactly repeat CurrencyLayer API responses structure (CLCurrenciesResponse, CLQuotesResponse, etc). Getting all currencies looks like that:

ICLManager manager = new CLManager("YOUR_API_ACCESS_KEY");
CLCurrenciesResponse response = manager.GetCurrencies();

foreach (var currency in response.Currencies){
	Console.WriteLine($"Currency Code: {currency.Key}, Currency Name: {currency.Value}");
}

Pros:

  • Full support of CurrencyLayer API endpoints
  • Async methods are available

Cons:

  • Low-level response objects
  • JSONP Callback Function feature missing

CLQueryBuilder

This is low-level class that allows building and executing queries to CurrencyLayer API. This class operates the same response entities as CLManager does (CLCurrenciesResponse, CLQuotesResponse, etc). Getting all currencies looks like that:

CLCurrenciesResponse response = CLQueryBuilder.
                Create(Endpoints.CURRENCIES).
                GetResult<CLCurrenciesResponse>();

To request quotes for specified currencies, you can do this:

CLQuotesResponse response = CLQueryBuilder.
                Create(Endpoints.RATES).
                SetAccessKey("YOUR_API_ACCESS_KEY").
				SetCurrencies(new[] { "EUR", "GBP" }).
                GetResult<CLQuotesResponse>();

JSONP Callback function feature:

string response = CLQueryBuilder.
                Create(Endpoints.CURRENCIES).
                AddParameter("callback", "test_callback").
                GetResponse();

Pros:

  • Full support of CurrencyLayer API endpoints and features
  • Async methods are available

Cons:

  • Low-level response objects
  • In fact you build query manually, so you possibly will need to look at documentation to get the exact parameters for the query you want to make

Running Tests

In order to run Unit Tests you should perform the following simple steps:

  • If you do not have a CurrencyLayer account, sign up. If you already have the account, sign in.
  • You will need an API Access Key. You can find it on your Dashboard.
  • Open CurrencyLayerNET.Tests.TestConfiguration class.
  • Replace ApiAccessKey property value to your API Access Key.
  • Replace Plan enum property value to the corresponding Plan of your CurrencyLayer subscription plan. Example:
public static string ApiAccessKey { get; set; } = "b69242edc1d371e395060d3f414870d2";
public static Plan Plan { get; set; } = Plan.Professional;

Note: some of Unit Tests depend on your account subscription plan. So if you will set wrong Plan, some tests may fail.

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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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
2.0.1 4,659 8/18/2019
1.0.0 2,305 2/19/2019

Added support for .NET Core 2.2 and .NET Standard 2.0