Welcome to the Library Management API
The Library Management API is a comprehensive REST API for managing books, users, and their collections. Built with Spring Boot, this API provides secure endpoints for creating, reading, updating, and deleting resources.Base URL
API Version
API Overview
The API provides three main endpoint categories:Authentication
User registration and login endpoints
Books
Complete CRUD operations for book management
Users
User management and book collection operations
API Versioning
All API endpoints are versioned to ensure backward compatibility. The current version is v1, and all endpoints are prefixed with/api/v1.
Endpoint Structure:
http://localhost:8081/api/v1/{resource}Example: http://localhost:8081/api/v1/books/findAllHTTP Methods
The API follows RESTful conventions and uses standard HTTP methods:| Method | Usage | Description |
|---|---|---|
| GET | Read operations | Retrieve resources or lists of resources |
| POST | Create operations | Create new resources or perform authentication |
| PUT | Update operations | Update existing resources |
| DELETE | Delete operations | Remove resources from the system |
Authentication
The API uses JWT (JSON Web Token) authentication to secure endpoints. Most endpoints require a valid JWT token in the request header.Authentication Flow
- Register: Create a new user account via
/api/v1/auth/register - Login: Authenticate and receive a JWT token via
/api/v1/auth/login - Use Token: Include the token in subsequent requests
Token Format
Include the JWT token in theAuthorization header using the Bearer scheme:
The token is returned in the response after successful login or registration.
Public Endpoints
The following endpoints do NOT require authentication:POST /api/v1/auth/login- User loginPOST /api/v1/auth/register- User registration- All Swagger UI endpoints (
/swagger-ui/**,/v3/api-docs/**)
Protected Endpoints
All other endpoints require a valid JWT token in the Authorization header:- All
/api/v1/books/**endpoints (except public ones) - All
/api/v1/users/**endpoints
Security Scheme: HTTP Bearer authentication with JWT formatHeader: AuthorizationScheme: bearer
Response Formats
Success Responses
Successful requests return JSON responses with appropriate HTTP status codes:- 200 OK: Successful GET, PUT, or DELETE operation
- 201 Created: Successful POST operation (resource created)
Error Responses
Error responses include detailed information about what went wrong:Common HTTP Status Codes
| Code | Meaning | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource successfully created |
| 400 | Bad Request | Invalid request parameters or body |
| 401 | Unauthorized | Missing or invalid authentication token |
| 404 | Not Found | Requested resource not found |
| 409 | Conflict | Resource already exists (e.g., duplicate email) |
| 500 | Internal Server Error | Server-side error occurred |
Pagination
List endpoints (findAll) support pagination with the following query parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 0 | Page number (0-indexed) |
size | integer | 10 | Number of items per page |
Pagination Response Format
Pages are 0-indexed in the API but displayed as 1-indexed in the response.
Data Format
UUID Identifiers
All resources use UUID (Universally Unique Identifier) format for IDs:Date/Time Format
All timestamps follow the ISO 8601 format:Environment Configuration
The API supports multiple deployment environments:Development Server
URL:
http://localhost:8081For local development and testingProduction Server
URL:
http://books:8081For production deploymentNext Steps
Try Swagger UI
Interactive API documentation and testing
Authentication Guide
Learn how to authenticate with the API