![]() |
VOOZH | about |
dotnet add package RestWrapper --version 3.2.0
NuGet\Install-Package RestWrapper -Version 3.2.0
<PackageReference Include="RestWrapper" Version="3.2.0" />
<PackageVersion Include="RestWrapper" Version="3.2.0" />Directory.Packages.props
<PackageReference Include="RestWrapper" />Project file
paket add RestWrapper --version 3.2.0
#r "nuget: RestWrapper, 3.2.0"
#:package RestWrapper@3.2.0
#addin nuget:?package=RestWrapper&version=3.2.0Install as a Cake Addin
#tool nuget:?package=RestWrapper&version=3.2.0Install as a Cake Tool
👁 NuGet Version
👁 NuGet Downloads
RestWrapper is a small C# library for sending HTTP requests without rebuilding the same request, header, authorization, streaming, and response-handling code in every project.
It wraps HttpClient with a compact API for:
HttpClient instancesIf you want something lighter than a full API client framework but more structured than hand-rolled HttpClient calls, RestWrapper sits in the middle:
HttpClient for DI, proxies, mTLS, custom handlers, and connection reuseRestWrapper currently targets:
netstandard2.0netstandard2.1net462net48net6.0net8.0net10.0dotnet add package RestWrapper
Simple GET:
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/status");
using RestResponse response = await request.SendAsync();
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.DataAsString);
Simple POST:
using RestWrapper;
using System.Net.Http;
using RestRequest request = new RestRequest("https://api.example.com/messages", HttpMethod.Post);
request.ContentType = "text/plain";
using RestResponse response = await request.SendAsync("Hello, world!");
Console.WriteLine(response.StatusCode);
Console.WriteLine(response.DataAsString);
JSON response handling:
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/items/123");
using RestResponse response = await request.SendAsync();
MyDto dto = response.DataFromJson<MyDto>();
Console.WriteLine(dto.Name);
Form data:
using RestWrapper;
using System.Net.Http;
using RestRequest request = new RestRequest("https://api.example.com/login", HttpMethod.Post);
Dictionary<string, string> form = new Dictionary<string, string>
{
{ "username", "alice" },
{ "password", "secret" }
};
using RestResponse response = await request.SendAsync(form);
Console.WriteLine(response.StatusCode);
using RestWrapper;
using System.Net.Http;
using RestRequest request = new RestRequest("https://api.example.com/items", HttpMethod.Post);
request.ContentType = "application/json; charset=utf-8";
request.Headers.Add("X-Correlation-Id", Guid.NewGuid().ToString());
request.Headers.Add("X-Tenant", "east");
using RestResponse response = await request.SendAsync("{\"name\":\"demo\"}");
Basic auth:
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/secure");
request.Authorization.User = "alice";
request.Authorization.Password = "secret";
using RestResponse response = await request.SendAsync();
Bearer auth:
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/secure");
request.Authorization.BearerToken = "your-token";
using RestResponse response = await request.SendAsync();
Raw authorization header:
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/secure");
request.Authorization.Raw = "Custom scheme-value";
using RestResponse response = await request.SendAsync();
using RestWrapper;
using System.Net.Http;
using System.Text;
byte[] payload = Encoding.UTF8.GetBytes("streamed payload");
using MemoryStream stream = new MemoryStream(payload);
using RestRequest request = new RestRequest("https://api.example.com/upload", HttpMethod.Put);
request.ContentType = "text/plain";
using RestResponse response = await request.SendAsync(payload.Length, stream);
Console.WriteLine(response.StatusCode);
For regular responses, RestWrapper gives you multiple access patterns:
response.Data for the raw streamresponse.DataAsBytes for the buffered byte arrayresponse.DataAsString for UTF-8 string contentresponse.DataFromJson<T>() for JSON payloadsExample:
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/items/123");
using RestResponse response = await request.SendAsync();
Console.WriteLine(response.IsSuccessStatusCode);
Console.WriteLine(response.ContentType);
Console.WriteLine(response.ContentLength);
Console.WriteLine(response.DataAsString);
Each RestResponse includes a Time property:
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/status");
using RestResponse response = await request.SendAsync();
Console.WriteLine("Start : " + response.Time.Start);
Console.WriteLine("End : " + response.Time.End);
Console.WriteLine("Total ms : " + response.Time.TotalMs);
When the server returns text/event-stream, use ReadEventAsync() instead of Data, DataAsString, or DataFromJson<T>().
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/events");
using RestResponse response = await request.SendAsync();
while (true)
{
ServerSentEvent evt = await response.ReadEventAsync();
if (evt == null) break;
Console.WriteLine($"[{evt.Event}] {evt.Data}");
}
ServerSentEvent exposes:
IdEventDataRetryRestWrapper supports chunked request sending and chunked response reading.
using RestWrapper;
using System.Net.Http;
using RestRequest request = new RestRequest("https://api.example.com/chunked", HttpMethod.Post);
request.ChunkedTransfer = true;
await request.SendChunkAsync("chunk-1", false);
await request.SendChunkAsync("chunk-2", false);
using RestResponse response = await request.SendChunkAsync(Array.Empty<byte>(), true);
while (true)
{
ChunkData chunk = await response.ReadChunkAsync();
if (chunk == null) break;
Console.WriteLine(System.Text.Encoding.UTF8.GetString(chunk.Data));
if (chunk.IsFinal) break;
}
As with SSE, chunked responses are a specialized mode. Use ReadChunkAsync() instead of Data, DataAsString, DataAsBytes, or DataFromJson<T>().
If you already manage HttpClient instances through dependency injection or need custom handler behavior, you can provide your own HttpClient to RestRequest.
using RestWrapper;
using System.Net.Http;
using HttpClient client = new HttpClient();
using RestRequest request = new RestRequest(
"https://api.example.com/resource",
HttpMethod.Get,
client);
using RestResponse response = await request.SendAsync();
Console.WriteLine(response.StatusCode);
This is useful for:
HttpClientFactory usageImportant behavior:
RestRequest will not dispose an external HttpClientWhen you supply your own HttpClient, transport-level settings also become caller-owned. In that mode, do not use these RestRequest properties:
TimeoutMillisecondsAllowAutoRedirectIgnoreCertificateErrorsCertificateFilenameCertificatePasswordConfigure those on your HttpClient / handler instead.
RestResponse.DataFromJson<T>() uses System.Text.Json by default, but you can replace the serializer:
using RestWrapper;
using RestRequest request = new RestRequest("https://api.example.com/items/123");
using RestResponse response = await request.SendAsync();
response.SerializationHelper = new MySerializer();
MyDto dto = response.DataFromJson<MyDto>();
MySerializer just needs to implement ISerializationHelper.
The repository includes both interactive and automated test hosts:
src/Test is the interactive console appsrc/Test.Shared contains the shared Touchstone suitessrc/Test.Automated is the console/CLI automation runnersrc/Test.Xunit exposes the shared suite through dotnet testsrc/Test.Nunit exposes the same shared suite through dotnet testThe current automated surface contains 120 shared cases covering:
HttpClient flowsRestWrapper uses the platform HttpClient stack. When targeting localhost, some environments will try IPv6 loopback first. If your local service is only listening on IPv4, that can introduce a noticeable delay.
If you see this behavior, prefer 127.0.0.1 instead of localhost.
See for version history.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 is compatible. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on RestWrapper:
| Package | Downloads |
|---|---|
|
KvpbaseSDK
C# SDK for Kvpbase object storage platform |
|
|
Komodo.Sdk
Client SDK in C# for Komodo. Please either install Komodo.Daemon to integrate search within your application, or Komodo.Server to run a standalone server if you wish to use this client SDK. Komodo is an information search, metadata, storage, and retrieval platform. |
|
|
GoogleMapsClient
I needed a simple way to parse addresses and resolve coordinates to an address. Plug in a Google Maps API key and you're all set. |
|
|
LiteGraph
LiteGraph is a property graph database with support for graph relationships, tags, labels, metadata, data, and vectors. |
|
|
SendWithBrevo
A simple C# class library to help simplify sending emails using Brevo. |
Showing the top 2 popular GitHub repositories that depend on RestWrapper:
| Repository | Stars |
|---|---|
|
dotnet/WatsonWebserver
Watson is the fastest, easiest way to build scalable RESTful web servers and services in C#.
|
|
|
litegraphdb/litegraph
Lightweight graph database with relational, vector, and MCP support, designed to power knowledge and artificial intelligence persistence and retrieval.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.2.0 | 360 | 5/18/2026 |
| 3.1.8 | 9,220 | 10/4/2025 |
| 3.1.7 | 396 | 10/1/2025 |
| 3.1.6 | 790 | 9/19/2025 |
| 3.1.5 | 6,169 | 3/10/2025 |
| 3.1.4 | 6,419 | 1/22/2025 |
| 3.1.3 | 657 | 12/13/2024 |
| 3.1.2 | 5,658 | 12/10/2024 |
| 3.1.1 | 339 | 12/10/2024 |
| 3.1.0 | 761 | 12/2/2024 |
| 3.0.22 | 1,386 | 10/29/2024 |
| 3.0.21 | 4,720 | 8/27/2024 |
| 3.0.20 | 4,573 | 5/21/2024 |
| 3.0.19 | 4,299 | 3/27/2024 |
| 3.0.18 | 1,669 | 1/16/2024 |
| 3.0.17 | 6,113 | 11/25/2023 |
| 3.0.16 | 692 | 11/10/2023 |
| 3.0.15 | 661 | 11/10/2023 |
| 3.0.14 | 1,503 | 10/21/2023 |
Custom HttpClient injection support, safer shared-client request handling, and expanded automated test coverage.