Giter Club home page Giter Club logo

sraveshnandan / my-first-rest-api Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 22 KB

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

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

License: MIT License

JavaScript 100.00%
api-endpoints error-handling express mongodb node-js programming-books restful-api

my-first-rest-api's Introduction

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!

my-first-rest-api's People

Stargazers

 avatar  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.