Understanding the RESTful state of the web
Tags: Restful Service, Backend Development, Rest Api, API, Restful Api

Hello World, …. I guess that is the first line of programming for most if not all and in the same simplicity, will this blog explain the key constraints that build up a RESTful web architecture.

Client-Server

The web is a client-server based system which separates these distinct parts to enable independent deployment of each using any language or tool of choice provided it conforms to the Web’s Uniform Interface.

This could be essentially perceived as building a frontend system in VueJs and a backend system in Python.

Uniform Interface

So what is the Web’s uniform interface that we mentioned earlier as an expectation of client-server to conform to?

Just as a request expects a response, the interactions between the web components depend on the uniformity of their interface. For clarity on the uniform interface, I will proceed to break it down into four segments.

Identification of resources

The URI ( Uniform Resource Identifier) is a syntax that assigns unique addresses to each web content hence each Web content is known as a resource. https://www.google.com is an example resource identifier to google’s website root resource.

representation as a means to manipulate the resources

A resource can be represented in different ways without having to change its unique identifier. A user might want an HTML view of the resource whereas a program may require a JSON representation of the same information. HTML and JSON, in this case, are not the actual resource rather a representational way that allows interacting with the resource itself.

self-descriptive messages

a request’s current state may be represented by a server’s response, for instance, a google search client may use a request message to the server to update content on the page. These self-descriptive messages may include metadata with extra information regarding the representation format and size, the resource state and the message itself.

Hypermedia as the engine of application state

Hypermedia references to information that includes graphics, audio, video, texts, and hyperlinks. It is an extension of the term hypertext.

Cache

Caching reduces the web costs by reducing the client-perceived latency, controlling a web server’s load and increase the reliability of the application. This is achieved by declaring cacheability of each response’s data making it faster to fetch the information.

Stateless

While considering the scalability of your program, you require to build a server capable of servicing multiple client platforms. This would require the server not to memorize the state of its client applications, as a result, each client must include all relevant information required to establish communication with the server. This trade-off ensures a stateless architecture type to the webserver.

Code on Demand

This is the only optional constraint in the REST architecture. It allows the server to provide executable code to the client e.g scripts or plug-ins. The client must be able to understand and execute the code downloaded from the server hence the reason this constraint is made optional to integrate.

For more information on this, check out this link https://stackoverflow.com/questions/32094952/code-demand-constraint-for-restful-apis.

Awesome Ninja!! Now you are more knowledgeable on the REST architecture’s key constraints have your foot down the right path to building awesome web-based solutions.

Your comments, contributions and most definitely claps are very welcome.