Lesson Complete!

Get and Delete an Expense

What you learned

  • How path parameters let you target a specific resource by its identifier in the URL
  • How FastAPI automatically converts path parameters to the type you specify
  • How to raise an HTTPException with a 404 status code when a resource is not found
  • How to retrieve a single expense by its identifier
  • How to delete an expense using dict.pop() and return the deleted resource

Next up

Your API handles creating, reading, and deleting expenses. The last CRUD operation is updating. In the next lesson, you will implement a PATCH endpoint that lets users update individual fields of an expense without replacing the entire object.