Resources, not functions
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
think in nouns (things) rather than verbs (actions).
Planned topics
- A resource is a thing the API exposes: a product, a category, an order.
- A collection is a group of resources (
/products). A sub-resource belongs to a parent (/orders/7/items). - The HTTP method is the verb. The URL is the noun.
- Model from the domain requirements, not from database tables.
- The contract should not leak internal structure such as table names or database IDs by accident.
Draft outline details
Demonstration
| Bad (functions) | Good (resources) |
|---|---|
POST /createProduct | POST /products |
GET /getOrderItems?id=7 | GET /orders/7/items |
Check your understanding
What is the verb in DELETE /products/5?
Show answer
DELETE, the method, not the path.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.