Basic

Library

Library endpoint for Personal Digital Book Library (PDBL)

These endpoints allow you to create, read, update and delete library books and their reviews. Perfect for building a Personal Digital Book Library (PDBL) application where users can manage their book collections and reviews.

These endpoints support pagination and sorting. Read more about these features here.

The Library Book model

PropTypeDefault
id
string
-
title
string
-
description
string
-
metadata
object
-
image
object
-
reviews
array
-
created
Date
-
updated
Date
-
owner
Profile
-

The Library Book Review model

PropTypeDefault
id
string
-
comment
string
-
rating
number
-
reviewer
Profile
-
book
LibraryBook
-
created
Date
-
updated
Date
-

Get all library books

GET/library

Retrieve all library books.

Response
{
  "data": [
    {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "title": "The Great Gatsby",
      "description": "A classic American novel set in the Jazz Age, exploring themes of wealth, love, and the American Dream.",
      "metadata": {
        "author": "F. Scott Fitzgerald",
        "isbn": "9780743273565",
        "publicationDate": "1925-04-10T00:00:00.000Z",
        "publisher": "Charles Scribner's Sons",
        "pageCount": 180,
        "language": "English",
        "genres": ["Fiction", "Classic Literature"],
        "format": "Hardcover",
        "price": 12.99
      },
      "image": {
        "url": "https://example.com/gatsby-cover.jpg",
        "alt": "The Great Gatsby book cover"
      },
      "reviews": [
        {
          "id": "review-id",
          "comment": "A masterpiece of American literature!",
          "rating": 5,
          "reviewer": {
            "name": "john_doe",
            "email": "john@example.com",
            "avatar": {
              "url": "https://example.com/avatar.jpg",
              "alt": "John's avatar"
            }
          },
          "created": "2025-01-01T12:00:00.000Z",
          "updated": "2025-01-01T12:00:00.000Z"
        }
      ],
      "created": "2025-01-01T12:00:00.000Z",
      "updated": "2025-01-01T12:00:00.000Z",
      "owner": {
        "name": "admin",
        "email": "admin@example.com",
        "bio": "Book library administrator",
        "avatar": {
          "url": "https://example.com/admin-avatar.jpg",
          "alt": "Admin avatar"
        },
        "banner": {
          "url": "https://example.com/admin-banner.jpg",
          "alt": "Admin banner"
        }
      }
    }
    // ...
  ],
  "meta": {
    "isFirstPage": true,
    "isLastPage": true,
    "currentPage": 1,
    "previousPage": null,
    "nextPage": null,
    "pageCount": 1,
    "totalCount": 1
  }
}

Get single library book

GET/library/<id>

Retrieve a single library book by its id, including all associated reviews.

Response
{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "title": "The Great Gatsby",
    "description": "A classic American novel set in the Jazz Age, exploring themes of wealth, love, and the American Dream.",
    "metadata": {
      "author": "F. Scott Fitzgerald",
      "isbn": "9780743273565",
      "publicationDate": "1925-04-10T00:00:00.000Z",
      "publisher": "Charles Scribner's Sons",
      "pageCount": 180,
      "language": "English",
      "genres": ["Fiction", "Classic Literature"],
      "format": "Hardcover",
      "price": 12.99
    },
    "image": {
      "url": "https://example.com/gatsby-cover.jpg",
      "alt": "The Great Gatsby book cover"
    },
    "reviews": [
      {
        "id": "review-id",
        "comment": "A masterpiece of American literature!",
        "rating": 5,
        "reviewer": {
          "name": "john_doe",
          "email": "john@example.com",
          "avatar": {
            "url": "https://example.com/avatar.jpg",
            "alt": "John's avatar"
          }
        },
        "created": "2025-01-01T12:00:00.000Z",
        "updated": "2025-01-01T12:00:00.000Z"
      }
    ],
    "created": "2025-01-01T12:00:00.000Z",
    "updated": "2025-01-01T12:00:00.000Z",
    "owner": {
      "name": "admin",
      "email": "admin@example.com",
      "bio": "Book library administrator",
      "avatar": {
        "url": "https://example.com/admin-avatar.jpg",
        "alt": "Admin avatar"
      },
      "banner": {
        "url": "https://example.com/admin-banner.jpg",
        "alt": "Admin banner"
      }
    }
  },
  "meta": {}
}

Create library book

POST/library

Create a new library book entry. Only authenticated users can create books.

Please note that the image.url property must be a fully formed URL that links to a live and publicly accessible image. The API will check the provided URL and if it cannot be accessed publicly you will receive a 400 Bad Request error response.

Request
{
  "title": "To Kill a Mockingbird",
  "description": "A gripping tale of racial injustice and childhood innocence.",
  "metadata": {
    "author": "Harper Lee",
    "isbn": "9780061120084",
    "publicationDate": "1960-07-11T00:00:00.000Z",
    "publisher": "J.B. Lippincott & Co.",
    "pageCount": 376,
    "language": "English",
    "genres": ["Fiction", "Classic", "Historical Fiction"],
    "format": "Paperback",
    "price": 15.99
  },
  "image": {
    "url": "https://example.com/mockingbird-cover.jpg",
    "alt": "To Kill a Mockingbird book cover"
  }
}
Response
{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "title": "To Kill a Mockingbird",
    "description": "A gripping tale of racial injustice and childhood innocence.",
    "metadata": {
      "author": "Harper Lee",
      "isbn": "9780061120084",
      "publicationDate": "1960-07-11T00:00:00.000Z",
      "publisher": "J.B. Lippincott & Co.",
      "pageCount": 376,
      "language": "English",
      "genres": ["Fiction", "Classic", "Historical Fiction"],
      "format": "Paperback",
      "price": 15.99
    },
    "image": {
      "url": "https://example.com/mockingbird-cover.jpg",
      "alt": "To Kill a Mockingbird book cover"
    },
    "reviews": [],
    "created": "2025-01-01T12:00:00.000Z",
    "updated": "2025-01-01T12:00:00.000Z",
    "owner": {
      "name": "admin",
      "email": "admin@example.com",
      "bio": "Book library administrator",
      "avatar": {
        "url": "https://example.com/admin-avatar.jpg",
        "alt": "Admin avatar"
      },
      "banner": {
        "url": "https://example.com/admin-banner.jpg",
        "alt": "Admin banner"
      }
    }
  },
  "meta": {}
}

