Skip to content

About

A .NET library enhancing HttpClient for RESTful API communication offers features like shared HttpClient instances for improved performance, flexible configurations, advanced error handling, retry strategies, modular content processing, authentication, and request/response interception.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

Kampute.HttpClient

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

Features

  • 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.

Packages

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.

Quick Start

For a JSON API, install the System.Text.Json extension. It includes the core client as a dependency.

dotnet add package Kampute.HttpClient.Json

In 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.

Contributing

Report bugs and suggest features in GitHub issues. Pull requests are welcome; run dotnet test from the repository root before submitting one.

License

Kampute.HttpClient is released under the MIT License.

About

A .NET library enhancing HttpClient for RESTful API communication offers features like shared HttpClient instances for improved performance, flexible configurations, advanced error handling, retry strategies, modular content processing, authentication, and request/response interception.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages