Resources and Resource Identifiers
You'll learn how REST treats every piece of data in your application as a uniquely addressable resource with its own URI.
The Core Idea
In REST architecture, everything is a resource—a noun representing an entity in your system. Instead of thinking about actions or functions, you organize your API around things: users, products, orders, comments. Each resource gets a unique URI (Uniform Resource Identifier) that serves as its address on the web.
Think of resources like houses on a street. Each house (resource) has a unique street address (URI) that lets you find it. You don't say "get the data from the user table where id=5"—you simply go to the address /users/5.
Resource Examples
A resource can be:
- A single entity:
/users/42(one specific user) - A collection:
/users(all users) - A nested relationship:
/users/42/orders(orders belonging to user 42) - Any conceptual entity:
/search,/dashboard,/settings
URI Structure Conventions
URIs should be:
- Nouns, not verbs:
/productsnot/getProducts - Plural for collections:
/articlesnot/article - Hierarchical when related:
/authors/7/books/3shows book 3 by author 7 - Lowercase with hyphens:
/product-categoriesnot/ProductCategories
Why This Matters
By identifying resources with URIs, you create a predictable, intuitive API structure. Developers can guess that if /users/5 gets one user, then /products/12 probably gets one product. This consistency makes APIs self-documenting and easier to understand.
Key Takeaway: REST organizes your application's data as resources, each identified by a unique URI that acts as a stable, meaningful address for accessing that entity.