FluentRestClient 1.1.3

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

FluentRestClient

A lightweight, fluent, and extensible REST client wrapper for .NET, designed to simplify API requests with support for features like MessagePack, configurable headers, and easy request customization.

๐Ÿš€ Features

  • Fluent request building syntax
  • Supports JSON and MessagePack serialization
  • Multipart/form-data support for file uploads
  • Cancellation token support
  • Custom headers, query parameters, and request options
  • Strongly typed responses
  • Lightweight and dependency-free

๐Ÿ“ฆ Installation

Install via NuGet:

dotnet add package FluentRestClient

Or via the NuGet Package Manager:

Install-Package FluentRestClient

๐Ÿ› ๏ธ Usage

var response = await RequestBuilder
    .Create(HttpMethod.Get, "https://api.example.com/items")
    .WithHeader("Authorization", "Bearer YOUR_TOKEN")
    .WithQuery("page", "1")
    .SendAsync<ApiResponse<List<ItemDto>>>(httpClient, cancellationToken);

Or with MessagePack serialization:

var response = await RequestBuilder
    .Create(HttpMethod.Get, "https://api.example.com/items")
    .WithMessagePackEnabled()
    .SendAsync<List<ItemDto>>(httpClient, cancellationToken);

File Upload with Multipart/Form-Data

Upload files using multipart/form-data:

// Upload a single file
byte[] fileBytes = File.ReadAllBytes("document.pdf");
var response = await RequestBuilder
    .Create(HttpMethod.Post, "https://api.example.com/upload")
    .WithFile("file", fileBytes, "document.pdf", "application/pdf")
    .WithFormField("description", "My document")
    .SendAsync<UploadResponse>(httpClient, cancellationToken);

Or upload using a file stream:

using var fileStream = File.OpenRead("image.jpg");
var response = await RequestBuilder
    .Create(HttpMethod.Post, "https://api.example.com/upload")
    .WithFileStream("image", fileStream, "image.jpg", "image/jpeg")
    .WithFormField("title", "Profile Picture")
    .SendAsync<UploadResponse>(httpClient, cancellationToken);

Upload multiple files:

var response = await RequestBuilder
    .Create(HttpMethod.Post, "https://api.example.com/upload-multiple")
    .WithFile("file1", file1Bytes, "doc1.pdf", "application/pdf")
    .WithFile("file2", file2Bytes, "doc2.pdf", "application/pdf")
    .WithFormField("category", "documents")
    .SendAsync<UploadResponse>(httpClient, cancellationToken);

โœจ Example API

public Task<ApiResponse<List<UserItem>>?> UsersList(CancellationToken cancellationToken = default)
    => RequestBuilder.Create(HttpMethod.Get, Urls.GetUsersList)
        .SendAsync<ApiResponse<List<UserItem>>>(_restClient, cancellationToken);

๐Ÿ“„ Documentation

-[x] Fluent API for building REST requests

-[x] Custom serialization options

-[ ] Optional retry policies (coming soon)

๐Ÿงฉ Extensibility

You can extend the RequestBuilder to add:

  • Global headers

  • Authentication middleware

  • Logging

  • Retry policies (e.g., Polly)

๐Ÿงช Testing

Mock IHttpClientFactory for unit tests.

๐Ÿค Contributing

Pull requests are welcome! Feel free to fork the repo and submit improvements.

๐Ÿ“œ License

MIT License

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.

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.1.3 321 11/7/2025
1.0.3 701 5/13/2025
1.0.2 240 5/13/2025
1.0.1 138 5/2/2025
1.0.0 105 5/2/2025