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.