How to create a Client for your API — .NET

Tiago Martins
5 min readJul 1, 2020

Nowadays, the creation of APIs is a very common solution when we want to make some features of our system available for other components. Since that, we can put an API as a public component and allow you to use it. The thing is that if you want to make some requests in your backend you must create an HTTP client in order to do the necessary requests.

Why is it good to provide a client library to your API?

That’s the main question that you want to have the right answer. It helps you to ignore some operations when you are developing a service because it avoids you from reinventing the wheel every time. Regarding this, it will increase your time to focus on your own system and not in creating the code to make HTTP requests. The client already gives you a response object ready to use instead of giving you a raw response which you must serialize for an object.

You also don’t need to know which version of an API are you using. The client abstracts you from this. If the API logic or rules change, you don’t need necessarily to update the client version if the interfaces not change, meaning this the input, output, or route of an endpoint didn’t change.

Let’s talk about code…

--

--

Tiago Martins

Senior Software Engineer | Cloud Native Developer | Just another programmer with some ideas.