In this chapter, we build a Student Management API using:
- FastAPI for REST API endpoints
- MongoDB Atlas for database storage
- PyMongo for database queries
- Create →
POST /add - Read →
GET /show - Update →
POST /edit - Delete →
GET /remove
GET /showResponse:
{
"data": [
{"_id": "66abc123", "name": "Riya", "roll": 101, "marks": 85}
]
}POST /add?name=Riya&roll=101&marks=85Response:
{"status": "66abc123"}POST /edit?id=66abc123&name=Riya SinghResponse:
{"status": 1}GET /remove?id=66abc123Response:
{"status": 1}Client ---> FastAPI Routes ---> PyMongo ---> MongoDB Atlas
- FastAPI + MongoDB is powerful for backend APIs
- CRUD maps to
POST/GETendpoints - ObjectId must be converted to string for JSON responses