Skip to content

Book API is a RESTful API built with Express, MongoDB, and Node.js, offering details on 300+ programming books. Explore various API endpoints to fetch book information, categories, names, and filter books based on criteria like author, category, and page count. Build seamless web applications with this API and take advantage of its error handling

License

Notifications You must be signed in to change notification settings

sraveshnandan/MY-FIRST-REST-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Book API 📚

This is a RESTful API built with Express, MongoDB, and Node.js that provides information about a collection of books. The API contains details on 300+ books related to programming and other categories. It offers various endpoints to fetch book details, categories, names, and supports filtering based on categories, ID, author's name, page count, and more.

Demo 🎉

https://books-api-dhc6.onrender.com/api/v1/books/

Getting Started ✨

To get started with this API, follow the steps below:

Prerequisites

  • Node.js (at least version 12.x)
  • MongoDB database
  • express
  • body-parser
  • mongoose

Installation

  1. Clone the repository:
git clone https://github.com/sraveshnandan/MY-FIRST-REST-API.git
cd book-api
  1. Install dependencies:
npm install
  1. Configure MongoDB connection:

    Open db.js and replace the MongoDB connection URL with your actual database URL, or you can create your own environment variable file to load your credientials from .env file, which is the secure way to manage your credientials.

Running the API

Run the following command to start the server:

npm run dev

The API will be accessible at http://localhost:3000.

Endpoints

Get All Books

Retrieve details of all books in the database.

  • Endpoint: /api/v1/books/
  • Method: GET
  • Response: JSON object containing an array of book details.

Get All Categories

Fetch details of all book categories available.

  • Endpoint: /api/v1/books/categories
  • Method: GET
  • Response: JSON object containing an array of category details.

Get All Book Names

Get the names of all the books available in the database.

  • Endpoint: /api/v1/name/
  • Method: GET
  • Response: JSON object containing an array of book names.

Filter Books

Filter the books based on various criteria such as category, ID, author's name, page count, and more.

  • Endpoint: /api/v1/books/filter
  • Method: GET
  • Query Parameters:
    • category: Filter books by category.

    • Add more query parameters as needed based on your API implementation.

Error Handling

The API handles errors gracefully and returns appropriate status codes and error messages for invalid requests or server errors.

Example Usage

Here are some example requests to demonstrate how to use the API:

  • Get all books:

    GET http://localhost:3000/api/v1/books/
  • Get all books by count

 GET http://localhost:3000/api/v1/books/?count=your desired number
  • Get all categories:

    GET http://localhost:3000/api/v1/books/categories
  • Get all book names:

    GET http://localhost:3000/api/v1/name/
  • Filter books by category:

    GET http://localhost:3000/api/v1/books/filter?category=programming
  • Filter books by author's name:

    GET http://localhost:3000/api/v1/books/filter?author=John%20Doe

Contributing

Contributions to this project are welcome! If you find any issues or have suggestions for improvements, please create a pull request or open an issue on the repository.

License

This project is licensed under the MIT License. Feel free to use and modify the code as per the terms of the license.

Acknowledgments

  • Special thanks to all contributors and open-source libraries used in this project.

😀 Happy coding!

About

Book API is a RESTful API built with Express, MongoDB, and Node.js, offering details on 300+ programming books. Explore various API endpoints to fetch book information, categories, names, and filter books based on criteria like author, category, and page count. Build seamless web applications with this API and take advantage of its error handling

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published