REST is an architectural style using HTTP methods and stateless communication, where resources are identified by URLs.
REST (Representational State Transfer) is an architectural style for designing networked applications. A RESTful API adheres to specific constraints that make it scalable, simple, and maintainable.
Key REST principles: Client-Server separation (client handles UI, server handles data), Statelessness (each request contains all info needed; server doesn't store client state), Cacheability (responses can be cached), Uniform Interface (consistent way to interact with resources), and Layered System (client can't tell if connected directly to server or intermediary).
The Uniform Interface has four constraints: Resource identification via URIs (/users/123), Manipulation through representations (JSON/XML), Self-descriptive messages (content-type headers), and HATEOAS (hypermedia links for navigation).
HTTP methods map to CRUD operations: GET (read, safe, idempotent), POST (create), PUT (replace, idempotent), PATCH (partial update), DELETE (remove, idempotent). Proper use of status codes is essential: 2xx for success, 4xx for client errors, 5xx for server errors.
RESTful design best practices: use nouns for resources (/users not /getUsers), use plural resource names, nest resources to show relationships (/users/123/posts), use query parameters for filtering and pagination, version your API (/v1/users), and return appropriate status codes.
Understanding REST is fundamental for backend development, though alternatives like GraphQL and gRPC are popular for specific use cases.
REST is an architectural style using HTTP methods and stateless communication, where resources are identified by URLs.
Join our network of elite AI-native engineers.