{"id":28171018,"url":"https://github.com/shivang21007/book-api","last_synced_at":"2025-05-15T18:15:55.999Z","repository":{"id":207361527,"uuid":"718683467","full_name":"shivang21007/book-api","owner":"shivang21007","description":"A RESTful API built with Go and Gin framework for managing a library's book inventory. This API provides endpoints for CRUD operations on books and handles book checkout/return functionality.","archived":false,"fork":false,"pushed_at":"2025-03-26T11:50:55.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T12:32:18.417Z","etag":null,"topics":["crud-api","go-api","golang","library-management-system","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shivang21007.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-14T15:34:25.000Z","updated_at":"2025-03-26T11:50:58.000Z","dependencies_parsed_at":"2023-11-15T12:27:49.773Z","dependency_job_id":"8deda7bb-7cbe-4fd6-9daf-67942492c49a","html_url":"https://github.com/shivang21007/book-api","commit_stats":null,"previous_names":["shivang21007/go-api","shivang21007/book-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivang21007%2Fbook-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivang21007%2Fbook-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivang21007%2Fbook-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shivang21007%2Fbook-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shivang21007","download_url":"https://codeload.github.com/shivang21007/book-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394711,"owners_count":22063985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crud-api","go-api","golang","library-management-system","rest-api"],"created_at":"2025-05-15T18:15:47.031Z","updated_at":"2025-05-15T18:15:55.948Z","avatar_url":"https://github.com/shivang21007.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Book Management API\n\nA RESTful API built with Go and Gin framework for managing a library's book inventory. This API provides endpoints for CRUD operations on books and handles book checkout/return functionality.\n\n## Features\n\n- Get all books\n- Get a specific book by ID\n- Create a new book\n- Update an existing book\n- Delete a book\n- Checkout a book\n- Return a book\n- Automatic inventory management\n- Duplicate book prevention\n\n## Prerequisites\n\n- Go 1.16 or higher\n- Git\n\n## Project Structure\n\n```\ngo-api/\n├── main.go\n└── README.md\n```\n\n## Getting Started\n\n1. Clone the repository:\n```bash\ngit clone \u003cyour-repository-url\u003e\ncd go-api\n```\n\n2. Install dependencies:\n```bash\ngo mod tidy\n```\n\n3. Run the application:\n```bash\ngo run main.go\n```\n\nThe server will start on `http://localhost:8080`\n\n## Running with Docker\n\nThe application is available as a Docker image on Docker Hub. You can run it using:\n\n```bash\ndocker run -it -p 8080:8080 shivang21007/book-api:v1.0\n```\n\nThis command will:\n- Pull the image from Docker Hub\n- Run it in interactive mode (-it)\n- Map port 8080 from the container to port 8080 on your host machine (-p 8080:8080)\n\nThe API will be accessible at `http://localhost:8080`\n\n## API Endpoints\n\n### 1. Get All Books\n```bash\nGET http://localhost:8080/books\n```\n\n### 2. Get Book by ID\n```bash\nGET http://localhost:8080/books/:id\n```\n\n### 3. Create New Book\n```bash\nPOST http://localhost:8080/books\n```\n\nSample request body:\n```json\n{\n    \"id\": \"5\",\n    \"title\": \"The Hobbit\",\n    \"author\": \"J.R.R. Tolkien\",\n    \"quantity\": 3\n}\n```\n\n### 4. Update Book\n```bash\nPUT http://localhost:8080/books/:id\n```\n\nSample request body:\n```json\n{\n    \"id\": \"5\",\n    \"title\": \"The Hobbit\",\n    \"author\": \"J.R.R. Tolkien\",\n    \"quantity\": 4\n}\n```\n\n### 5. Delete Book\n```bash\nDELETE http://localhost:8080/books/:id\n```\n\n### 6. Checkout Book\n```bash\nPATCH http://localhost:8080/checkout?id=:id\n```\n\n### 7. Return Book\n```bash\nPATCH http://localhost:8080/return?id=:id\n```\n\n## Testing with cURL\n\nHere are some example cURL commands to test the API:\n\n1. Get all books:\n```bash\ncurl http://localhost:8080/books\n```\n\n2. Get a specific book:\n```bash\ncurl http://localhost:8080/books/1\n```\n\n3. Create a new book:\n```bash\ncurl -X POST http://localhost:8080/books \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"id\": \"5\",\n    \"title\": \"The Hobbit\",\n    \"author\": \"J.R.R. Tolkien\",\n    \"quantity\": 3\n  }'\n```\n\n4. Update a book:\n```bash\ncurl -X PUT http://localhost:8080/books/1 \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"id\": \"1\",\n    \"title\": \"Updated Title\",\n    \"author\": \"Updated Author\",\n    \"quantity\": 5\n  }'\n```\n\n5. Delete a book:\n```bash\ncurl -X DELETE http://localhost:8080/books/1\n```\n\n6. Checkout a book:\n```bash\ncurl -X PATCH \"http://localhost:8080/checkout?id=1\"\n```\n\n7. Return a book:\n```bash\ncurl -X PATCH \"http://localhost:8080/return?id=1\"\n```\n\n## Error Handling\n\nThe API includes proper error handling for various scenarios:\n- Invalid request body (400 Bad Request)\n- Book not found (404 Not Found)\n- Duplicate book ID (409 Conflict)\n- Duplicate book title (409 Conflict)\n- Book not available for checkout (400 Bad Request)\n- Cannot return more books than original quantity (400 Bad Request)\n\n## Contributing\n\nFeel free to submit issues and enhancement requests!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshivang21007%2Fbook-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshivang21007%2Fbook-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshivang21007%2Fbook-api/lists"}