How to consume a Web API using RestSharp


When working with APIs you might often need to interface with public APIs and perform CRUD operations. To connect to and work with such APIs, you have libraries aplenty. One of the most popular is , mainly because of its simplicity.

RestSharp is an open source HTTP client library that can interface with public APIs and consume data without the need to deal with the complexity of the raw HTTP requests. It is an easy to use and powerful library that you can leverage to consume your RESTful API built using .NET. The best thing in RestSharp is that it can even work with even .NET 2.0 and it supports Xamarin and Windows Phone as well. This article presents a discussion on RestSharp and how it can be used to consume RESTful APIs build using ASP.NET Web API.

Install RestSharp

You can install RestSharp in your project from the NuGet Package Manager UI or by typing the following command in the NuGet Package Manager console.

Install-Package RestSharp

As of this writing, the latest stable version of RestSharp is 106.2.1.