Learn VisualLearn API

A URL Names the Thing, Not the Action

A REST URL names a resource — a noun the API exposes — rather than the action being performed on it.

/users is a collection, the set of all users. /users/42 is a single item within that collection, one specific user. /users/42/orders is a nested collection, the orders that belong to that one user.

The method carries the action, GET reads and POST creates, so the URL itself never needs a verb like /getUser or /createOrder.

GOAL

Design a resource-oriented URL for a given piece of data, distinguishing a collection from a single item and from a nested sub-collection.

An API needs an endpoint to fetch a single product with id 7. Which URL fits?