Skip to the workspace
Pebellslearn by building
Designing RESTful APIs  ›  Lesson

Resource Modeling

Resource modeling 14 minResource modeling means choosing the nouns callers need to fetch or change on their own, turning important actions into resources, and hiding how the data is stored.

api design / Resource Modeling

Explore each scene at your own pace.

01 · The rule

The rule

Resource Modeling

Before writing a single endpoint, BookNook has to decide what its API is about. Is a loan its own thing, or a field on a book? Is a reservation a resource, or an action? These choices shape every URL, every response and every future change, and they are much cheaper to get right on paper than in production.

The rule

Model the nouns your callers care about, not the tables you store.

A resource is anything a caller wants to name, fetch or change. Resource modeling means choosing those nouns, their fields and how they relate.

Start from what callers do, then find the nouns in those sentences:

  • "A member borrows a book" → nouns: member, book, and the borrowing itself, a loan.
  • "A member reserves a book that is out" → a reservation.
  • "A librarian sees overdue loans" → not a new noun; a filter on loans.

Resources come in two shapes:

  • A collection holds many: /v1/books.
  • An item is one member of it: /v1/books/42.

Relationships can be shown by nesting (/v1/members/7/loans) or by reference, a field holding the other resource's id:

{
  "id": 901,
  "book_id": 42,
  "member_id": 7,
  "borrowed_on": "2026-09-25",
  "due": "2026-10-09",
  "returned_on": null
}

Two habits keep models healthy:

  • Turn important actions into resources. "Borrow" becomes creating a loan: POST /v1/loans. The loan then has its own id, history and status, which a bare borrow action would not.
  • Hide storage details. If the database splits a book across books, editions and shelf_locations tables, the API may still expose one book resource. Callers should not break because you reorganised your tables.
Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.