Skip to content

Latest commit

 

History

History
103 lines (67 loc) · 4.97 KB

README.md

File metadata and controls

103 lines (67 loc) · 4.97 KB

DalSoft .NET REST Client for all platforms

If you find this repo / package useful all I ask is you please star it ⭐

Do you or the company you work for benefit from the tools I build?
If so please consider Becoming a Sponsor it would be greatly appreciated ❤️

Nuget StackOverflow Docs

For everything you need to know, please head over to https://restclient.dalsoft.io

alt text

Just some of the things you can do with DalSoft.RestClient

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

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: