Skip to content

Resource & URI Design

In REST, the resource is the central abstraction. A resource is any thing worth naming and addressing — a user, an article, an order, a shopping cart. Designing an API is mostly deciding what your resources are and how their URIs read.

classDiagram
  class User { +id +name +email }
  class Article { +id +title +body +authorId }
  class Comment { +id +body +articleId +authorId }
  User "1" --> "*" Article : writes
  Article "1" --> "*" Comment : has
  User "1" --> "*" Comment : posts
A small domain: users author articles, which have comments

Each box becomes a collection you can address (/users, /articles, /comments), and the relationships hint at how URIs nest and link.

  • Modeling resources — finding the right nouns and the right granularity.
  • URI naming — the conventions that make an API predictable.
  • Nesting & relationships — sub-resources versus links.
  • Consistency & conventions — keeping the whole API coherent.
In REST, what is the central abstraction you design around?
Which URL smells like RPC rather than REST?