Lesson 2 / 24
Resources & URIs
Naming endpoints around nouns, not actions.
A resource is a noun
A resource is any thing you can name and address — a user, an order, a collection of orders. The URI identifies what you're talking about; the HTTP method says what to do with it.
Naming conventions
Use plural nouns for collections, lowercase-with-hyphens, and nest resources to show ownership. Avoid verbs — the method already is the verb.
GET /orders # good: plural noun
GET /orders/482 # a single order
GET /users/9/orders # orders owned by user 9
GET /getAllOrders # bad: verb in the path
POST /order/create # bad: redundant verbKeep nesting shallow
/users/9/orders/482/items is already a lot. Beyond two levels, prefer a flat URI with a query filter — /order-items?orderId=482 — it's easier to route and cache.