REST API Masterclass
Architecting Modern BackendsWhat is REST?
REST (Representational State Transfer) is an architectural style for providing standards between computer systems on the web, making it easier for systems to communicate with each other.
1. The 6 Constraints of REST
Client-Server
Separate the user interface concerns from the data storage concerns.
Stateless
No client context is stored on the server between requests. Each request is independent.
Cacheable
Responses must define themselves as cacheable or not to prevent stale data usage.
Uniform Interface
Resources should be identified by URIs and manipulated through representations (JSON/XML).
2. Resources vs Actions
In REST, everything is a Resource. You don't call functions; you perform standard HTTP actions on resources.
- Good:
GET /users - Bad:
GET /getAllUsers
3. Representation
A resource is a conceptual entity. A Representation is how that resource is sent to the client (e.g., a JSON string or an HTML file).