This is an API based on FastAPI designed to send contact forms via SMTP and Discord Webhooks, then receive notifications through Email and Discord, while also storing the information in PostgreSQL.
MIT License
This is FastAPI-based API is designed for submitting contact forms and receiving notifications. Follow the instructions below to install and use the API.
The API is built using the following libraries:
To run the API locally, follow these steps:
Note:
Clone the repository:
git clone https://github.com/nguyenhongthe/contact_form_api.git
cd contact_form_api
Install the required dependencies:
pip install -r requirements.txt
Create a .env
file in the root directory and set the necessary environment variables. Refer to the .env.example
file for guidance.
Run the API server:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
The API should now be up and running at http://localhost:8000.
API documentation can be accessed through the following URLs:
To submit a contact form, send a POST request to the /submit-contact-form
endpoint with the following form parameters:
name
: Name of the senderemail
: Email of the senderphone
: Phone number of the sendertitle
: Title of the messagemessage
: Message contentExample using cURL:
curl -X 'POST' \
'http://localhost:8000/submit-contact-form' \
-H 'accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'name=My%20Name&email=myname%40gmail.com&phone=0123456789&title=Hello&message=Hello%20World'
The application uses environment variables for configuration. Make sure to define these variables in the .env
file before running the application. Refer to the .env.example
file for a list of required variables.
For detailed configuration options, consult the Settings
class in the main.py
file.
Contributions are welcome! Feel free to open an issue or submit a pull request if you find a bug or want to improve the API.
This project is licensed under the MIT License. See LICENSE for more information.