DalSoft.RestClient
4.4.2
dotnet add package DalSoft.RestClient --version 4.4.2
NuGet\Install-Package DalSoft.RestClient -Version 4.4.2
<PackageReference Include="DalSoft.RestClient" Version="4.4.2" />
paket add DalSoft.RestClient --version 4.4.2
#r "nuget: DalSoft.RestClient, 4.4.2"
// Install DalSoft.RestClient as a Cake Addin #addin nuget:?package=DalSoft.RestClient&version=4.4.2 // Install DalSoft.RestClient as a Cake Tool #tool nuget:?package=DalSoft.RestClient&version=4.4.2
DalSoft .NET REST Client for all platforms
If you find this repo / template useful all I ask is you please star it ⭐
For everything you need to know, please head over to https://restclient.dalsoft.io
👉 New Static Typing and Resource Expressions in 4.0
Just some of the things you can do with DalSoft.RestClient
- Easliy Create Fluent SDK's
- Unit Testing
- Post Json
- Post Forms
- Post Files
- Retry Requests
- Twitter SDK
- Raw HTTP
- Passthrough HttpClient
- Authorization
Supported Platforms
RestClient targets .NET Standard 2.0 therefore supports Windows, Linux, Mac and Xamarin (iOS, Android and UWP).
.NET 5.0 and .NET 6.0 supported All versions of .NET Core supported All versions of legacy .NET Framework > 4.6.1 supported
Getting Started
Install via .NET CLI
> dotnet add package DalSoft.RestClient
Install via NuGet
PM> Install-Package DalSoft.RestClient
Example calling a REST API
You start by new'ing up the RestClient and passing in the base uri for your RESTful API.
For example if your wanted to perform a GET on https://jsonplaceholder.typicode.com/users/1 you would do the following:
Static Typed Rest Client
For the Static typed Rest Client just pass a string representing the resource you want access to the Resource method, and then call the HTTP method you want to use.
var client = new RestClient("https://jsonplaceholder.typicode.com");
User user = await client.Resource("users/1").Get();
Console.WriteLine(user.Name);
Dynamicaly Typed Rest Client
For the Dynamicaly typed Rest Client chain members that would make up the resource you want to access - ending with the HTTP method you want to use.
dynamic client = new RestClient("https://jsonplaceholder.typicode.com");
var user = await client.Users(1).Get();
Console.WriteLine(user.name);
Note all HTTP methods are async
Recent Releases
- Version 4.0 Static Typing and Resource Expressions
- Version 3.3.0 IHttpClientFactory Goodness
- Version 3.0 Pipeline Awesomeness
About
RestClient is a very lightweight wrapper around System.Net.HttpClient that uses the dynamic features of .NET 4 to provide a fluent way of accessing RESTFul API's, making it trivial to create REST requests using a lot less code.
Originally created to remove the boilerplate code involved in making REST requests using code that is testable. I know there are a couple of REST clients out there but I wanted the syntax to look a particular way with minimal fuss.
RestClient is biased towards posting and returning JSON - if you don't provide Accept and Content-Type headers then they are set to application/json by default See Working with non JSON content.
Standing on the Shoulders of Giants
DalSoft.RestClient is built using the following great open source projects:
DalSoft.RestClient is inspired by and gives credit to:
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.5.0)
- Microsoft.Extensions.DependencyInjection (>= 2.2.0)
- Microsoft.Extensions.Http (>= 2.2.0)
- Newtonsoft.Json (>= 13.0.1)
- System.Net.Http (>= 4.3.4)
- System.Runtime.InteropServices (>= 4.3.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on DalSoft.RestClient:
Package | Downloads |
---|---|
DalSoft.RestClient.Testing
Use DalSoft.RestClient with ASP.NET Core In-Memory Test Server for integration tests. |
|
RoomerSDK
SDK for Roomer API |
|
RamApidotnet
Package Description |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on DalSoft.RestClient:
Repository | Stars |
---|---|
MelbourneDeveloper/RestClient.Net
.NET REST Client Framework for all platforms
|
|
kitamstudios/rust-analyzer.vs
Rust language support for Visual Studio 2022
|
Version | Downloads | Last updated |
---|---|---|
4.4.2 | 2,823 | 9/2/2024 |
4.4.1 | 55,275 | 12/2/2021 |
4.4.0 | 27,305 | 12/18/2020 |
4.3.0 | 2,201 | 11/25/2020 |
4.2.1 | 7,118 | 9/24/2020 |
4.2.0 | 22,290 | 10/26/2019 |
4.1.0 | 13,400 | 8/24/2019 |
4.0.0 | 2,536 | 8/4/2019 |
3.3.2 | 19,213 | 12/3/2018 |
3.3.1 | 2,884 | 10/29/2018 |
3.3.0 | 4,639 | 7/11/2018 |
3.2.3 | 2,109 | 4/25/2018 |
3.2.2 | 48,568 | 5/4/2017 |
3.1.1 | 1,806 | 4/23/2017 |
3.1.0 | 1,755 | 4/20/2017 |
3.0.3 | 2,556 | 2/27/2017 |
3.0.2 | 1,902 | 2/23/2017 |
2.0.4 | 4,734 | 12/2/2016 |
2.0.2 | 2,587 | 11/2/2016 |
2.0.1 | 1,772 | 10/28/2016 |
2.0.0 | 2,144 | 10/27/2016 |
1.0.10 | 4,091 | 6/14/2016 |
1.0.9 | 5,410 | 8/28/2015 |
1.0.8 | 1,691 | 8/28/2015 |
1.0.7.27011 | 2,082 | 8/3/2015 |
1.0.7.15372 | 1,727 | 8/28/2015 |
1.0.6 | 1,907 | 5/11/2015 |
1.0.5.2623 | 1,881 | 4/25/2015 |
1.0.4.41175 | 1,813 | 2/1/2015 |
1.0.4.41083 | 1,907 | 4/24/2015 |
1.0.3.29240 | 1,730 | 1/21/2015 |
1.0.2.31019 | 1,744 | 1/20/2015 |
1.0.1 | 1,773 | 1/15/2015 |
1.0.0 | 1,831 | 1/14/2015 |
Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 12.0.2 to 13.0.1.
- [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases)
- [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/12.0.2...13.0.1)