RobinTTY.NordigenApiClient
5.2.0
See the version list below for details.
dotnet add package RobinTTY.NordigenApiClient --version 5.2.0
NuGet\Install-Package RobinTTY.NordigenApiClient -Version 5.2.0
<PackageReference Include="RobinTTY.NordigenApiClient" Version="5.2.0" />
paket add RobinTTY.NordigenApiClient --version 5.2.0
#r "nuget: RobinTTY.NordigenApiClient, 5.2.0"
// Install RobinTTY.NordigenApiClient as a Cake Addin #addin nuget:?package=RobinTTY.NordigenApiClient&version=5.2.0 // Install RobinTTY.NordigenApiClient as a Cake Tool #tool nuget:?package=RobinTTY.NordigenApiClient&version=5.2.0
NordigenApiClient
This project provides a C# client for the Nordigen API. The project targets .NET 6/7 & .NET Standard 2.0 and supports the following endpoints of the API:
- Token
- Institutions
- Agreements
- Requisitions
- Accounts
Getting started
To get started install the package via the package manager:
Install-Package RobinTTY.NordigenApiClient
Next you need to create a new instance of the client:
using var httpClient = new HttpClient(); var credentials = new NordigenClientCredentials("my-secret-id", "my-secret-key"); var client = new NordigenClient(httpClient, credentials);
Note: The client will obtain the required JWT access/refresh token itself and manage it accordingly, for access/refresh token reuse see the advanced section.
You can now use the different endpoints through the client:
var response = await client.InstitutionsEndpoint.GetInstitutions(country: "GB");
The responses that are returned always have the same structure:
// If the request was successful "Result" will contain the returned data (Error will be null) if(response.IsSuccess){ var institutions = response.Result; institutions.ForEach(institution => Console.WriteLine(institution.Name)); } // If the request was not successful "Error" will contain the reason it failed (Result will be null) else Console.WriteLine(response.Error.Summary);
Getting balances and transactions for a bank account
Here is how you would go about retrieving the balances and transactions for a bank account (you can find this full example here):
Get a list of institutions in your country (e.g. Great Britain):
var institutionsResponse = await client.InstitutionsEndpoint.GetInstitutions(country: "GB"); if (institutionsResponse.IsSuccess) institutionsResponse.Result.ForEach(institution => { Console.WriteLine($"Institution: {institution.Name}, Id: {institution.Id}"); }); else Console.WriteLine($"Couldn't retrieve institutions, error: {institutionsResponse.Error.Summary}");
Choose the institution your bank account is registered with and create a requisition for it:
var institution = "BANK_OF_SCOTLAND_BOFSGBS1"; var userLanguage = "EN"; var reference = "your-internal-reference"; var redirect = new Uri("https://where-nordigen-will-redirect-after-authentication.com"); var requisitionRequest = new CreateRequisitionRequest(redirect, institution, reference, userLanguage); var requisitionResponse = await client.RequisitionsEndpoint.CreateRequisition(requisitionRequest); if (requisitionResponse.IsSuccess) { Console.WriteLine($"Requisition id: {requisitionResponse.Result.Id}"); Console.WriteLine($"Start authentication: {requisitionResponse.Result.AuthenticationLink}"); } else Console.WriteLine($"Requisition couldn't be created: {requisitionResponse.Error.Summary}");
You will now need to accept the end user agreement by following the authentication link. After that you will be able to retrieve the accounts linked to your bank account:
var requisitionId = "your-requisition-id"; var accountsResponse = await client.RequisitionsEndpoint.GetRequisition(requisitionId); if (accountsResponse.IsSuccess) accountsResponse.Result.Accounts.ForEach(accountId => { Console.WriteLine($"Account id: {accountId}"); }); else Console.WriteLine($"Accounts couldn't be retrieved: {accountsResponse.Error.Summary}");
Now you can retrieve details about the bank account and the balances/transactions:
var accountId = "your-account-id"; var bankAccountDetailsResponse = await client.AccountsEndpoint.GetAccountDetails(accountId); if (bankAccountDetailsResponse.IsSuccess) { Console.WriteLine($"IBAN: {bankAccountDetailsResponse.Result.Iban}"); Console.WriteLine($"Account name: {bankAccountDetailsResponse.Result.Name}"); } var balancesResponse = await client.AccountsEndpoint.GetBalances(accountId); if (balancesResponse.IsSuccess) balancesResponse.Result.ForEach(balance => { var balanceAmount = balance.BalanceAmount; Console.WriteLine($"Type: {balance.BalanceType}"); Console.WriteLine($"Balance: {balanceAmount.AmountParsed} {balanceAmount.Currency}"); }); var transactionsResponse = await client.AccountsEndpoint.GetTransactions(accountId); if (transactionsResponse.IsSuccess) transactionsResponse.Result.BookedTransactions.ForEach(transaction => { var transactionAmount = transaction.TransactionAmount; Console.WriteLine($"Remittance: {transaction.RemittanceInformationUnstructured}"); Console.WriteLine($"Booking date:{transaction.ValueDate}"); Console.WriteLine($"Amount: {transactionAmount.AmountParsed} {transactionAmount.Currency}"); });
Advanced Usage
Acess/Refresh Token reuse
If you wan't to persist the access/refresh token used by the client you can do so by accessing the JsonWebTokenPair
property of the client. After the first request that requires authentication this property will be populated with the access/refresh token that was automatically aquired.
Console.WriteLine(client.JsonWebTokenPair.AccessToken.EncodedToken);
Console.WriteLine(client.JsonWebTokenPair.RefreshToken.EncodedToken);
The next time you instantiate the client you can pass the access/refresh token to the client constructor:
using var httpClient = new HttpClient();
var credentials = new NordigenClientCredentials("my-secret-id", "my-secret-key");
var tokenPair = new JsonWebTokenPair("encoded-access-token", "encoded-refresh-token");
var client = new NordigenClient(httpClient, credentials, tokenPair);
The client will now use the given token pair and refresh it automatically if it is expired.
Alternatively you can also use the tokens endpoint directly:
var response = await client.TokenEndpoint.GetTokenPair();
if (response.IsSuccess)
{
Console.WriteLine($"Access token: {response.Result.AccessToken.EncodedToken}");
Console.WriteLine($"Refresh token: {response.Result.RefreshToken.EncodedToken}");
}
// Set the token pair on the client
client.JsonWebTokenPair = response.Result;
Getting notified when the Access/Refresh Token is updated
To get notified whenever the token pair is updated you can subscribe to the TokenPairUpdated
event:
client.TokenPairUpdated += OnTokenPairUpdated;
void OnTokenPairUpdated(object? sender, TokenPairUpdatedEventArgs e)
{
// The event args contain the updated token
Console.WriteLine("Updated token pair:");
Console.WriteLine($"Access Token: {e.JsonWebTokenPair!.AccessToken.EncodedToken}");
Console.WriteLine($"Refresh Token: {e.JsonWebTokenPair!.RefreshToken.EncodedToken}");
}
Usage with Frameworks older than .NET 6.0
If you use this library with .NET versions older than 6.0 you will receive warnings informing you that various dependencies of this packet don't necessarily support your chosen .NET version. The .NET Standard version of this package is tested against .NET Framework 4.8 and other versions (including .NET Core) should work fine as well. You can surpress those warnings by adding the following option to your csproj file:
<PropertyGroup>
...
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
...
</PropertyGroup>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. 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. |
-
.NETStandard 2.0
- Microsoft.IdentityModel.JsonWebTokens (>= 6.25.1)
- PolySharp (>= 1.10.0)
- System.Net.Http.Json (>= 7.0.0)
-
net6.0
- Microsoft.IdentityModel.JsonWebTokens (>= 6.25.1)
-
net7.0
- Microsoft.IdentityModel.JsonWebTokens (>= 6.25.1)
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 |
---|---|---|
10.1.0 | 609 | 8/19/2024 |
10.0.0 | 119 | 8/17/2024 |
9.0.0 | 224 | 5/16/2024 |
8.0.1 | 117 | 5/4/2024 |
8.0.0 | 111 | 4/27/2024 |
7.1.0 | 182 | 3/25/2024 |
7.0.0 | 505 | 2/22/2024 |
6.2.0 | 129 | 2/21/2024 |
6.1.3 | 113 | 2/21/2024 |
6.1.2 | 266 | 12/30/2023 |
6.1.1 | 363 | 11/9/2023 |
6.1.0 | 111 | 11/8/2023 |
6.0.6 | 403 | 9/27/2023 |
6.0.5 | 253 | 9/8/2023 |
6.0.4 | 244 | 7/31/2023 |
6.0.3 | 154 | 7/15/2023 |
6.0.2 | 240 | 5/27/2023 |
6.0.1 | 187 | 5/24/2023 |
6.0.0 | 146 | 5/22/2023 |
5.2.1 | 156 | 5/21/2023 |
5.2.0 | 126 | 5/13/2023 |
5.1.0 | 224 | 4/25/2023 |
5.0.1 | 161 | 4/24/2023 |
5.0.0 | 459 | 1/18/2023 |
4.0.2 | 303 | 12/23/2022 |
3.0.0 | 332 | 12/16/2022 |
2.0.3 | 323 | 12/9/2022 |
2.0.2 | 299 | 12/9/2022 |
2.0.1 | 295 | 12/9/2022 |
2.0.0 | 296 | 12/8/2022 |
1.0.0 | 359 | 8/10/2022 |
Improved the static code analysis for the NordigenApiResponse class.
The compiler can now analyze whether the "Result" and "Error" properties may be null or are not-null depending on the "IsSuccess" property.
For more information see: https://github.com/RobinTTY/NordigenApiClient/releases/tag/v5.2.0