Skip to content

sonalgaud12/Books-Api-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Book Management API

Overview

This project is a simple Book Management API built using the Go programming language and the Gin web framework. It provides endpoints to perform basic CRUD operations on a collection of books, such as retrieving book details, adding new books, and updating book quantities for checkout and return operations.

Features

  • Retrieve a list of all books.
  • Retrieve a book by its ID.
  • Add a new book to the collection.
  • Checkout a book (reduce quantity).
  • Return a book (increase quantity).

Endpoints

Method Endpoint Description
GET /books Get a list of all books.
GET /books/:id Get details of a specific book.
POST /books Add a new book to the collection.
PATCH /checkout Checkout a book by ID (decrease quantity).
PATCH /return Return a book by ID (increase quantity).

Technologies Used

  • Programming Language: Go
  • Web Framework: Gin

Prerequisites

  • Install Go
  • Install dependencies:
    go mod init books-api
    go get -u github.com/gin-gonic/gin

Running the Application

  1. Clone the repository:
    git clone https://github.com/your-repo/book-management-api.git
  2. Navigate to the project directory:
    cd book-management-api
  3. Run the application:
    go run main.go
  4. The API will be available at http://localhost:8080

Example JSON Request for Adding a Book

{
    "id": "4",
    "title": "Hamlet",
    "author": "William Shakespeare",
    "quantity": 2
}

Operating System Used

This project has been tested and developed on:

  • Windows
  • Linux
  • macOS

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages