Skip to content
Srikar Chowdary Kantamani edited this page Apr 22, 2022 · 1 revision

API

The below API's are used to fetch the details from database and return it to the calling API so that data in FRONTEND can be rendered based on the data stored in BACKEND

  1. Get Genre API
  2. Get Particular Genre API
  3. Get Books based on Genre
  4. Insert Books into Database
  5. API to return Book Details by ID
  6. API to post book reviews
  7. API to fetch book reviews
  8. API to fetch ratings of a book by ID
  9. API to Fetch the Top 5 books for a Given Genre
  10. API to Register User
  11. API to authenticate a user login
  12. API to add a book to users wishlists

The Postman commands and sample examples can be viewed here : https://documenter.getpostman.com/view/19432934/UVeGqRHi

1. Get Genre API

Method : GET

This getGenres API is used to fetch all the Genres Present in The Genres Table from the Database.

Sample API and Sample Output Sample GetGenre API

Sample Output : Sample Output

Sample Demo : Postman

2. Get Particular Genre API

localhost:8080/api/getGenres/5

Method : GET The getGenres/{id} API is used to fetch a particular Genre from the database based on the Genre ID requested from the frontend Webpage.

Sample API and Sample Output Get a Particular Genre

Sample Demo : Postman(1)

3. API to Insert books into Database

Method Type: POST API will receive a POST request from the body in JSON format. This JSON is Decoded to a struct type Book and insert the values into database books.db books table as per the user's request.

Sample API usage via POSTMAN

image

After the insertion API will return values in JSON format of the information inserted in DB and the ID generated for the book.

Sample Demo : Postman(2)

4. API to fetch Books from the Database tagged with requested GenreID

Method : GET API will receive a request with Genre ID query in URL string and returns a array of all the books in DB tagged with the requested Genre ID in JSON format.

Sample API usage via POSTMAN

image

Sample Demo : Postman(3)

5. API to return Book Details by ID

Method : GET The /api/getBook API is used to fetch a particular Book by its ID as requested from the frontend Webpage.

Sample API usage and Output

image

6. API to post book reviews

Method Type: POST API will receive a POST request from the body in JSON format. This JSON is Decoded to a struct type Reviews and insert the values into database books.db books table as per the user's request.

  1. It will insert the review datas to Review table as and when any user writes Reviews about the book.
  2. It also calculates the review and ratin g count and increments it in the Book Table.

Sample API usage via POSTMAN

Screenshot (40)

After the insertion API will return values in JSON format of the information inserted in DB and the ID generated for the book review.

7. API to fetch book reviews

Method Type: GET API will receive a GET request from the body in JSON format. This JSON is Decoded to a struct type Review and insert the values into database books.db books table as per the user's request. This API returns top 10 the reviews for that particular BookID. And based on the Review-Index, it returns the next 10 revies starting from index number Review-index

Sample API usage via POSTMAN

Screenshot (41)

8. API to fetch ratings of a book by ID

Method Type: GET API will receive a GET request from the body in JSON format. This JSON is Decoded to a struct type Book and insert the values into database books.db books table as per the user's request.

Sample API usage via POSTMAN image

9. API to Fetch the Top 5 books for a Given Genre

Method Type: GET The /fetchTopBooksForGenre?id=5 API is used to fetch the top 5 Books for any given Genre ID

Sample API usage and Output

Screenshot (46)

Postman 2022-04-20 21-37-43

10. API to Register User

Method Type : POST This API is to register a new user account.

Sample API usage and output

image

11. API to authenticate User login

Method Type : POST This api will authenticate users email and password and return a json body that contains the status(true / false).

Sample API usage and output

image

12. API to add a book to users wishlists

Method Type : POST

This api will associate book ids when a user adds a book to his/her wishlist based on users id.

Sample API usage and output image