spm999 / book-api

Book Store Api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Book API

This is a simple RESTful API built using Node.js and Express for managing a collection of books. The API supports basic CRUD (Create, Read, Update, Delete) operations on the book resources.

Endpoints

Get all books

  • URL: /books
  • Method: GET
  • Description: Retrieve a list of all books.
  • Response: Returns a JSON array of books.

Get a specific book by ID

  • URL: /books/:id
  • Method: GET
  • Description: Retrieve details of a specific book by providing its ID in the request parameters.
  • Response: Returns a JSON object representing the book if found, or a 404 status with an error message if not found.

Add a new book

  • URL: /books
  • Method: POST
  • Description: Add a new book to the collection.
  • Request Body: Should include a JSON object representing the new book.
  • Response: Returns the newly added book with a 201 status.

Update a book by ID

  • URL: /books/:id
  • Method: PUT
  • Description: Update details of a specific book by providing its ID in the request parameters.
  • Request Body: Should include a JSON object representing the updated book.
  • Response: Returns the updated book if found, or a 404 status with an error message if not found.

Delete a book by ID

  • URL: /books/:id
  • Method: DELETE
  • Description: Delete a specific book by providing its ID in the request parameters.
  • Response: Returns the deleted book if found, or a 404 status with an error message if not found.

Usage

  1. Clone this repository.
  2. Install dependencies using npm install.
  3. Start the server with npm start.
  4. Access the API at http://localhost:3000/books.

Feel free to use and modify this API for your own projects. For more details on how to interact with the API, refer to the provided endpoints documentation.

About

Book Store Api


Languages

Language:JavaScript 100.0%