![]() |
VOOZH | about |
dotnet add package Tildom.Libraries.Xero --version 9.0.0
NuGet\Install-Package Tildom.Libraries.Xero -Version 9.0.0
<PackageReference Include="Tildom.Libraries.Xero" Version="9.0.0" />
<PackageVersion Include="Tildom.Libraries.Xero" Version="9.0.0" />Directory.Packages.props
<PackageReference Include="Tildom.Libraries.Xero" />Project file
paket add Tildom.Libraries.Xero --version 9.0.0
#r "nuget: Tildom.Libraries.Xero, 9.0.0"
#:package Tildom.Libraries.Xero@9.0.0
#addin nuget:?package=Tildom.Libraries.Xero&version=9.0.0Install as a Cake Addin
#tool nuget:?package=Tildom.Libraries.Xero&version=9.0.0Install as a Cake Tool
A C# library that provides a simplified interface for interacting with Xero's Accounting APIs. This library wraps the official Xero.NetStandard.OAuth2 package to provide a more streamlined experience for reading data from Xero.
Install the package via NuGet:
Install-Package Tildom.Libraries.Xero
Or using the .NET CLI:
dotnet add package Tildom.Libraries.Xero
using Microsoft.Extensions.DependencyInjection;
using Tildom.Libraries.Xero.Configuration;
using Tildom.Libraries.Xero.Services;
public void ConfigureServices(IServiceCollection services)
{
// With default settings
services.AddXeroServices(options => {
options.ClientId = "YOUR_CLIENT_ID";
options.ClientSecret = "YOUR_CLIENT_SECRET";
});
// With custom settings
services.AddXeroServices(
// Configure Xero API credentials
options => {
options.ClientId = "YOUR_CLIENT_ID";
options.ClientSecret = "YOUR_CLIENT_SECRET";
},
// Configure token caching (default is true)
useTokenCaching: true,
// Configure retry policy
configureRetryPolicy: options => {
options.MaxRetryAttempts = 5; // Default: 3
options.InitialDelayMilliseconds = 2000; // Default: 1000
options.DelayFactor = 1.5; // Default: 2.0
options.MaxDelayMilliseconds = 60000; // Default: 30000
options.UseJitter = true; // Default: true
});
}
using Tildom.Libraries.Xero.Interfaces;
using Tildom.Libraries.Xero.Queries;
public class YourService
{
private readonly IXeroRepository _xeroRepository;
public YourService(IXeroRepository xeroRepository)
{
_xeroRepository = xeroRepository;
}
public async Task<List<Invoice>> GetInvoicesAsync(string tenantId)
{
var query = new XeroApiQueryBuilder
{
XeroTenantId = tenantId,
Where = "Status=='AUTHORISED'",
Order = "Date DESC"
};
return await _xeroRepository.GetInvoicesAsync(query);
}
}
The library provides access to the following Xero data entities:
GetInvoicesAsync - Get a list of invoicesGetInvoiceAsync - Get a specific invoice by IDGetCreditNotesAsync - Get a list of credit notesGetCreditNoteAsync - Get a specific credit note by IDGetAccountsAsync - Get a list of accountsGetAccountAsync - Get a specific account by IDGetBankTransactionsAsync - Get a list of bank transactionsGetBankTransactionAsync - Get a specific bank transaction by IDGetBankTransfersAsync - Get a list of bank transfersGetBankTransferAsync - Get a specific bank transfer by IDGetContactsAsync - Get a list of contactsGetContactAsync - Get a specific contact by IDGetItemsAsync - Get a list of itemsGetItemAsync - Get a specific item by IDGetManualJournalsAsync - Get a list of manual journalsGetManualJournalAsync - Get a specific manual journal by IDGetPaymentsAsync - Get a list of paymentsGetPaymentAsync - Get a specific payment by IDGetTrackingCategoriesAsync - Get a list of tracking categoriesGetTaxRatesAsync - Get a list of tax ratesGetOrganizationsAsync - Get a list of organizationsGetCurrenciesAsync - Get a list of currenciesGetJournalsAsync - Get a list of journalsGetJournalAsync - Get a specific journal by IDGetReportProfitAndLossAsync - Get a profit and loss reportGetReportBalanceSheetAsync - Get a balance sheet reportBy default, the library uses token caching to improve performance. This means that it will only request a new token from Xero when the current token expires. This reduces the number of API calls and improves performance.
You can control token caching behavior when registering the services:
// Enable token caching (default)
services.AddXeroServices(options => {
options.ClientId = "YOUR_CLIENT_ID";
options.ClientSecret = "YOUR_CLIENT_SECRET";
}, useTokenCaching: true);
// Disable token caching
services.AddXeroServices(options => {
options.ClientId = "YOUR_CLIENT_ID";
options.ClientSecret = "YOUR_CLIENT_SECRET";
}, useTokenCaching: false);
You can also manually manage the token cache using the IXeroTokenProvider interface:
public class YourService
{
private readonly IXeroTokenProvider _tokenProvider;
public YourService(IXeroTokenProvider tokenProvider)
{
_tokenProvider = tokenProvider;
}
public async Task DoSomethingAsync()
{
// Force a token refresh
var token = await _tokenProvider.RefreshTokenAsync();
// Clear the token cache
_tokenProvider.ClearTokenCache();
}
}
The library includes built-in retry logic to handle transient failures when communicating with the Xero API. This makes your application more resilient to temporary network issues, rate limiting, and other transient errors.
The following types of errors will trigger a retry:
The library includes built-in rate limiting to prevent hitting Xero API rate limits. This ensures that your application doesn't exceed the allowed number of requests per minute and handles rate limiting responses gracefully.
You can configure both the retry policy and rate limits when registering the services:
services.AddXeroServices(
options => {
options.ClientId = "YOUR_CLIENT_ID";
options.ClientSecret = "YOUR_CLIENT_SECRET";
},
useTokenCaching: true,
configureRetryPolicy: options => {
options.MaxRetryAttempts = 5; // Maximum number of retry attempts (default: 3)
options.InitialDelayMilliseconds = 2000; // Initial delay between retries in ms (default: 1000)
options.DelayFactor = 1.5; // Factor by which delay increases (default: 2.0)
options.MaxDelayMilliseconds = 60000; // Maximum delay between retries in ms (default: 30000)
options.UseJitter = true; // Add randomness to delay to prevent thundering herd (default: true)
options.RetryableStatusCodes = new[] { 408, 429, 500, 502, 503, 504 }; // HTTP status codes that trigger retry
},
configureRateLimits: options => {
options.RequestsPerMinute = 60; // Maximum requests per minute (default: 60)
options.MaxConcurrentRequests = 10; // Maximum concurrent requests (default: 10)
options.DefaultRetryAfterMs = 2000; // Default wait time when rate limited (default: 2000)
options.AutoAdjustRateLimits = true; // Automatically adjust rate limits based on API responses (default: true)
options.RateLimitBufferPercentage = 20; // Buffer percentage to apply to rate limits (default: 20)
});
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.0.0 | 310 | 4/9/2025 |
| 8.0.2-alpha | 184 | 3/29/2025 |