Endjin.FreeAgent.Client 1.0.0-preview.2

This is a prerelease version of Endjin.FreeAgent.Client.
dotnet add package Endjin.FreeAgent.Client --version 1.0.0-preview.2
                    
NuGet\Install-Package Endjin.FreeAgent.Client -Version 1.0.0-preview.2
                    
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="Endjin.FreeAgent.Client" Version="1.0.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Endjin.FreeAgent.Client" Version="1.0.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="Endjin.FreeAgent.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Endjin.FreeAgent.Client --version 1.0.0-preview.2
                    
#r "nuget: Endjin.FreeAgent.Client, 1.0.0-preview.2"
                    
#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.
#:package Endjin.FreeAgent.Client@1.0.0-preview.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Endjin.FreeAgent.Client&version=1.0.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Endjin.FreeAgent.Client&version=1.0.0-preview.2&prerelease
                    
Install as a Cake Tool

Endjin.FreeAgent.Client

A comprehensive .NET client library for the FreeAgent accounting API, providing strongly-typed access to all FreeAgent resources.

Features

  • Strongly-typed models for all FreeAgent API resources
  • Modern .NET 10 implementation with C# 14 features
  • Async/await support throughout
  • Built-in caching for improved performance
  • OAuth2 authentication support
  • Comprehensive resource coverage including:
    • Invoices and Credit Notes
    • Contacts and Projects
    • Expenses and Bills
    • Bank Accounts and Transactions
    • Timeslips and Tasks
    • VAT Returns
    • Users and Company settings
    • And much more...

Installation

Install via NuGet Package Manager:

dotnet add package Endjin.FreeAgent.Client

Or via Package Manager Console:

Install-Package Endjin.FreeAgent.Client

Quick Start

Configuration

using Endjin.FreeAgent.Client;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;

// Configure services
ServiceCollection services = new();
services.AddMemoryCache();
services.AddHttpClient();
services.AddLogging();

// Configure FreeAgent options
FreeAgentOptions options = new()
{
    ClientId = "your-client-id",
    ClientSecret = "your-client-secret",
    RedirectUri = "your-redirect-uri"
};

// Create client
ServiceProvider serviceProvider = services.BuildServiceProvider();
IMemoryCache cache = serviceProvider.GetRequiredService<IMemoryCache>();
IHttpClientFactory httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
ILoggerFactory loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();

FreeAgentClient client = new(options, cache, httpClientFactory, loggerFactory);
await client.InitializeAndAuthorizeAsync();

Basic Usage

using Endjin.FreeAgent.Domain;

// Get all active projects
IEnumerable<Project> projects = await client.Projects.GetAllActiveAsync();

// Get all contacts
IEnumerable<Contact> contacts = await client.Contacts.GetAllAsync();

// Create an invoice
Invoice invoice = new()
{
    Contact = "https://api.freeagent.com/v2/contacts/123",
    DatedOn = DateOnly.FromDateTime(DateTime.Now),
    PaymentTermsInDays = 30,
    InvoiceItems = new List<InvoiceItem>
    {
        new()
        {
            Description = "Consulting Services",
            ItemType = "Services",
            Quantity = 1,
            Price = 1000.00m
        }
    }
};

Invoice createdInvoice = await client.Invoices.CreateAsync(invoice);

// Get timeslips for a project
IEnumerable<Timeslip> timeslips = await client.Timeslips.GetByProjectUrlAsync("https://api.freeagent.com/v2/projects/456");

Advanced Features

Caching

The client includes built-in memory caching with configurable expiration:

// Cache is automatically used for GET operations
IEnumerable<Project> projects1 = await client.Projects.GetAllAsync(); // Fetches from API
IEnumerable<Project> projects2 = await client.Projects.GetAllAsync(); // Returns cached result

Error Handling

The client provides detailed error information for API failures:

try
{
    Invoice invoice = await client.Invoices.GetByIdAsync("invalid-id");
}
catch (HttpRequestException ex)
{
    // Handle API errors
    Console.WriteLine($"API Error: {ex.Message}");
}

Requirements

  • .NET 10.0 or later
  • FreeAgent API credentials (Client ID, Client Secret)
  • Active FreeAgent account

Documentation

For complete API documentation, visit the FreeAgent API Documentation.

Contributing

We welcome contributions! Please feel free to submit issues and pull requests.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Support

For support, please contact Endjin Limited or raise an issue on our GitHub repository.


Copyright (c) Endjin Limited. All rights reserved.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Endjin.FreeAgent.Client:

Package Downloads
Endjin.FreeAgent.Client.Extensions

Extension methods and additional functionality for the Endjin.FreeAgent.Client library, providing timesheets management, project filtering, user settings, and activity summaries. This is a preview release targeting .NET 10.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-preview.2 122 9/23/2025

Preview release of the Endjin FreeAgent Client library targeting .NET 10 RC. This package will be updated to stable once .NET 10 is officially released.