What is REST API and Why Use It?

Dilshan Hiruna
2 min readJun 11, 2022

APIs were frequently built around a remote procedure call (RPC), so they looked and felt like locally executing code. While this gave APIs the appearance and feel of functions, it also made the transition to the Web more difficult. Because the HTTP protocol is naturally connection-less, developers had to think about it differently.

Many technology stacks attempted to solve this problem along the way by providing developers with an RPC-like stack that attempted to hide the details. This method aided in the faster delivery of applications to the Web, but it resulted in developers writing inefficient code. During this time, an influential paper was published that discussed how to build better Web-based APIs: REpresentational State Transfer (REST).

REST for the rescue

REST is an architectural style that favors simple HTTP calls over more complex options such as CORBA, RPC, or even SOAP for inter-machine communication. RESTful calls are message-based and rely on the HTTP standard to describe these messages.

REST is a simple request/response mechanism because it uses the HTTP protocol. Each request is followed by a response.

Requests consist of a verb (in this case, POST), headers that describe the message, and a body. The request is a message that tells the server what you want it to do. Similarly, the response is made up of three parts: a status code (200), headers that describe the response, and the body itself.

HTTP Verbs describe the type of operation:

  • GET: Retrieve a resource
  • POST: Create a resource
  • PUT: Update a resource
  • DELETE: Delete a resource

The most common verb on the internet is GET. This is because the primary purpose of a Web page’s function is to request the various resources that comprise a page. In REST-based APIs, we use these verbs to describe the types of operations we want.

How is REST useful?

It works because your API is not tied to your client-side technology. This API could be accessed via a client-side Web project, an iOS app, or an IoT device. This allows you to build the infrastructure for your organization with fewer concerns about long-term compatibility with a specific client-side stack. The server has a longer lifespan than the client. It’s always the case.

Another key concept in this architectural philosophy is that the server is stateless and supports caching. These concepts are critical to the operation of REST. Caching is important because if multiple requests for the same resource are made, caching the result of the request means that the server’s scalability should improve.

Conclusion

From this article, you’ll find out how REST has come into the picture and how it works.

--

--