REST is an architectural style for API design that is defined by six constraints. These constraints, or design principles, were first documented in Roy Fielding’s dissertation “Architectural Styles and the Design of Network-based Architectures”. The acronym REST stands for REpresentational State Transfer.
A REST API is an API that follows the constraints of REST architectural style. REST APIs are the most commonly used APIs today.
- Uniform Interface: The API must use standard HTTP methods to represent the operations that can be performed on a resource (endpoint). Examples of these HTTP methods are
- Layered System: The API can be implemented with multiple layers, where each layer performs a different task. For example, the data layer (where information is stored) could be implemented on a different server than the authentication layer (where requests are verified).
- Cacheable: Clients must be able to cache responses, and the server must be able to tell clients how long it should keep a response stored in its cache.
- Client-Server Model: The client and server must be separate. They must communicate using HTTP requests and responses.
- Statelessness: The server must not store information related to the client’s state or session. The client is responsible for storing and handling this information.