SkillByAIOpen interactive version →

Lesson 2 / 25

Resources & URIs

Name endpoints around plural nouns, nest resources sensibly and let HTTP methods supply the verbs.

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 verb

Keep 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.