Coder Social home page Coder Social logo

bookmanagementapi's Introduction

Book Management API

This is a simple REST API for managing a list of books. It supports operations to create, read, update, and delete books.

Table of Contents

  • Installation
  • Setup
  • Running the Server
  • API Endpoints
    • Get All Books
    • Get a Book by ID
    • Create a New Book
    • Update an Existing Book
    • Delete a Book
  • Testing the API

Installation

First, make sure you have Node.js installed. Then, clone the repository.

git clone https://github.com/subhamadhikari/BookManagementAPI.git
cd BookManagementAPI

Setup

Ensure you have the necessary dependencies installed by running:

npm install

Running the Server

To start the server, use the following command:

npm start

API Endpoints

Get All Books

  • URL: /bookAPI/books
  • Method: GET
  • Success Response:
    • Code: 200 OK
    • Content: {"book": [{ "id": "1717215862912", "title": "Harry Potter", "author": "JK Rowling", "year": 1996 }, ...]}

Get a Book by ID

  • URL: /bookAPI/books/:bookID

  • Method: GET

  • URL Params: bookID=[string]

  • Success Response:

    • Code: 200 OK
    • Content: {"message": "Book Found!", "book": [{ "id": "1717215862912", "title": "Harry Potter", "author": "JK Rowling", "year": 1996 }]}
  • Error Response:

    • Code: 404 Not Found
    • Content: {"message": "Book not found"}

Create a New Book

  • URL: /bookAPI/books

  • Method: POST

  • Data Params:

    {"title": "string", "author": "string", "year": "number"}

  • Success Response:

    • Code: 201 Created
    • Content: {"message": "Book created successfully!", "book": { "id": "1717215862913", "title": "New Book", "author": "Author", "year": 2023 }}
  • Error Response:

    • Code: 400 Bad Request
    • Content: {"message": "Enter all the required fields", "book": null}

Update an Existing Book

  • URL: /bookAPI/books/:bookID

  • Method: PUT

  • URL Params: bookID=[string]

  • Data Params:

    {"title": "string", "author": "string", "year": "number"}

  • Success Response:

    • Code: 200 OK
    • Content: {"message": "Book has been successfully updated", "book": { "id": "1717215862912", "title": "Updated Title", "author": "Updated Author", "year": 2023 }}
  • Error Response:

    • Code: 404 Not Found
    • Content: {"message": "Book not found"}

Delete a Book

  • URL: /bookAPI/books/:bookID

  • Method: DELETE

  • URL Params: bookID=[string]

  • Success Response:

    • Code: 200 OK
    • Content: {"message": "Book deleted successfully!", "book": { "id": "1717215862912", "title": "Deleted Book", "author": "Deleted Author", "year": 2023 }}
  • Error Response:

    • Code: 404 Not Found
    • Content: {"message": "Book not found"}

Testing the API

You can test the API endpoints using a tool like Postman.

Get All Books

Get a Book by ID

Create a New Book

{
  "title": "New Book",
  "author": "Author",
  "year": 2023
}

Update a Book

{
  "title": "Updated Title",
  "author": "Updated Author",
  "year": 2023
}

Delete a Book

bookmanagementapi's People

Contributors

subhamadhikari avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.