Rest APIs


Recently I came across one tweet saying “#Rest APIs are now #RestInPeace APIs”. Working with Rest APIs since last so many years, something like this was really intimidating to envision. Though I heard about GraphQL, which in some ways is being seen as the replacement of REST; however is this really the case? Is GraphQL going to do the same to REST which JSON did to XML? Is it just the server round trips which will cost REST its existence?

I spent few a days educating myself looking into various aspects, differences, doing some tests etc. to try to come to a conclusion on this.

REST (Representational State Transfer) evolved at a stage when the server was dominating the web application domain. Most of the complex business rules, heavy processing etc. was done at the server end. So it was the server, which was eventually in command. Depending on the requirements, you will have to create different endpoints to fetch relevant information. However, adding more features on top of this, you may end up making four, five or even more different API calls to fetch the relevant data as per extended functionalities or complexities within the same set of data. You can still manage it up to a level, but eventually it would mean maintaining multiple API codes, just to ensure that it works for both, new and old clients, and in turn offering tightly coupled services to clients. I hope you are well aware of the nightmares involved in handling this after a certain point.

This is primarily the area where GraphQL tends to fill in the gap and provides a mechanism to retrieve a broader data schema and then allowing the client to pick exactly what he requires. So it puts the client in command to specify what data is exactly required. Developers who have been working with REST since long time now may feel uneasy going ahead with GraphQL but I feel it is not that hard. It is definitely worth a try and looks pretty mature in handling what is expected out of it. It is certainly an overhaul and the choice of usage should be done based on various factors like the type of application, the nature of API’s, etc. Regarding REST, I do not see a mass exodus right away,but GraphQL may be used as an auxiliary interface to the endpoints for now and hence can work in conjunction with REST.

Final Words:

In today’s world of rapidly advancing technology, the existence of any technical platform has been always in threat, but still there are technologies (like REST) which have seen tremendous acceptance and usage worldwide. The core principles and guidelines will always be the stepping stones for newer technologies and this battleground will continue to bring out the best of the lot.