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.
- URL:
/books
- Method:
GET
- Description: Retrieve a list of all books.
- Response: Returns a JSON array of books.
- 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.
- 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.
- 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.
- 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.
- Clone this repository.
- Install dependencies using
npm install
. - Start the server with
npm start
. - 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.