What is REST?

ghz 9months ago ⋅ 84 views

REST stands for Representational State Transfer. It is an architectural style for designing networked applications. RESTful systems use standard HTTP methods (such as GET, POST, PUT, DELETE) to perform various operations on resources identified by URLs.

Key principles of REST include:

  1. Client-Server Architecture: Separation of concerns between the client and the server, allowing them to evolve independently.
  2. Statelessness: Each request from a client to the server must contain all the information necessary to understand and fulfill the request, and the server should not store any client context between requests.
  3. Cacheability: Responses must define themselves as cacheable or non-cacheable to prevent the client from reusing stale data in response to further requests.
  4. Uniform Interface: This is one of the main principles of REST. It simplifies and decouples the architecture, allowing each part to evolve independently. The uniform interface is achieved by using standard HTTP methods (GET, POST, PUT, DELETE) and resource identifiers (URLs).
  5. Layered System: The architecture should be composed of hierarchical layers, where each layer cannot "see" beyond the layer with which they are directly interacting. This enhances scalability by allowing intermediaries such as proxies and caches to be added or removed without affecting the core functionality.
  6. Code on Demand (optional): Servers can temporarily extend or customize the functionality of a client by transferring executable code.

RESTful APIs are widely used for building web services that can be consumed by various clients, including web browsers and mobile applications, due to their simplicity, scalability, and interoperability.