Recipe API Client
Build a C# command-line tool that searches recipes from a free public recipe API, TheMealDB, and prints short, readable summaries. You can search by name, list recipes that use an ingredient, filter by category or cuisine, and show one recipe in full with its ingredients and instructions. It handles slow or missing internet, empty results and unexpected data gracefully. It's a good first C# project that talks to the internet: you'll learn HttpClient, async and await, turning JSON into C# classes with System.Text.Json, handling errors, reading command-line arguments, and testing code that calls an API without really calling it.
- Estimate
- ~8h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
HttpClient · System.Text.Json · xUnit
Project roadmap
- 01
Explore the API and plan the commands
~1hOpen TheMealDB's free API in the browser (search by name, filter by ingredient, list categories and look up by id) and look at the JSON. Write README.md with the commands (recipes search chicken, recipes ingredient garlic, recipes show 52772, recipes categories) and example output. Create a project with dotnet new console. Done when: README.md shows each command with example output.
- 02
Model the data
~1.5hCreate C# record classes for the parts of the responses you need, using [JsonPropertyName] for the API's field names. The API stores ingredients in numbered fields (strIngredient1 to strIngredient20), so write a method that turns them into a clean list of ingredient and measure pairs, skipping empty ones. Done when: a saved JSON response is deserialized into your classes with the right ingredient list.
- 03
Call the API
~1.5hWrite a RecipeClient class using one shared HttpClient with a timeout and a base address, with async methods for each command using GetFromJsonAsync. The API returns meals: null when nothing matches, so return an empty list in that case. Done when: each method returns real data from the API.
- 04
Print summaries
~1.5hImplement the commands: lists show the id, name, category and cuisine in aligned columns (with --limit), and show prints the name, category, ingredients with measures, and instructions wrapped to the terminal width. Add --category and --area filters for search results. Done when: every command in README.md prints clean output.
- 05
Handle problems
~1hHandle no internet or a timeout (a clear message suggesting to check the connection), server errors, an empty search, an id that doesn't exist, and a missing or unknown command (print the usage). Catch HttpRequestException and TaskCanceledException, never showing a stack trace to the user, and exit with a non-zero code on errors. Done when: each problem gives a friendly message.
- 06
Test it
~1.5hWrite xUnit tests that give RecipeClient an HttpClient with a fake HttpMessageHandler returning saved JSON files: parsing ingredients, empty results (meals: null), a 500 error, a timeout, and the output formatting. Done when: dotnet test passes without internet access.
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack