Build HTTP requests with a clean, chainable API. Less boilerplate, more productivity.
Created in Poland by Leszek Pomianowski and open-source community.
- Table of Contents
- 🤔 Why This Library?
- ⚡ Get Started
- 📖 How to Use
- 📚 API Reference
- 🧪 Testing with AwesomeAssertions
- 👥 Maintainers
- 💬 Support
- 📄 License
Traditional HttpClient usage requires verbose setup:
// ❌ Traditional approach - verbose and repetitive
var request = new HttpRequestMessage(HttpMethod.Post, "/api/users");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
request.Content = new StringContent(
JsonSerializer.Serialize(new { Name = "John" }),
Encoding.UTF8,
"application/json");
var response = await client.SendAsync(request);With Fluent.Client, requests become expressive one-liners:
// ✅ Fluent approach - clean and readable
var response = await client
.Authorize(token: "abc123")
.Post("/api/users", new { Name = "John" })
.SendAsync();dotnet add package Fluent.Client📦 NuGet: https://www.nuget.org/packages/Fluent.Client
using Fluent.Client;
var client = new HttpClient { BaseAddress = new Uri("https://api.example.com/") };
// Simple POST with JSON body
var response = await client
.Post("/api/users", new { Name = "John Doe" })
.SendAsync();Start by creating a request using one of the HTTP method extensions on HttpClient.
using Fluent.Client;
var client = new HttpClient { BaseAddress = new Uri("https://api.example.com/") };
// POST with JSON body
var request = client.Post("/api/v1/users", new { Name = "John Doe" });
// GET with query parameters
var request = client.Get("/api/v1/users", new { page = 1, limit = 10 });
// DELETE
var request = client.Delete("/api/v1/users/897");
// PUT with body
var request = client.Put("/api/v1/users/897", new { Name = "Jane Doe" });| Method | Description |
|---|---|
.Get(path, query?) |
Create GET request with optional query parameters |
.Post(path, body?) |
Create POST request with optional JSON body |
.Put(path, body?) |
Create PUT request with optional JSON body |
.Delete(path) |
Create DELETE request |
.Patch(path, body?) |
Create PATCH request with optional JSON body |
Chain configuration methods to add headers, authorization, and more.
// Bearer token
client.Authorize(token: "jwt-token-here").Get("/api/protected");
// Basic authentication
client.Authorize(username: "john", password: "secret").Get("/api/protected");// Pass as anonymous object
client.Get("/api/users", new
{
page = 1,
limit = 10,
sortBy = "createdAt"
});var request = client
.Authorize(token: "abc123")
.Get("/api/v1/basket", new { includeItems = true });Send the request and handle the response.
Get HttpResponseMessage
using HttpResponseMessage response = await request.SendAsync();
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
}Deserialize Response Automatically
// Automatically deserialize JSON response to typed object
UserCreatedResponse result = await request.SendAsync<UserCreatedResponse>();
Console.WriteLine($"Created user: {result.Id}");Direct Execution (No SendAsync)
// The request returns Task<HttpResponseMessage>, so you can await directly
using var response = await client
.Authorize(token: "abc123")
.Post("/api/users", new { Name = "John" });| Method | Description |
|---|---|
Get(path, query?) |
Create GET request |
Post(path, body?) |
Create POST request |
Put(path, body?) |
Create PUT request |
Delete(path) |
Create DELETE request |
Patch(path, body?) |
Create PATCH request |
| Method | Description |
|---|---|
Authorize(token) |
Add Bearer token authorization |
Authorize(username, password) |
Add Basic authentication |
| Method | Description |
|---|---|
SendAsync() |
Send request and return HttpResponseMessage |
SendAsync<T>() |
Send request and deserialize response to T |
Pair this library with Fluent.Client.AwesomeAssertions for expressive test assertions:
await client
.Authorize(token: "abc123")
.Post("/api/users", new { Name = "John" })
.Should()
.Succeed("because valid user data was provided");📦 Install: dotnet add package Fluent.Client.AwesomeAssertions
- Leszek Pomianowski (@pomianowski)
For support, please open a GitHub issue. We welcome bug reports, feature requests, and questions.
This project is licensed under the terms of the MIT open source license. Please refer to the LICENSE file for the full terms.
You can use it in private and commercial projects. Keep in mind that you must include a copy of the license in your project.