MarkZither.KimaiDotNet.ApiClient 1.0.0

dotnet add package MarkZither.KimaiDotNet.ApiClient --version 1.0.0
                    
NuGet\Install-Package MarkZither.KimaiDotNet.ApiClient -Version 1.0.0
                    
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="MarkZither.KimaiDotNet.ApiClient" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkZither.KimaiDotNet.ApiClient" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MarkZither.KimaiDotNet.ApiClient" />
                    
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 MarkZither.KimaiDotNet.ApiClient --version 1.0.0
                    
#r "nuget: MarkZither.KimaiDotNet.ApiClient, 1.0.0"
                    
#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 MarkZither.KimaiDotNet.ApiClient@1.0.0
                    
#: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=MarkZither.KimaiDotNet.ApiClient&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MarkZither.KimaiDotNet.ApiClient&version=1.0.0
                    
Install as a Cake Tool

KimaiDotNet

A .NET client library for the Kimai time-tracking REST API.

NuGet CI License: MIT

Overview

MarkZither.KimaiDotNet.ApiClient is a strongly-typed C# client for the Kimai API, generated from the Kimai OpenAPI 3.0 specification using Microsoft Kiota. It targets netstandard2.0 and works with .NET 6+, .NET Framework 4.6.2+, and any platform that supports .NET Standard 2.0.

Breaking change in v1.0.0-beta1: The client was re-generated with Microsoft Kiota (replacing AutoRest). The API surface has changed significantly. See the migration guide below.

Installation

dotnet add package MarkZither.KimaiDotNet.ApiClient

Quick Start

Kimai uses token-based authentication. Pass your username and API token via custom HTTP headers.

using MarkZither.KimaiDotNet;
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using System.Net.Http;

// Configure the HttpClient with auth headers
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("X-AUTH-USER", "your-username");
httpClient.DefaultRequestHeaders.Add("X-AUTH-TOKEN", "your-api-token");

// Build the Kiota adapter and client
var adapter = new HttpClientRequestAdapter(new AnonymousAuthenticationProvider(), httpClient: httpClient);
adapter.BaseUrl = "https://your-kimai-server.example.com";

var client = new KimaiClient(adapter);

// Get server version
var version = await client.Api.Version.GetAsync();
Console.WriteLine($"Kimai version: {version?.Version}");

// List activities
var activities = await client.Api.Activities.GetAsync();
foreach (var activity in activities ?? [])
{
    Console.WriteLine($"  {activity.Id}: {activity.Name}");
}

// Get the current user
var me = await client.Api.Users.Me.GetAsync();
Console.WriteLine($"Logged in as: {me?.Username}");

Authentication

Kimai supports two header-based auth schemes:

Header Value
X-AUTH-USER Your Kimai username
X-AUTH-TOKEN API token from your Kimai profile

Available Endpoints

The client exposes all Kimai API routes via a fluent builder pattern under client.Api.*:

Namespace Description
client.Api.Activities List, create, get by id, update, rates
client.Api.Projects List, create, get by id, update, rates
client.Api.Customers List, create, get by id, update, rates
client.Api.Timesheets List, create, get by id, stop, restart, export
client.Api.Users List, get by id, Me (current user)
client.Api.Teams List, create, manage members and permissions
client.Api.Tags List, create, delete
client.Api.Config.Timesheet Timesheet configuration
client.Api.Version Server version info
client.Api.Ping Health check

Creating Resources

Kiota models use object-initializer syntax:

using MarkZither.KimaiDotNet.Models;

var newActivity = new ActivityEditForm
{
    Name = "My Activity",
    Comment = "Optional description",
    Visible = true
};

var created = await client.Api.Activities.PostAsync(newActivity);
Console.WriteLine($"Created activity id: {created?.Id}");

Error Handling

Kiota throws Microsoft.Kiota.Abstractions.ApiException on non-2xx responses:

using Microsoft.Kiota.Abstractions;

try
{
    var activity = await client.Api.Activities["123"].GetAsync();
}
catch (ApiException ex)
{
    Console.WriteLine($"API error {ex.ResponseStatusCode}: {ex.Message}");
}

Migrating from v0.4.x

v1.0.0-beta1 replaces the AutoRest-generated client with a Kiota-generated one. Key differences:

v0.4.x (AutoRest) v1.0.0-beta1 (Kiota)
new Kimai2APIDocs(httpClient, false) new KimaiClient(adapter)
docs.ListActivitiesUsingGetWithHttpMessagesAsync() client.Api.Activities.GetAsync()
response.Body / response.Response.IsSuccessStatusCode Direct return value / throws ApiException
new ActivityEditForm("name", ...) new ActivityEditForm { Name = "name", ... }
version.VersionProperty version.Version
version.Name / version.Semver version.Version / version.VersionId
client.GetCurrentUserLocale...() Removed (endpoint no longer in Kimai API)

Versioning

Releases follow Semantic Versioning. NuGet packages are published automatically when a v* tag is pushed to the repository.

To publish a new release:

git tag v1.0.0-beta1
git push origin v1.0.0-beta1

Regenerating the Client

The client is generated from docs/document.json (the Kimai OpenAPI 3.0 spec) using Microsoft Kiota.

Install the Kiota tool:

dotnet tool install --global Microsoft.OpenApi.Kiota

Regenerate from the repo root:

kiota generate \
  --language CSharp \
  --class-name KimaiClient \
  --namespace-name MarkZither.KimaiDotNet \
  --openapi docs/document.json \
  --output src/KimaiDotNet.Core \
  --exclude-backward-compatible \
  --clean-output

After regenerating, update the descriptionLocation in src/KimaiDotNet.Core/kiota-lock.json if the path to document.json has changed.

Building from Source

dotnet restore
dotnet build -c Release
dotnet test

License

MIT

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.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. 
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
1.0.0 66 5/30/2026
1.0.0-beta1 70 5/27/2026
0.4.0-beta0001 459 9/11/2021
0.3.0-beta0001 450 8/5/2021
0.2.1 642 8/1/2021
0.2.0 496 8/1/2021
0.2.0-beta 437 8/1/2021
0.1.0 630 12/15/2020