In this lesson, the following topics are discussed:
- What is REST?
- Realization as a Web API.
What Is REST?
Generally, REST describes a machine-to-machine interface. In web development, REST allows content to be rendered when it's requested, often referred to as Dynamic Content. RESTful Dynamic Content uses server-side rendering to generate a website and send the content to the requesting web browser, which interprets the server’s code and renders the page in the user’s web browser.
Architectural properties
The constraints of the REST architectural style affect the following architectural properties:
- Performance in component interactions, which can be the dominant factor in user-perceived performance and network efficiency.
- Scalability allowing the support of large numbers of components and interactions among components.
- Simplicity of a uniform interface.
- Modifiability of components to meet changing needs (even while the application is running).
- Visibility of communication between components by service agents.
- Portability of components by moving program code with the data.
- Reliability in the resistance to failure at the system level in the presence of failures within components, connectors, or data.
Architectural Constraints
The REST architectural style defines the following six guiding constraints:
- Client–server architecture
- Stateless
- Cache-ability
- Layered system
- Code on demand (optional)
- Uniform interface
Realization as a web API
Web service APIs that adhere to the REST architectural constraints and properties are called RESTful APIs. HTTP-based RESTful APIs are defined with the following aspects:
- A base URL, such as http://api.example.com/.
- Standard HTTP methods (for example: GET, POST, PUT, and DELETE).
- A media type that defines state transition data elements (for example, Atom, microformats, application/vnd.collection+json). The current representation tells the client how to compose requests for transitions to all the next available application states.
Sources
A great deal of information can be found on the internet in the shape of texts, videos, podcasts, and more about REST. There are also various books about this topic from different perspectives:
Summary
A RESTful web API is created with the REST software architecture style. The interface must correspond to both the architectural properties and the constraints. This results in an implementation that, in addition to a base URI, uses standard HTTP methods and supports many media types. This places RESTful Web APIs at the heart of an API First Approach (architecture).