REST Principles and Architecture
REST (Representational State Transfer) is an architectural style for designing networked APIs. Following REST principles leads to scalable, maintainable web services.
Core REST Principles
- Client-Server — Separation of UI and data storage enables independent evolution.
- Stateless — Each request contains all information needed; server stores no client session state.
- Cacheable — Responses should define whether they can be cached.
- Uniform Interface — Consistent use of URIs, HTTP methods, and representations.
- Layered System — Client cannot tell if connected directly to server or intermediary.
- Resource-Based — Everything is a resource identified by a URI (/users/42).
Resource Naming Conventions
- Use nouns, not verbs: /orders not /getOrders.
- Use plural names: /products not /product.
- Use nesting for relationships: /customers/5/orders.
- Use query params for filtering: /products?category=electronics&sort=price.
HTTP Status Codes
2xx Success
200 OK, 201 Created, 204 No Content.
4xx Client Error
400 Bad Request, 401 Unauthorized, 404 Not Found.
5xx Server Error
500 Internal Server Error, 503 Service Unavailable.
Frequently Asked Questions
Is REST the same as RESTful?▼
RESTful means following REST principles. Not every API labeled REST is truly RESTful — many are RPC-style APIs over HTTP.
