A .NET library for REST API clients built on HttpClient, with scoped request configuration, typed responses, configurable retries, and error handlers.
Documentation · Getting started · API reference
- Shared connections or an application-managed
HttpClient. - Temporary headers and request properties through scopes.
- JSON, XML, and custom content formatters for requests and responses.
- Retry strategies for transient connection failures and handlers for HTTP errors.
- Request and response events for customization and inspection.
The packages target .NET Standard 2.0 and .NET 10.
| Package | Purpose |
|---|---|
| Kampute.HttpClient | Core client, scopes, error handlers, and XML support. |
| Kampute.HttpClient.Json | JSON with System.Text.Json. |
| Kampute.HttpClient.NewtonsoftJson | JSON with Newtonsoft.Json. |
For a JSON API, install the System.Text.Json extension. It includes the core client as a dependency.
dotnet add package Kampute.HttpClient.JsonIn a .NET application, register the formatter before requesting a typed response. Replace the example URL with your API; this model assumes a JSON response such as {"Id":42,"Name":"Example"}.
using Kampute.HttpClient;
using Kampute.HttpClient.Json;
using var client = new HttpRestClient();
client.UseJson();
var resource = await client.GetAsync<Resource>("https://api.example.com/resource");
public sealed class Resource
{
public int Id { get; set; }
public string? Name { get; set; }
}See Getting started for package selection and the user guide for request configuration, content formats, retries, and error handling.
Report bugs and suggest features in GitHub issues. Pull requests are welcome; run dotnet test from the repository root before submitting one.
Kampute.HttpClient is released under the MIT License.