Welcome to the Virtual Bookstore API, a robust and user-friendly solution for managing your online bookstore. Built with Flask, Flask-SQLAlchemy, Flask-Restful, Flask-Marshmallow, Flask-Bcrypt, Flask-Cors and Flask-JWT-Extended, this RESTful API seamlessly integrates with SQLite and MySQL databases, providing a versatile and scalable platform. With features like book retrieval, addition, update, deletion, user authentication, and admin privileges, the Virtual Bookstore API empowers you to efficiently manage your inventory. Experience the power and flexibility of the Virtual Bookstore API today and create an exceptional online bookstore experience.
- Python 3.10.0
- Flask
- Flask-SQLAlchemy
- Flask-JWT-Extended
- SQLite (for local development)
- MySQL (for production)
- Clone the repository:
git clone https://github.com/TheDayDreamer01/Bookstore-Flask-API.git
cd bookstore-flask-api
- Create a virtual environment:
virtualenv env
- Activate the virtual environment:
- For Linux/Mac:
source env/bin/activate
- For Windows:
env\Scripts\activate
- Install the dependencies:
pip install -r requirements.txt
- Run the application:
python server.py
The default database used in this project is SQLite3. However, you can also use it in MySQL by configuring the config.py
in the Config/config.py
directory. Moreover, the API should now be accessible at https://localhost:5000
.
-
POST /api/auth/signin
- User sign-in with email and password.
- Returns a JWT token for authentication.
-
POST /api/auth/signup
- User sign-up with username, email, and password.
- Creates a new user in the database.
-
POST /api/auth/signout
- User sign-out.
- Invalidates the JWT token.
-
GET /api/book
- Get a list of all books.
- No authentication required.
-
GET /api/book/<book_id>/<book_title>
- Get details of a specific book.
- No authentication required.
-
GET /api/book/user/<user_id>
- Get the authenticated user's book list.
-
POST /api/book/user/<user_id>
- Add a book to the authenticated user's book list.
-
DELETE /api/book/<book_id>
- Delete a book from the authenticated user's book list.
-
GET /api/user/<user_id>
- Get the authenticated user's profile.
-
PUT /api/user/<user_id>
- Update the authenticated user's profile.
-
POST /api/user/<user_id>
- Update the authenticated user's password.
-
DELETE /api/user/<user_id>
- Delete the authenticated user's account.
-
POST /api/admin/book
- Add a book (admin only).
-
PUT /api/admin/book
- Update a book (admin only).
-
DELETE /api/admin/book
- Delete a book (admin only).
-
GET /api/admin/user
- Get a list of all users (admin only).
-
DELETE /api/admin/user
- Delete a user (admin only).
Contributions to the project are welcome. If you find any issues or have any suggestions for improvement, feel free to submit a pull request or open an issue on the repository.
This project is licensed under the MIT License. See the LICENSE file for more details.