Consume Web API with C# HttpClientFactory

Sometimes we need to integrate an external API into our code even as a backend service and not just the frontend integrating with the UI components.

We may need to modify such data before it is presented or do some bits of filtering or whatever we want as long as it’s in the scope of access we have to such third-party web APIs.

HttpClient is an already made library in .Net that makes this task easy to achieve without having to do many configurations or setups to start consuming Web APIs.

Let’s have a walkthrough on a simple use case.

I have used a free API endpoint in my case No keys are needed.

Ready for use and integration, you can also use it for testing in your case or simply google for other free APIs that you can use if you just want something different.

However, This is more than sufficient for this tutorial.

You can start off by creating a simple ASP.Net Core Web API project

Create an API project

Give your project a name