Skip to main content
.NETStandard2.0

A .NET client library for the Kimai time-tracking REST API, generated with Microsoft Kiota from the OpenAPI 3.0 specification.

Published
May 27, 2026
4mo ago
Total Downloads
3.5K
3,468

Install

dotnet add package MarkZither.KimaiDotNet.ApiClient --version 1.0.0-beta1
ProductVersions
.NET Standard
netstandard2.0

README

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

Changes from Previous Version

v0.4.0-beta0001v1.0.0-beta1
Added Dependencies
Microsoft.Kiota.Bundle(.NETStandard2.0)
Removed Dependencies
Newtonsoft.Json(.NETStandard2.0)
Polly(.NETStandard2.0)
Polly.Extensions.Http(.NETStandard2.0)

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.