Mastering REST Architecture — REST Architecture Details

REST — Representational State Transfer

REST stands for Representational State Transfer (It is sometimes spelled “REST”). It relies on a stateless, client-server, cacheable communications protocol — and in virtually all cases, the HTTP protocol is used.

https://cdn-images-1.medium.com/max/782/1*EbBD6IXvf3o-YegUvRB_IA.jpeg
REST is a simple way to organize interactions between independent systems.

HTTP — HyperText Transfer Protocol

HTTP means HyperText Transfer Protocol. HTTP is the underlying protocol used by the World Wide Web and this protocol defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands.

We use HTTP protocol thousands of times in our daily life!
HTTP requests example

Benefits of using REST Architecture

Here are 5 benefits of using REST architecture:

  • RESTful as lightweight Web Services: The RESTful architecture was a reaction to the more heavy-weight SOAP-based standards. In REST web services, the emphasis is on simple point-to-point communication over HTTP using plain XML. In addition, RESTful permits many different data formats whereas SOAP only permits XML.
  • The simplicity of RESTful: The RESTful architecture is much simpler to develop than SOAP. One of the main reasons for REST popularity is the simplicity and ease of use, as it does an extension of native Web technologies such as HTTP.
  • RESTful architecture is closer in design to the Web: RESTful is the architectural style of the web itself, so the developer with knowledge in web architecture will naturally develop in the RESTful architecture.
  • Scalability: As RESTful forbids conversational state, which means we can scale very wide by adding additional server nodes behind a load balancer.
  • Expose APIs as HTTP Services: When developers need the universal presence with minimum efforts, given the fact that RESTful APIs are exposed as HTTP Services, which is virtually present on almost all the platforms.

Architectural Constraints

Here are 6 REST constraints that we can consider as design rules, that must be applied to establish the distinct characteristics of the REST architectural style. In other words, These 6 architectural constraints which make any web service — a true RESTful API:

  • Interface / Uniform Contract: Once a developer becomes familiar with one of your API, he should be able to follow the similar approach for other APIs.
  • Client-Server: Servers and clients may also be replaced and developed independently, as long as the interface between them is not altered.
  • Stateless: No client context shall be stored on the server between requests. The client is responsible for managing the state of the application.
  • Cache: Well-managed caching partially or completely eliminates some client-server interactions, further improving scalability and performance.
  • Layered System
  • Code-On-Demand (optional)

Conclusion

  • REST is an architectural pattern which is based on HTTP and uses HTTP requests, responses, verbs and status codes to communicate.
  • The fact that REST services use HTTP means they can be consumed by almost any ‘online’ device or application (including IoT devices such as toasters, cars, pedometers etc) — no proprietary knowledge of the API is required! This is freaking awesome!!!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ahmet Özlü

Ahmet Özlü

175 Followers

I am a big fan of Real Madrid CF and I love computer science!