What is REST and what are its six architectural constraints?
Answer
REST (Representational State Transfer) is an architectural style for designing networked APIs, defined by Roy Fielding in his 2000 doctoral dissertation. Its six constraints are: Client-Server (client and server are decoupled and evolve independently), Stateless (each request contains all information needed; server stores no client session state), Cacheable (responses must define themselves as cacheable or non-cacheable), Uniform Interface (consistent resource identification, manipulation through representations, self-descriptive messages, HATEOAS), Layered System (client cannot tell if it is connected directly to the server or an intermediary like a load balancer or CDN), and Code on Demand (optional: server can send executable code like JavaScript to the client). An API that follows all constraints is called RESTful.
More REST API Design Questions
View all →- Beginner What are the main HTTP methods used in REST APIs and what do they do?
- Beginner What is idempotency and which HTTP methods are idempotent?
- Beginner What are the most important HTTP status codes in REST APIs?
- Beginner What are REST resource naming conventions?
- Beginner What is the difference between path parameters and query parameters?