This is a dotnet standard library providing a thin wrapper around the Freshdesk API as described here: https://developers.freshdesk.com/api.
At present this library requires .NET Standard 2.1 (for IAsyncEnumerable), if I get interest then I'll build a version of the library which doesn't make use of that feature and is therefore available in .NET Standard 2.0 (or possibly lower)
This library provides a single client class which can be created in one of several ways:
- No existing HttpClient object (suitable for console applications)
using var freshdeskHttpClient = FreshdeskHttpClient.Create("https://mydomain.freshdesk.com", "APIKEY");
var freshdeskClient = FreshdeskClient.Create(freshdeskHttpClient);
NOTE: Disposing the freshdeskClient will dispose the HttpClient object, as per https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/ you need to be careful when disposing HttpClient objects. Broadly speaking, don't make and dispose lots of FreshdeskClient objects using this model.
- Existing HttpClient object (suitable for asp.net applications or cases where you want more control over the HttpClient)
var freshdeskHttpClient = new FreshdeskHttpClient(myHttpClient);
var freshdeskClient = FreshdeskClient.Create(freshdeskHttpClient);
NOTE: Typically you don't want to dispose the freshdesk client in this case.
- Using
Microsoft.Extensions.DependencyInjection
using FreshdeskApi.Client.Extensions;
serviceCollection
.AddFreshdeskApiClient()
.Configure(options => {
options.FreshdeskDomain = "https://<mydomain>.freshdesk.com";
options.ApiKey = "APIKEY";
});
...
container.GetRequiredService<IFreshdeskClient>();
container.GetRequiredService<IFreshdeskTicketClient>();
container.GetRequiredService<IFreshdesk...Client>();
Get a single ticket, including the company information on the API response
using var freshdeskHttpClient = new FreshdeskHttpClient("https://mydomain.freshdesk.com", "APIKEY");
var freshdeskTicketClient = new FreshdeskTicketClient(freshdeskHttpClient);
var ticket = await freshdeskTicketClient.ViewTicketAsync(
ticketId: 12345,
includes: new TicketIncludes { Company = true }
);
Not all of the Freshdesk API is covered, this table illustrates the current status of coverage by this library. Pull requests to add additional features are welcome.
API Area | Coverage |
---|---|
Tickets | ✔️ |
Ticket Fields | ✔️ |
Conversations | ✔️ |
Contacts | ✔️ |
Agents | ✔️ |
Skills | ❌ |
Roles | ✔️ |
Groups | ✔️ |
Companies | ✔️ |
Canned Responses | ✔️ (read only) |
Discussions | ❌ |
Solutions | ✔️ |
Surveys | ❌ |
Satisfaction Ratings | ❌ |
Field Service Management | ❌ |
Time Entries | ❌ |
Email Configs | ❌ |
Email Mailboxes | ❌ |
Products | ✔️ |
Business Hours | ❌ |
Scenario Automations | ❌ |
SLA Policies | ❌ |
Settings | ❌ |
Custom Objects | ✔️ |
The library utilises C#11 features and therefore VS2022 or a suitable text editor are required for making changes.
Please feel free to send pull requests or raise Github issues.