Introduction: Why Track Reading Progress?

Welcome back! In the previous lesson, you learned how to build a book catalog and search for books in your reading tracker API. Now, let’s take the next step: tracking your own reading progress and organizing your personal shelf.

Imagine you want to see which books you’ve finished, which ones you’re still reading, and which you want to read next. This is where per-user reading status and the shelf API come in. By the end of this lesson, you’ll understand how to store and update your reading progress and how to view your shelf with filters and sorting options.

How Per-User Reading Status Works

Each user can have their own reading progress for each book. This is stored in the ReadingSession object. The key fields are:

  • userId: Whose progress is this?
  • bookId: Which book?
  • currentPage: What page is the user on?
  • status: What is the reading status? (optional, but useful)

The status can be one of:

  • "not-started"
  • "in-progress"
  • "completed"
  • "want-to-read"

Let’s look at how a reading session is updated in the service:

Building the Shelf API Endpoint

Now, let’s see how to build the endpoint that lets a user view their personal shelf. This endpoint will show all books the user is tracking, along with their progress and status.

Here’s the main part of the controller and service:

What it does
Builds the current user’s shelf by joining reading sessions with book metadata, computing normalized status and a numeric progress, then applying optional filtering (status) and sorting (title, , , ) with a specified .

Using Query Parameters: Examples

You can customize your shelf view using query parameters. Here are some examples:

  • Filter by status:
    /reading/shelf?status=completed
    Shows only books you have completed.

  • Sort by title (descending):
    /reading/shelf?sortBy=title&order=desc
    Shows your shelf sorted by book title, from Z to A.

  • Sort by progress:
    /reading/shelf?sortBy=progress&order=asc
    Shows books with the least progress first.

Example Output:

Suppose Alice has two books on her shelf:

If Alice requests /reading/shelf?status=want-to-read, she will see only "Dune" in the results.

Test the Shelf API (Unit-2 scope only)

Alice updates progress (two sessions)

View Alice’s shelf (filter & sort)

Public read: progress for a given book (no auth)

Negative tests (expect errors)

Summary and Practice Preview

In this lesson, you learned how to track each user’s reading progress and status, and how to build an API endpoint that lets users view and organize their personal shelf. You saw how to filter and sort your shelf using query parameters, making it easy to find the books you want to focus on.

Next, you’ll get to practice these concepts by updating your own reading progress and exploring your shelf with different filters and sorting options. This hands-on practice will help you become comfortable with managing per-user reading status and using the shelf API effectively.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal