Backend & Node.js · APIs, data and failure

How do you design REST resources and endpoints?

Mediumrestresourcesapi designUpdated Oct 2026
Quiz this track

Short answer

Model nouns as resources with stable identifiers, use HTTP methods for operations, and keep URLs hierarchical. Use query parameters for filtering and pagination, and represent actions that do not fit CRUD as sub-resources or explicit action endpoints.

A good REST URL names a thing, not a function. The method carries the verb. Collections are plural, an item is identified by its id, and relationships are expressed through nested paths or dedicated collection endpoints.

http
GET    /users
POST   /users
GET    /users/42
PATCH  /users/42
DELETE /users/42

GET    /users/42/orders
POST   /users/42/orders

POST   /orders/99/cancel
GET    /orders?status=paid&sort=-created_at&limit=25
The verb lives in the method. Repeated path segments describe ownership or a scoped collection.

Design rules

  • Use plural nouns and lowercase paths with hyphens for multiword segments
  • Do not encode verbs such as getUsers or createOrder in the URL
  • Use query parameters for filtering, sorting, fields and pagination
  • Return consistent shapes and stable ids across the API
  • Use 404 for a missing parent, or hide resources the caller may not see
  • Nest only when the child cannot exist without the parent, and keep nesting shallow

Some operations are not CRUD. Cancelling an order, resending an invitation or archiving a project can be modeled as a sub-resource action, a state field updated with PATCH, or a dedicated endpoint. Choose one convention and document it. Strict purity matters less than predictability for clients.

Avoid exposing database ids directly if they leak volume or enable enumeration. A public opaque id or UUID can decouple the API from storage, at the cost of extra lookup or index size.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1Should a URL ever contain a verb?
  2. 2How do you model an action that is not CRUD?
  3. 3When should you nest resources?
  4. 4How do you handle filtering and sorting?

Say it in the interview

I model the domain as nouns and let HTTP methods express the operation. Collections are plural, items have stable ids, and relationships use nested paths or separate collection endpoints. Filtering, sorting and pagination go in query parameters. For non-CRUD actions I use a documented convention such as an action sub-resource or a state field, because consistency for clients matters more than theoretical purity.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Backend & Node.js mock interview and get scored feedback on depth, clarity and confidence.