SKitLs.ClientsApi.Core 1.0.1

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

SKitLs.ClientsApi.Core

Lightweight base library for building JSON-based HTTP API clients on top of HttpClient.

The goal of this project is to remove boilerplate code when implementing API clients, while keeping behavior explicit, predictable and easy to customize.


Features

  • Unified HTTP request pipeline
  • Built-in JSON serialization and deserialization
  • Automatic query string building from DTOs or dictionaries
  • Consistent error handling via ApiException
  • Minimal abstractions, no framework-level magic
  • Fully testable without real HTTP calls

When to use

This library is a good fit if you:

  • write multiple HTTP API clients
  • want consistent error handling and serialization
  • prefer explicit code over heavy frameworks
  • want full control over HttpClient configuration

This is not a REST framework and does not rely on code generation or reflection-based routing.


Basic usage

1. Create a client

public sealed class MyApiClient : JsonApiClientBase
{
    protected override void ConfigureHttpClient(HttpClient client)
    {
        client.BaseAddress = new Uri("https://api.example.com/");
        client.DefaultRequestHeaders.Authorization =
            new AuthenticationHeaderValue("Bearer", "token");
    }

    public Task<UserDto?> GetUser(int id, CancellationToken ct = default)
        => GetAsync<UserDto>($"users/{id}", ct: ct);

    public Task<UserDto?> CreateUser(CreateUserDto dto, CancellationToken ct = default)
        => PostAsync<CreateUserDto, UserDto>("users", dto, ct: ct);
}

Query parameters

Query parameters can be provided as an object or a dictionary (Dictionary<string, object?>).

DTO-based query

var users = await client.GetAsync<UserDto[]>(
    "users",
    new { page = 1, pageSize = 20 });

Dictionary-based query

var users = await client.GetAsync<UserDto[]>(
    "users",
    new Dictionary<string, object>
    {
        ["status"] = "active",
        ["page"] = 2
    });

Null values are ignored automatically.


Error handling

Non-success HTTP responses result in an ApiException:

try
{
    await client.GetAsync<UserDto>("users/unknown");
}
catch (ApiException ex)
{
    Console.WriteLine(ex.StatusCode);
    Console.WriteLine(ex.RequestUri);
    Console.WriteLine(ex.RawResponse);
}

Customization points

You can override the following methods to customize behavior:

  • ConfigureHttpClient
  • CreateSerializer
  • BuildRequestUri
  • BuildQueryString
  • OnBeforeSendAsync
  • OnAfterResponseAsync
  • CreateApiExceptionAsync

Design principles

  • Explicit over implicit
  • No hidden retries or policies
  • No dependency on DI frameworks
  • Minimal surface area
  • Easy to reason about and debug

License

MIT Copyright (c) 2026 SKitLs

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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.1 92 2/12/2026
1.0.0 98 1/13/2026

(+) IApiSerializer: Added JsonSerializerOptions prop
(~) SystemTextJsonApiSerializer: Renamed Options to JsonSerializerOptions
(~) SystemTextJsonApiSerializer: Updated default config with
   IgnoreReadOnlyFields = true,
   IgnoreReadOnlyProperties = true,
   WriteIndented = true,
(~) JsonApiClientBase: HttpClient switched to fullprop, _httpClient initilizes during fisrt request (ensures accessing child-class props values)
(~) JsonApiClientBase: ctros updates