CRUD operations
The four basic operations at the heart of almost every web application are often referred by the acronym CRUD (create, read, update, and delete). These operations enable users to interact with data by creating new resources, retrieving one or more instances of existing resources, and modifying and deleting resources. Here, a more formal definition of APIs is used, but resources, in this case, are simply cars.
FastAPI is strongly tied to web standards, so these operations map to specific HTTP request methods: POST
is used for creating new instances, GET
is for reading one or more cars, PUT
is for updating, and DELETE
is for deleting resources. In your case, the resources are represented by cars
, which map to MongoDB documents.
Set up the API router
After having the application ready and serving a basic root endpoint, the environment variables set up, and the connection to the Atlas MongoDB database in place, you are now ready to start implementing the endpoints...