REST Services

it19214580 Bulner S.M.
4 min readMar 21, 2021

Based on the REST architecture, Restful Web Services is a lightweight, maintainable, and scalable service. Restful Web Services allow you to expose API from your application to the calling client in a secure, uniform, and stateless manner. The Restful service allows the calling client to perform predefined operations. HTTP is the fundamental protocol for REST. REpresentational State Transfer is the acronym for REpresentational State Transfer.

RESTful Architecture

An application or architecture considered RESTful or REST-style has the following characteristics

  • State and functionality are separated into distributed resources, which ensures that each resource should be reachable using standard HTTP commands such as GET, POST, PUT, and DELETE. So, if anyone wanted to download a file from a server, they should be able to do so with a GET message. They should be able to submit a POST or Placed request to the server if they want to upload a file. Finally, if they were to remove a file from the server, they could use the DELETE command.

he architecture is client/server, stateless, layered, and supports caching –

  • Client-server is the typical architecture where the server can be the web server hosting the application, and the client can be as simple as the web browser.
  • Stateless means that the state of the application is not maintained in REST.
  • For example, if you delete a resource from a server using the DELETE command, you cannot expect that delete information to be passed to the next request.
  • In order to ensure that the resource is deleted, you would need to issue the GET request. The GET request would be used to first get all the resources on the server. After which one would need to see if the resource was actually deleted.

RESTful Methods

The HTTP verbs comprise a major portion of our “uniform interface” constraint and provide us the action counterpart to the noun-based resource. The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations, respectively. There are a number of other verbs, too, but are utilized less frequently. Of those less-frequent methods, OPTIONS and HEAD are used more often than others.

Why RESTful ?

Restful mostly came into popularity due to the following reasons:

  1. Heterogeneous languages and environments
  • It enables web applications that are built on various programming languages to communicate with each other
  • With the help of Restful services, these web applications can reside on different environments, some could be on Windows, and others could be on Linux.

But in the end, no matter what the environment is, the end result should always be the same that they should be able to talk to each other. Restful web services offer this flexibility to applications built on various programming languages and platforms to talk to each other.

The below picture gives an example of a web application which has a requirement to talk to other applications such Facebook, Twitter, and Google.

Now if a client application had to work with sites such as Facebook, Twitter, etc. they would probably have to know what is the language Facebook, Google and Twitter are built on, and also on what platform they are built on.

Based on this, we can write the interfacing code for our web application, but this could prove to be a nightmare.

Facebook, Twitter, and Google expose their functionality in the form of Restful web services. This allows any client application to call these web services via REST.

  1. The event of Devices — Nowadays, everything needs to work on Mobile devices, whether it be the mobile device, the notebooks, or even car systems.
  2. Can you imagine the amount of effort to try and code applications on these devices to talk with normal web applications? Again Restful API’s can make this job simpler because as mentioned in point no 1, you really don’t need to know what is the underlying layer for the device.
  3. Finally is the event of the Cloud — Everything is moving to the cloud. Applications are slowly moving to cloud-based systems such as in Azure or Amazon. Azure and Amazon provide a lot of API’s based on the Restful architecture. Hence, applications now need to be developed in such a way that they are made compatible with the Cloud. So since all Cloud-based architectures work on the REST principle, it makes more sense for web services to be programmed on the REST services based architecture to make the best use of Cloud-based services.

--

--