Drinks Info
Software developers frequently build systems that rely on third-party data. A common method for accessing this data is by making requests to external vendors Web APIs (Application Programming Interfaces). Once the data is retrieved, it can be processed and integrated into the application to meet specific requirements. Another typical scenario involves organizations with multiple independent applications that need to communicate with each other, often using a technique known as microservices. Later we will build our own APIs and Microservices, but first we need to learn how to consume a Web Api.
In this application we will learn how to connect to an external API through HTTP requests using .NET’s class library. It‘s easier than you imagine! Luckily there are many public APIs out there. Here’s a great list of public APIs for practice.
Requirements
You were hired by restaurant to create a solution for their drinks menu.
Their drinks menu is provided by an external company. All the data about the drinks is in the companies database, accessible through an API.
Your job is to create a system that allows the restaurant employee to pull data from any drink in the database.
You don't need SQL here, as you won't be operating the database. All you need is to create a user-friendly way to present the data to the users (the restaurant employees)
When the users open the application, they should be presented with the Drinks Category Menu and invited to choose a category. Then they'll have the chance to choose a drink and see information about it.
When the users visualise the drink detail, there shouldn't be any properties with empty values.
You should handle errors so that if the API is down, the application doesn't crash.
Resources
Here are the links for using HTTP calls with C# and to the Drinks API documentation:
Tips
Try calling the API using Postman or your browser before starting to code.
The UI in the youtube tutorial above is a bit ugly. We suggest you use Spectre Console for a better UX/UI.
Challenges
Add a 'Favorite Drinks' functionality
Find a way to show a picture of the drinks
Add a view count functionality so the users know which drinks have been visualized the most.
If you followed the tutorial in the resources, you noticed we used Rest Client for the handling of the HTTP requests. Try using .NET's HTTP client instead, as it's more commonly used in the industry.