Skip to main content
GET
/
api
/
books
List Books
curl --request GET \
  --url https://api.example.com/api/books
{
  "success": true,
  "data": {
    "content": [
      {
        "id": 123,
        "isbn": "<string>",
        "title": "<string>",
        "description": "<string>",
        "coverImageUrl": "<string>",
        "authors": [
          {
            "id": 123,
            "name": "<string>"
          }
        ],
        "category": {
          "id": 123,
          "name": "<string>"
        }
      }
    ],
    "pageable": {},
    "totalPages": 123,
    "totalElements": 123,
    "size": 123,
    "number": 123,
    "first": true,
    "last": true,
    "empty": true
  }
}

Endpoint

GET /api/books
Retrieves a paginated list of all books in the library system.

Authentication

This endpoint is publicly accessible and does not require authentication.

Query Parameters

page
integer
default:"0"
Page number (zero-based)
size
integer
default:"20"
Number of items per page
sort
string
default:"id"
Sort field and direction (e.g., id, title,asc, isbn,desc)

Response

success
boolean
required
Indicates if the request was successful
data
object
required
Paginated book data
content
array
required
Array of book objects
id
long
Unique identifier for the book
isbn
string
International Standard Book Number (normalized format)
title
string
Book title
description
string
Book description (max 1000 characters)
coverImageUrl
string
URL to the book’s cover image
authors
array
Array of author objects
id
long
Author’s unique identifier
name
string
Author’s name
category
object
Category object
id
long
Category’s unique identifier
name
string
Category name
pageable
object
Pagination metadata
totalPages
integer
Total number of pages
totalElements
long
Total number of books
size
integer
Number of items per page
number
integer
Current page number (zero-based)
first
boolean
Whether this is the first page
last
boolean
Whether this is the last page
empty
boolean
Whether the page is empty

Example Request

curl -X GET "http://localhost:8080/api/books?page=0&size=10&sort=title,asc"

Example Response

{
  "success": true,
  "data": {
    "content": [
      {
        "id": 1,
        "isbn": "9780134685991",
        "title": "Effective Java",
        "description": "A comprehensive guide to Java programming best practices and design patterns.",
        "coverImageUrl": "https://example.com/covers/effective-java.jpg",
        "authors": [
          {
            "id": 1,
            "name": "Joshua Bloch"
          }
        ],
        "category": {
          "id": 2,
          "name": "Programming"
        }
      },
      {
        "id": 2,
        "isbn": "9780132350884",
        "title": "Clean Code",
        "description": "A handbook of agile software craftsmanship.",
        "coverImageUrl": "https://example.com/covers/clean-code.jpg",
        "authors": [
          {
            "id": 2,
            "name": "Robert C. Martin"
          }
        ],
        "category": {
          "id": 2,
          "name": "Programming"
        }
      }
    ],
    "pageable": {
      "sort": {
        "sorted": true,
        "unsorted": false,
        "empty": false
      },
      "pageNumber": 0,
      "pageSize": 10,
      "offset": 0,
      "paged": true,
      "unpaged": false
    },
    "totalPages": 5,
    "totalElements": 42,
    "size": 10,
    "number": 0,
    "first": true,
    "last": false,
    "empty": false
  },
  "message": null
}

Notes

  • The default page size is 20 items
  • Results are sorted by id by default
  • ISBN values are stored in normalized format (hyphens and spaces removed)
  • Each book must have at least one author (many-to-many relationship)
  • Each book belongs to exactly one category

Build docs developers (and LLMs) love