This documentation provides details about the Book and User APIs, which allow book management and user-related actions.
Use a virtual environment and follow the setup
pip install -r requiremets.txt
python manage.py makemigrations
python manage.py migrate --run-syncdb
You can create an admin user with
python manage.py createsuperuser
for docker you can proceed after getting interactive shell
docker exec <CONTAINER_NAME> -it /bin/bash
To run use this command
python manage.py runserver
To run with docker
sudo docker-compose up --build
The docker volume has not been set. If you are changing code while the server is running you may need to restart the server for the changes to take effect.
- Endpoint:
POST /api/user/register
- Description: Register a new user in the system.
Parameter | Type | Description |
---|---|---|
username |
String | User's desired username |
email |
String | User's email address |
password |
String | User's password |
- Endpoint:
POST /api/user/login
- Description: Log in an existing user to obtain authentication tokens.
Parameter | Type | Description |
---|---|---|
username |
String | User's username |
password |
String | User's password |
- Endpoint:
GET /api/user/list
- Description: Retrieve a list of all registered users.
Authentication Required | Admin Access Required |
---|---|
Yes | Yes |
- Endpoint:
GET /api/user/view/<str:id>
- Description: View details of a specific user by providing their user ID.
Authentication Required | Admin Access Required |
---|---|
Yes | Yes |
- Endpoint:
POST /api/book/add
- Description: Add a new book record to the library.
Parameter | Type | Description |
---|---|---|
title |
String | Book title |
ISBN |
String | International Standard Book Number |
genre |
String | Book genre |
Published_date |
Date | Published date of the book |
- Endpoint:
GET /api/book/list
- Description: Retrieve a list of all books in the library.
- Endpoint:
GET /api/book/get/<int:id>/
- Description: Fetch details of a specific book by providing its Book ID.
- Endpoint:
PUT /api/book/details/<int:id>/
- Description: Assign details to a book or update existing book details.
Parameter | Type | Description |
---|---|---|
NumberOfPages |
Int | Number of pages in the book |
language |
String | Language of the book |
publisher |
String | Publisher of the book |
- Endpoint:
POST /api/book/borrow/<int:id>/
- Description: Record the borrowing of a book by linking a user with a book.
- Endpoint:
PUT /api/book/return/<int:id>/
- Description: Update the system when a book is returned.
- Endpoint:
GET /api/book/list-borrowed/
- Description: List all books currently borrowed from the library.
- Register User: Send a POST request to
/api/user/register/
with the parameters:username
,email
,password
. - Login User: Send a POST request to
/api/user/login
with the parameters:username
,password
. Obtain authentication tokens. - List Users: Send a GET request to
/api/user/list
with valid authentication tokens. - View User Details: Send a GET request to
/api/user/view/<str:id>
with valid authentication tokens. - Add Book: Send a POST request to
/api/book/add
with the parameters:title
,ISBN
,genre
,Published_date
. - List All Books: Send a GET request to
/api/book/list
. - Get Book by ID: Send a GET request to
/api/book/get/<int:id>
. - Assign/Update Book Details: Send a PUT request to
/api/book/details/<int:id>
with parameters:NumberOfPages
,language
,publisher
. - Borrow a Book: Send a POST request to
/api/book/borrow/<int:id>/
with valid authentication tokens. - Return a Book: Send a PUT request to
/api/book/return/<int:id>/
with valid authentication tokens. - List All Borrowed Books: Send a GET request to
/api/book/list-borrowed/
with valid authentication tokens.
- User Actions: Registration and login are open to the public. Other actions require authentication.
- Admin Access: Certain actions, such as viewing user details and listing users, require admin access in addition to authentication.
- Token Usage: Include authentication tokens obtained during login in the headers of authenticated requests.