Update library book

PUT/library/<id>

Update a library book by its id. Only the owner of the book can update it. You must provide at least one field to update.

Please note that the image.url property must be a fully formed URL that links to a live and publicly accessible image. The API will check the provided URL and if it cannot be accessed publicly you will receive a 400 Bad Request error response.

Request
// You can update any combination of the properties of the book.
{
  "description": "An updated description of this classic novel about moral courage.",
  "metadata": {
    "pageCount": 281,
    "format": "eBook",
    "genres": ["Fiction", "Classic", "Historical Fiction", "Coming of Age"],
    "price": 19.99
  },
  "image": {
    "url": "https://example.com/new-mockingbird-cover.jpg",
    "alt": "Updated To Kill a Mockingbird cover"
  }
}
Response
{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "title": "To Kill a Mockingbird",
    "description": "An updated description of this classic novel about moral courage.",
    "metadata": {
      "author": "Harper Lee",
      "isbn": "9780061120084",
      "publicationDate": "1960-07-11T00:00:00.000Z",
      "publisher": "J.B. Lippincott & Co.",
      "pageCount": 281,
      "language": "English",
      "genres": ["Fiction", "Classic", "Historical Fiction", "Coming of Age"],
      "format": "eBook",
      "price": 19.99
    },
    "image": {
      "url": "https://example.com/new-mockingbird-cover.jpg",
      "alt": "Updated To Kill a Mockingbird cover"
    },
    "reviews": [],
    "created": "2025-01-01T12:00:00.000Z",
    "updated": "2025-01-01T12:30:00.000Z",
    "owner": {
      "name": "admin",
      "email": "admin@example.com",
      "bio": "Book library administrator",
      "avatar": {
        "url": "https://example.com/admin-avatar.jpg",
        "alt": "Admin avatar"
      },
      "banner": {
        "url": "https://example.com/admin-banner.jpg",
        "alt": "Admin banner"
      }
    }
  },
  "meta": {}
}

Delete library book

DELETE/library/<id>

Delete a library book by its id. Only the owner of the book can delete it. This will also delete all associated reviews.

Returns an empty 204 No Content response on success.


Create review

POST/library/<id>/reviews

Create a new review for a library book. Only authenticated users can create reviews.

Request
{
  "comment": "This book changed my perspective on so many things. The character development is incredible and the themes are still relevant today.",
  "rating": 5
}
Response
{
  "data": {
    "id": "new-review-id",
    "comment": "This book changed my perspective on so many things. The character development is incredible and the themes are still relevant today.",
    "rating": 5,
    "reviewer": {
      "name": "current_user",
      "email": "user@example.com",
      "bio": "Literature student",
      "avatar": {
        "url": "https://example.com/user-avatar.jpg",
        "alt": "User's avatar"
      },
      "banner": {
        "url": "https://example.com/user-banner.jpg",
        "alt": "User's banner"
      }
    },
    "book": {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "title": "To Kill a Mockingbird",
      "image": {
        "url": "https://example.com/mockingbird-cover.jpg",
        "alt": "Book cover"
      },
      "owner": {
        "name": "admin",
        "email": "admin@example.com"
      }
    },
    "created": "2025-01-01T12:00:00.000Z",
    "updated": "2025-01-01T12:00:00.000Z"
  },
  "meta": {}
}

Update review

PUT/library/<id>/reviews/<reviewId>

Update a review by its id. Only the author of the review can update it. You must provide at least one field to update.

Request
// You can update any combination of the properties of the review.
{
  "comment": "After re-reading this book, I appreciate it even more. The symbolism is masterful.",
  "rating": 5
}
Response
{
  "data": {
    "id": "review-id",
    "comment": "After re-reading this book, I appreciate it even more. The symbolism is masterful.",
    "rating": 5,
    "reviewer": {
      "name": "current_user",
      "email": "user@example.com",
      "bio": "Literature student",
      "avatar": {
        "url": "https://example.com/user-avatar.jpg",
        "alt": "User's avatar"
      },
      "banner": {
        "url": "https://example.com/user-banner.jpg",
        "alt": "User's banner"
      }
    },
    "book": {
      "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "title": "To Kill a Mockingbird",
      "image": {
        "url": "https://example.com/mockingbird-cover.jpg",
        "alt": "Book cover"
      },
      "owner": {
        "name": "admin",
        "email": "admin@example.com"
      }
    },
    "created": "2025-01-01T12:00:00.000Z",
    "updated": "2025-01-01T12:30:00.000Z"
  },
  "meta": {}
}

Delete review

DELETE/library/<id>/reviews/<reviewId>

Delete a review by its id. Only the author of the review or the owner of the book can delete it.

Returns an empty 204 No Content response on success.

On this page