Skip to content

BionStt/RestClient.Net

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

diagram

.NET REST Client Framework for all platforms

The best .NET REST Client with task-based async, strong types and dependency injection on all platforms. Consume your ASP .NET Core Web APIs or consume RESTful APIs over the internet in C# or Visual Basic.

.NET Core

Documentation Here

Announcement

Version 4.0.0 has been released!

Check out the features and fixes. There are some breaking changes. IHttpClientFactory and IClientFactory have been converted to delegates to save on boilerplate code.

Check out blog posts here https://christianfindlay.com/

Why You Should Use It

  • It's fast! Initial tests show that it is faster than RestSharp and is one of the faster .NET Rest Clients available.
  • Designed for Dependency Injection, Unit Testing and use with IoC Containers
  • Async friendly. All operations use async, await keywords.
  • Integrates with Polly resilience and transient-fault-handling
  • Automatic serialization with any method (JSON, Binary, SOAP, Google Protocol Buffers)
  • Installation from NuGet is easy on any platform
  • Uses strong types with content body
  • Supports WebAssembly, Android, iOS, Windows 10, .NET Framework 4.5+, .NET Core (.NET Standard 2.0)
  • Supports GET, POST, PUT, PATCH, DELETE with ability to use less common HTTP methods

These features together make this the best C# REST client and the best alternative to RestSharp. Consuming REST APIs is simple and encourages best practice.

See documentation for more examples.

NuGet: Install-Package RestClient.NET

Please read this article about Serialization and Deserialization.

With Newtonsoft serialization

var client = new Client(new NewtonsoftSerializationAdapter(), new Uri("https://restcountries.eu/rest/v2/"));
var response = await client.GetAsync<List<RestCountry>>();

With default serialization on .NET Core

var client = new Client(new Uri("https://restcountries.eu/rest/v2/"));
var response = await client.GetAsync<List<RestCountry>>();

Post / Put / Patch

Protocol Buffers (Binary)

var person = new Person { FirstName = "Bob", Surname = "Smith" };
var client = new Client(new ProtobufSerializationAdapter(), new Uri("http://localhost:42908/person"));
person = await client.PostAsync<Person, Person>(person);

JSON

var client = new Client(new NewtonsoftSerializationAdapter(), new Uri("https://jsonplaceholder.typicode.com"));
client.SetJsonContentTypeHeader();
UserPost userPost = await client.PostAsync<UserPost, UserPost>(new UserPost { title = "Title" }, "/posts");
var client = new Client(new NewtonsoftSerializationAdapter(), new Uri("https://jsonplaceholder.typicode.com"));
await client.DeleteAsync("posts/1");

Donate

Coin Address
Bitcoin 33LrG1p81kdzNUHoCnsYGj6EHRprTKWu3U
Ethereum 0x7ba0ea9975ac0efb5319886a287dcf5eecd3038e

Please log any issues or feedback in the issues section. For pull requests, please see the contribution guide.

About

.NET REST Client Framework for all platforms

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 96.0%
  • HTML 2.6%
  • CSS 1.3%
  • Other 0.1%