Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wannacry081/contacts-flask-api
This is a secure Flask-based Contacts API with user authentication and management features.
https://github.com/wannacry081/contacts-flask-api
docker flask flask-bcrypt flask-cors flask-jwt-extended flask-marshmallow flask-restful flask-sqlalchemy
Last synced: about 1 month ago
JSON representation
This is a secure Flask-based Contacts API with user authentication and management features.
- Host: GitHub
- URL: https://github.com/wannacry081/contacts-flask-api
- Owner: WannaCry081
- License: mit
- Created: 2023-07-03T04:57:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-07-09T02:39:51.000Z (over 1 year ago)
- Last Synced: 2023-09-16T19:25:38.333Z (over 1 year ago)
- Topics: docker, flask, flask-bcrypt, flask-cors, flask-jwt-extended, flask-marshmallow, flask-restful, flask-sqlalchemy
- Language: Python
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Contacts API
This is a simple Contacts API built with Flask and several popular extensions, including Flask-RESTful, Flask-SQLAlchemy, Flask-Marshmallow, Flask-Bcrypt, Flask-CORS, Flask-JWT-Extended, and more. The API allows users to manage their contact lists and provides user authentication to ensure privacy and security.
## Features
- User registration and authentication using JWT (JSON Web Tokens)
- Create, read, update, and delete operations for contacts
- User-specific contact lists to maintain privacy
- Secure password hashing using Flask-Bcrypt
- Cross-Origin Resource Sharing (CORS) support for handling cross-domain requests
- Data serialization and deserialization using Flask-Marshmallow
- Persistent storage and querying of contacts using Flask-SQLAlchemy
- Consistent RESTful API design and error handling using Flask-RESTful## Installation
1. Clone the repository:
```bash
git clone https://github.com/TheDayDreamer01/Contacts-Flask-API.git
cd contacts-flask-api
```2. Create and activate a virtual environment:
```bash
virtualenv env
source venv/bin/activate
```3. Install the dependencies:
```bash
pip install -r requirements.txt
```4. Configure the application by modifying the `config.py` file.
5. Start the server:
```bash
python server.py
```The API will be accessible at `http://localhost:5000`.
## API Endpoints
### Authentication
- `POST /api/auth/register`: Register a new user. Required fields: `username`, `password`.
- `POST /api/auth/login`: Log in with an existing user. Required fields: `username`, `password`.
- `POST /api/auth/logout`: Log out the currently logged-in user.### Contacts
- `GET /api/contacts`: Retrieve all contacts for the authenticated user.
- `GET /api/contacts/`: Retrieve a specific contact by ID.
- `POST /api/contacts`: Create a new contact. Required fields: `name`, `phone`, `email`.
- `PUT /api/contacts/`: Update an existing contact by ID. Required fields: `name`, `phone`, `email`.
- `DELETE /api/contacts/`: Delete a contact by ID.## Error Handling
The API provides consistent error responses with appropriate status codes and error messages in case of any issues. Make sure to handle errors and exceptions in your client application.
## Security
User authentication is implemented using JSON Web Tokens (JWT). Each request to protected endpoints requires the inclusion of a valid JWT token in the `Authorization` header. Unauthorized requests will be denied access.
## Contributing
Contributions to this project are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
## License
This project is licensed under the [MIT License](LICENSE). Feel free to use, modify, and distribute the code for both commercial and non-commercial purposes.