LearnThatStack Ace your next interview
API Design · question
Question 2 of 110

Explain the concept of resources in REST API design.

beginner
← All API Design questions
Re-explain
Visual ↓

Resources are the key abstraction in REST. A resource is any information that can be named and addressed. Resources should be:

  • Nouns, not verbs: Use /users not /getUsers
  • Hierarchical: /users/123/orders/456
  • Consistent: Use plural nouns (/users, not /user)
  • Meaningful: Clear and descriptive names

Resources represent entities in your domain model and should map to business objects or data entities.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for API Design One question at a time. Answer out loud, get graded, see what you missed.
Related concept

Thinking in resources: what REST actually is

REST is constraints, not JSON over HTTP: address resources, let methods decide the action, send hypermedia links to what's next and more.

For this question · chapter 2 of 3Watch three action endpoints become GET, PUT, DELETE on one address, /users/123. The method carries the action.

2/3 Six endpoints become four addresses
RESOURCESSix endpoints become four addressesthe method carries the actionENDPOINTS0ADDRESSES4/users/123DELETEPUTGETUser/usersGET ?email=User/users/123/ordersPOSTGETOrder/orders/456Order
RESOURCESSix endpoints become four addressesENDPOINTS0ADDRESSES4/users/123DELETEPUTGET/usersGET ?email=/users/123/ordersPOSTGET/orders/456

Six endpoints become four addresses

  1. What does 'the uniform interface' mean. The six POST endpoints on the left are each named after an action, so this API ignores the uniform interface. Every feature got its own name, which felt natural but has a cost - growing and unpredictable list of endpoint names.
  2. Instead, name the thing and you got one address, /users/123. The three user endpoints become methods on that address: GET reads the user, PUT replaces the user, DELETE removes the user. Six endpoints will become three, all on that one address. The method specify the action, and the URL is the name of the resource.
  3. The collection for the item is the same noun, plural - /users. Finding a user by email is not a different action. That search is a filter on the collection, GET /users?email=. The collection is just one address, and you can add as many filters later.
  4. Orders belong to a user, so /users/123/orders sits one level under /users/123 and allows GET and POST actions. The path defines who owns what. The left column, the list of actions, is empty now. Every action has an address and a method.
  5. But be careful of nesting. The path /users/123/orders/456/items/7 repeats ids that already identify things on their own. With nesting , it's important to know where to stop. An order has its own id, so /orders/456 stands alone and items sit under that path. So usually, nest one level to show ownership, and stop there.
  6. The address tree should read like the domain: users have orders. And a client should be able to guess addresses that match your entities. A verb in a path means you are calling a function over HTTP, not addressing a resource.
Chapter 2 · step 1 of 6

What does 'the uniform interface' mean. The six POST endpoints on the left are each named after an action, so this API ignores the uniform interface. Every feature got its own name, which felt natural but has a cost - growing and unpredictable list of endpoint names.

1 of 6 Use ← → or swipe See the concept: all 3 chapters in it

© LearnThatStack - diagrams may not be republished without permission.

How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

  • How would you model an action that isn't CRUD, like cancelling an order? Turn it into a state change or a noun, like PATCH on the order's status or POST to a cancellation sub-resource, and say why you picked one.
  • How deep would you nest resource URLs, and when would you flatten them? Nest for real ownership, usually one level. Anything with its own ID also gets a top-level path so clients don't need the parent.
  • Which HTTP methods apply to a collection like /users versus a single item like /users/123? GET and POST on the collection. GET, PUT, PATCH and DELETE on the item. The method carries the verb, so the path never needs one.
  • What's the difference between a resource and its representation? The resource is the concept. JSON or XML is one representation, picked with the Accept header, and its fields need not mirror your tables.
  • How would you let clients filter or search a collection without adding new paths? Use query parameters on the collection, like ?status=active&sort=-created_at, instead of paths such as /users/active.

What you can say

  1. A resource is any piece of information the API can name and give an address to, like a user, an order, or a list of users.
  2. The URL names the thing and the HTTP method says what to do with it, so I write GET /users, not /getUsers.
  3. I use plural nouns everywhere, /users for the collection and /users/123 for one user, so every endpoint follows the same pattern.
  4. Relationships show up in the path, so /users/123/orders/456 reads as order 456 belonging to user 123.
  5. Good resources map to the business objects in your domain, with names clear enough that a client developer could guess the URL.
  6. The limit is that not everything is a noun, so I model an action like cancelling an order as a state change, and I keep nesting to one or two levels.

Weak answers to avoid

  • Puts verbs in the URL /getUsers or /createOrder repeats what the HTTP method already says. Name the thing and let GET, POST and DELETE carry the action.
  • Lists naming rules but never says what a resource is Plural nouns and no verbs are style rules. Say first that a resource is a named, addressable thing, then give the rules as what follows from that.
  • Nests URLs as deep as the data model goes /users/1/orders/2/items/3/notes breaks when relationships change. Nest one level for ownership and give items with their own IDs a top-level path.
  • Treats the resource and its JSON as the same thing The resource is the concept and JSON is one representation of it. Mentioning the Accept header shows you know the same resource can have several formats.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the API Design cheatsheet.

← Back to all API Design questions
Pro · $10/mo

90 of 110 API Design answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime