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
<PackageReference Include="SKitLs.ClientsApi.Core" Version="1.0.1" />
<PackageVersion Include="SKitLs.ClientsApi.Core" Version="1.0.1" />
<PackageReference Include="SKitLs.ClientsApi.Core" />
paket add SKitLs.ClientsApi.Core --version 1.0.1
#r "nuget: SKitLs.ClientsApi.Core, 1.0.1"
#:package SKitLs.ClientsApi.Core@1.0.1
#addin nuget:?package=SKitLs.ClientsApi.Core&version=1.0.1
#tool nuget:?package=SKitLs.ClientsApi.Core&version=1.0.1
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
HttpClientconfiguration
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:
ConfigureHttpClientCreateSerializerBuildRequestUriBuildQueryStringOnBeforeSendAsyncOnAfterResponseAsyncCreateApiExceptionAsync
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 | Versions 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. |
-
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.
(+) 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