Rest API’s : An introduction
After coming into the “real world programming” , if you understand what i mean :p , i saw and heard many instances of HTTP and Rest API’s and each time struggled to understand these terms. I read about some application layer protocols such as HTTP, SMTP, FTP etc, in my Networking class but never understood how it works. Actually you don’t experience anything when you type a URL, it displays you the requested webpage and you don’t get to know about other intermediate procedures involved while processing your request from your browser to the server. So each time when i tried to understand these things, i found this:
Hyper Text Transfer Protocol
Representational State Transfer
And my response to these was :P .
So after several attempts and reading several analogies finally i understood these magic things. I will try to explain these as simple as possible.
There should be a proper mode of communication medium required to talk to a person, isn’t it? In similar way server-client communication also need a proper mode of communication which is done through several protocols like HTTP, FTP, SMTP based on the requirement. when you type any URL and make requests then it needs to be converted into proper way so that server can understand it and vice-versa when server responds to your requests. All these activities handled by these protocols.i.e, when you requested an URL this actually send a HTTP command to fetch and transmit the web page from servers. HTTP is stateless, i.e, it doesn’t maintain info about the clients, reason is quite simple due to large no of requests. So cookie is used to store the info about the clients. It’s just like your Id-card to to the websites. That’s why you see ads of shopping websites everywhere.
In early days when there was no standard all the intermediate procedures used to be hand written i.e, in XML or any other defined format. So there has to be some way to automate these stuff and make the things as simple as possible. All these simplicity achieved through years of research and experience and that’s how Rest API’s came into the world. Rest defined some set of rules, procedures and constraints for all of these. all thanks to this guy Roy Fielding who managed all the disorganised internet and gifted it to the world.
So what does Representational State Transfer mean : There is a very good explanation given on stackoverflow, just have a look on it.
But again if these things are made to simplify the internet then why they gave it such tough name 😐 ?
As always thanks for reading 😊.
