Don’t think twice, it's alright
I have been torn down, buried in sand, played around with like a toy, put in difficult situations all my life. People have blamed for things I never had a part in, they curse me, fear me, hate me, but still cannot live without me. People have used me all their lives, exposed me, bugged me, shouted, and brooded about me. I never asked for it. I never wished for it. All I can do is be who I have been assigned to be.
— Your dear, Development Server
Yesterday night, I had a dream. I was standing beside the great pyramids of Egypt and the ancient aliens who built it were having a casual chat with me. I was the only human there, all others were aliens! Strange…….
Alien 1: “He, who is a human here, must promise those, who are the aliens here, to not reveal the secret of the origins of this great Pyramid built by our ancient, intelligent, and esteemed species.”
Me: “I hereby promise to thou to not reveal to the people of the modern world that those pyramids have been built by thee aliens.”
And so, yesterday night, in my dreams, I came to know the secrets of creating a good software that the aliens used to create 3D visualizations of the great Pyramid before they actually built it. I swear to not reveal the secret, but this guy came in from nowhere and revealed it to the whole world. Damn!
And thus, I shall reveal the secrets given to me as well, for the greater good of humanity and because they are not really secrets, and you can find them on any other damn blog on the internet!
The secrets I am talking about are those of REST APIs.
If you have worked anywhere near full stack, backend web engineers, you must have come across this peaceful term RESTful APIs. What are these RESTful APIs? And for that matter, what are APIs?
Whenever a user visits YouTube and searches for some video. It is an API that is returning the results. An API can be considered as a food outlet. You go to the outlet window, give your order, the attendant goes back into the kitchen, packs the order, and gives it right back to you. Happy junk eating!
Replace yourself with a frontend web application, the attendant with the code written in some language, the kitchen with some database, and the food is the results you searched for. This is what an API is. An endpoint you can call anytime to serve your purpose. The aliens gave me this example, surprisingly, they too have McDonald’s on their planet.
So now that we know what APIs are, what are RESTful APIs?
So many companies, so many people, so many processes, so many engineers, so much code! Is it not better to standardize a few practices while creation of code to make it more predictable, maintainable, and understandable. REST is just a standardization. It is an architectural design pattern and RESTful APIs are one of the most popular in the industry.
If we perform an autopsy on an HTTP API, we will find that it is composed of mainly 4 things.
- The endpoint
- The method
- The headers
- The data
Endpoint: This is the website URL. The internal YouTube API for example might be hosted at https://api.youtube.com/v3.
Method: The method is the type of request you make to the API. If you want some data, a “GET” request is made. To store some new data, a “POST” request is made, to update some existing data, “PUT” request is made, and similarly “DELETE” for deletion of some records.
Headers: Headers just contain some extra information like authorization details(username and password), in case the API is to be private. It can contain information as to in which format the data is being passed.
Data: Data is data. The data being requested. In our case, the result of videos from YouTube.
The creation of REST APIs requires a certain pattern to be followed that can be found anywhere on the World Wide Web. But, for nontech people enthusiastic about learning about new terms in tech, this much information about REST APIs is more than enough.
It is important that coders pay attention to and adhere to certain coding mechanisms and processes to make it easier for themselves and others to maintain that code.
Lady Melisandre knew it all along the way
Following certain practices like REST ensures that code has been written in a certain style and is understandable by someone new coming in.
So if you create API using REST, you don’t have to think twice, it will be alright!
“And here’s to you, Mrs. Robinson
Jesus loves you more than you will know”