Lesson Complete!
Create an Expense
What you learned
- How POST requests send data in the request body and how FastAPI maps that data to your function parameters
- How to set up in-memory storage using a dictionary and a counter for unique identifiers
- How to build a complete POST endpoint that validates input, assigns an identifier, stores the expense, and returns it
- How to start the development server with automatic reloading
- How to test your endpoint interactively using FastAPI's built-in Swagger UI at
/docs
Next up
Your API can create expenses, but there is no way to retrieve them yet. In the next lesson, you will add a GET endpoint to list all expenses and filter them by category using query parameters.