Week 1–2: Minimal APIs Basics
Build a Books API with in-memory storage. Learn how Minimal APIs work, how to create endpoints, and how to test them with Swagger.
Essential (70% of time)
Section titled “Essential (70% of time)”Core skills:
- Create a Minimal API project with
dotnet new web - Make GET and POST endpoints
- Use route parameters (
/books/{id}) - Return proper status codes using the
Resultshelper - Test with Swagger UI
Key resources
Section titled “Key resources”LLM prompts
Section titled “LLM prompts”“Show me how to create a .NET 8 Minimal API with a GET endpoint that returns a list of books. Books have Id, Title, Author, Year. Use an in-memory List.”
“Add POST, PUT, DELETE endpoints for books. Use Results.Ok(), Results.Created(), Results.NotFound() for proper status codes.”
“Explain when to use Results.Ok() vs Results.Created() vs Results.NotFound(). Simple examples please.”
Brief (20% of time)
Section titled “Brief (20% of time)”- Understanding Program.cs structure
- Query parameters (
?search=value)
Optional (skip if needed)
Section titled “Optional (skip if needed)”- .http files for testing
- Dependency injection details
Practical project
Section titled “Practical project”Build a Books API with in-memory storage using a List<Book>.
Learning activities
Section titled “Learning activities”- Run
dotnet new web -n BooksApiand explore the generated files - Add a
Bookclass with Id, Title, Author, Year - Create GET /books — returns all books
- Create GET /books/{id} — returns one book or 404
- Create POST /books — adds to list, returns 201
- Create PUT /books/{id} — updates book, returns 204 or 404
- Create DELETE /books/{id} — removes book, returns 204 or 404
- Open Swagger and manually test every endpoint
Key concepts to master
Section titled “Key concepts to master”app.MapGet(),app.MapPost(),app.MapPut(),app.MapDelete()syntax- Route parameters vs query parameters
Results.Ok(),Results.Created(),Results.NotFound(),Results.BadRequest()- Running and testing locally with Swagger
Deliverable
Section titled “Deliverable”Books API with in-memory List, all CRUD endpoints working in Swagger.