Final Project: Build a Task API with FastAPI & MongoDB
Time to combine models, Motor, and path operations into a real API.
Requirements
- Define a Pydantic
Taskmodel with at least a title, a completed flag, and one more field of your choice. - Connect to a MongoDB database (local, Docker, or a free Atlas cluster) using Motor.
- Build full CRUD endpoints,
POST /tasks,GET /tasks,GET /tasks/{id},PUT /tasks/{id}, andDELETE /tasks/{id}. - Return a proper
404when a requested task doesn't exist. - Confirm your endpoints work using the automatic docs at
/docs.
Stretch goals
- Add a query parameter to filter tasks by
donestatus. - Add pagination with
skip/limitquery parameters. - Add a second collection (e.g.
usersorprojects) with a relationship to tasks.
Submit your repository link below when you are done, an instructor will review it before you can mark this lesson complete. Good luck! 🚀