CH

CodeHub

API Playground

← All collections

Collection Docs

Books Collection

Library catalog demonstrating pagination, sorting, and boolean filtering.

Fields

text

title

Required; book title.

text

author

Required; author name.

text

category

Required; genre or category.

number

publishedYear

Required; between 1000 and current year.

checkbox

available

Boolean; defaults to true.

REST Endpoints

GET/api/books

List books. Use ?limit=10&page=2 for pagination, ?sort=title for sorting.

GET/api/books/:id

Fetch one book by document ID.

POST/api/books

Create a book. Include title, author, category, publishedYear, available.

PATCH/api/books/:id

Update book fields.

DELETE/api/books/:id

Delete a book document.

Teaching Tips

  • Paginate: ?limit=20&page=1
  • Sort: ?sort=publishedYear (ascending) or ?sort=-publishedYear (descending)
  • Filter available books: ?where[available][equals]=true
  • Combine filters: ?where[available][equals]=true&sort=-publishedYear&limit=10