Here's the complete README in a single copy-paste format for your README.md
file:
A secure and RESTful Bookmark Management API built using Flask-RESTX, JWT Authentication, Flask-SQLAlchemy, and Passlib. This project demonstrates a professional approach to building authenticated APIs with route protection and user-specific access control.
This project is created purely for educational purposes and to demonstrate my skills to potential employers. I am not liable for any misuse, data loss, copyright issues, or third-party replication.
- User registration and login
- JWT-based authentication using
Flask-JWT-Extended
- Secure password hashing using
Passlib
- CRUD operations for personal bookmarks
- Only logged-in users can perform CRUD operations
- Users can access and modify only their own bookmarks
- RESTful API structure with built-in Swagger UI via
Flask-RESTX
- Python 3.x
- Flask
- Flask-RESTX
- Flask-JWT-Extended
- Flask-SQLAlchemy
- Passlib
-
Clone the repository
git clone https://github.com/chiragsd94/flask_bookmark_rest_api.git cd bookmark-api
-
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set environment variables Create a
.env
file with the following:FLASK_APP=run.py FLASK_ENV=development SECRET_KEY=your-secret-key JWT_SECRET_KEY=your-jwt-secret
-
Set flask environment variables Create a
.flaskenv
file with the following:FLASK_APP=api FLASK_DEBU=1 # only in development
-
Run the app
flask run
-
Register a user POST /api/v1/users/signup
{ "email": "[email protected]", "password": "yourpassword" }
-
Login to get JWT token POST /api/v1/users/login
{ "access_token": "your.jwt.token" }
-
Use the token for all protected routes Add this to headers:
Authorization: Bearer your.jwt.token
POST /api/v1/users/signup
– Register new userPOST /api/v1/users/login
– Get JWT tokenPOST /api/v1/users/logout
– Logout User
GET /api/v1/bookmarks/
– Get all bookmarks of logged-in userPOST /api/v1/bookmarks/
– Add new bookmarkGET api/v1/bookmarks/<id>
– Get a specific bookmarkPUT api/v1/bookmarks/<id>
– Update a specific bookmarkDELETE api/v1/bookmarks/<id>
– Delete a specific bookmark
- This project is developed for educational and demonstration purposes only.
- I am not responsible for any data loss, legal issues, or damages that may arise from using this code.
- All trademarks, logos, and third-party dependencies used belong to their respective owners.
Test the API using tools like:
- Insomnia
- Postman
- cURL
Make sure to include the JWT token in the Authorization
header for all protected routes.
GET /api/v1/bookmarks/
– Get all bookmarks of logged-in userPOST /api/v1/bookmarks/
– Add new bookmarkGET api/v1/bookmarks/<id>
– Get a specific bookmarkPUT api/v1/bookmarks/<id>
– Update a specific bookmarkDELETE api/v1/bookmarks/<id>
– Delete a specific bookmarkPOST /api/v1/users/logout
– Logout User
This project is licensed under the MIT License.