Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wpcodevo/fastapi_mongodb
This article will teach you how to create a CRUD RESTful API with Python, FastAPI, PyMongo, MongoDB, and Docker-compose to perform the basic Create/Read/Update/Delete operations against a database.
https://github.com/wpcodevo/fastapi_mongodb
fastapi fastapi-crud fastapi-framework jwt jwt-authentication mongodb pydantic pydantic-models rest-api uvicorn
Last synced: 27 days ago
JSON representation
This article will teach you how to create a CRUD RESTful API with Python, FastAPI, PyMongo, MongoDB, and Docker-compose to perform the basic Create/Read/Update/Delete operations against a database.
- Host: GitHub
- URL: https://github.com/wpcodevo/fastapi_mongodb
- Owner: wpcodevo
- Created: 2022-07-14T19:02:16.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-04T21:22:33.000Z (almost 2 years ago)
- Last Synced: 2024-05-15T15:32:42.543Z (7 months ago)
- Topics: fastapi, fastapi-crud, fastapi-framework, jwt, jwt-authentication, mongodb, pydantic, pydantic-models, rest-api, uvicorn
- Language: Python
- Homepage: https://codevoweb.com/crud-restful-api-server-with-python-fastapi-and-mongodb
- Size: 29.3 KB
- Stars: 82
- Watchers: 4
- Forks: 28
- Open Issues: 3
-
Metadata Files:
- Readme: readMe.md
Awesome Lists containing this project
README
# RESTful API with Python, FastAPI, Pydantic, and MongoDB
## 1. API with Python, FastAPI, and MongoDB: JWT Authentication
This article will teach you how to add JSON Web Token (JWT) authentication to your FastAPI app using PyMongo, Pydantic, FastAPI JWT Auth package, and Docker-compose.
![API with Python, FastAPI, and MongoDB: JWT Authentication](https://codevoweb.com/wp-content/uploads/2022/07/API-with-Python-FastAPI-and-MongoDB-JWT-Authentication.webp)
### Topics Covered
- How to Setup FastAPI with MongoDB
- Starting the FastAPI Server
- Set up Environment Variables with Pydantic
- Connect to the MongoDB Database
- Creating the Schemas with Pydantic
- Create Serializers for the MongoDB BSON Documents
- Password Management in FastAPI
- Creating Utility Functions to Sign and Verify JWTs
- Creating the Authentication Controllers in FastAPI
- User Registration Handler
- User Sign-in Handler
- Refresh Access Token Handler
- Sign out User Handler
- How to Protect Private Routes
- Creating a User Handler
- Adding the API Routes and CORS
- Testing the API with PostmanRead the entire article here: [https://codevoweb.com/api-with-python-fastapi-and-mongodb-jwt-authentication](https://codevoweb.com/api-with-python-fastapi-and-mongodb-jwt-authentication)
## 2. Build API with Python & FastAPI: SignUp User and Verify Email
This article will teach you how to send HTML Emails with Python, FastAPI, PyMongo, MongoDB, Jinja2, and Docker. Also, you will learn how to use Jinja2 to generate different HTML templates.
![Build API with Python & FastAPI: SignUp User and Verify Email](https://codevoweb.com/wp-content/uploads/2022/07/Build-API-with-Python-FastAPI-SignUp-User-and-Verify-Email.webp)
### Topics Covered
- Send HTML Emails with Jinja2 & FastAPI Example
- Creating the SMTP Provider Account
- Edit the Environment Variables File
- Validating the Environment Variables with Pydantic
- Creating the HTML Email Templates in FastAPI
- Creating the SMTP Email Sender
- Sending the HTML Emails in FastAPI
- Update the SignUp Controller
- Create a Handler to Validate the Verification CodeRead the entire article here: [https://codevoweb.com/api-with-python-fastapi-signup-user-and-verify-email](https://codevoweb.com/api-with-python-fastapi-signup-user-and-verify-email)
## 3. CRUD RESTful API Server with Python, FastAPI, and MongoDB
This article will teach you how to create a CRUD RESTful API with Python, FastAPI, PyMongo, MongoDB, and Docker-compose to perform the basic Create/Read/Update/Delete operations against a database.
![CRUD RESTful API Server with Python, FastAPI, and MongoDB](https://codevoweb.com/wp-content/uploads/2022/07/CRUD-RESTful-API-Server-with-Python-FastAPI-and-MongoDB.webp)
### Topics Covered
- Python, FastAPI, MongoDB CRUD API Overview
- Setting up FastAPI with MongoDB
- Installing FastAPI
- Running the FastAPI Server
- Loading Environment Variables with Pydantic
- Connecting to the MongoDB Database Server
- Creating the Schemas with Pydantic
- Serializers for the MongoDB Documents
- Creating the API Route Controllers
- Get All Posts Controller
- Create New Post Controller
- Update Post Controller
- Get Single Post Controller
- Delete Post Controller
- Add the Routes to the FastAPI Middleware StackRead the entire article here: [https://codevoweb.com/crud-restful-api-server-with-python-fastapi-and-mongodb](https://codevoweb.com/crud-restful-api-server-with-python-fastapi-and-mongodb)