API is an acronym for Application Programming Interface.
Let's start with first defining some basic terms:
Browser:
Server: Hmm, this is tough. In simple words, server is a computer. Yes, just like the laptop, or PC at your home. The only difference is that it does not have a screen. Of course, there are other differences in technical specifications, but at its core, the server is just, simply, a computer. That's it.
So why is it called a server?
Because it serves. When you go to a website like google.com, your computer connects to the internet and gets you your search result. But your computer's internet connection has to get that result from somewhere, right? If the google search result is giving you some answers, the answers have to come from somewhere. What is that place?
The answer to that some place is: a server.
When you click on the search button on google, or hit enter after typing, "Who am I", your computer speaks to the internet, that it wants to go to "https://www.google.com" with a search query "who am i".
The internet somehow manages to send this request to the server. This server is of Google. They have built it, programmed it and made available to the internet, so anyone can simply write "www.google.com" and be connected to this server.
Hosting: When I said that Google had made this server available to the internet, the technical meaning of this is: hosting. It means anyone with an internet connection, from anywhere in the world, can connect to this server.
Domain: What is "www.google.com"? A website? Sure. But writing the name specifically, connects to Google's server and no other server. Writing "instagram.com" only connects to Instagram's server always. How?
Because these names, also called, domains, are saved. In a sense, by the internet.
Now, if you don't remember all of these definitions, it's okay. But the most important thing here is, a server.
As the world progressed, more websites came into existence. Google, Facebook, Instagram, YouTube, Amazon, Microsoft. All of these have their own website. Which means?
That all of these websites have their own servers too.
These servers serve the websites when somebody tries to connect with them, or in simpler words, when somebody requests the servers.
What happens when you visit a website?
When you enter a website URL into a browser, a request is sent to the server, which is hosted on that domain (URL).
When a server receives the request, it responds with sending data to your computer. What is that data? That data contains website's content and some instructions on how to show that content (the style, the position of various data on your screen, how everything will look). These instructions are what we call code. Understanding the code part of the data is not important. That's what Web Developers do.
Imagine, if you tried visiting a website that just had some content, but no instructions on showing that content. How would that look?Yes, it would look like this. Yes, it looks chaotic and ugly to look at. Maybe that's why, only programmers play with such websites.
But readers, finally, I have presented you what APIs are.
They are certain corners in the internet that provide you with data from servers; just data, no code. So that you can use that data to do whatever you want in your application that you are building, or whatever.
They are also faster than a website!
Examples of APIs: Where are APIs used, you ask? In every nook and corner of your phone, to begin with!
- YouTube: Ask yourself, what is YouTube? It's an app on your phone. What does it do? It shows you irresistible video suggestions and plays them for you after you watch those irritating ads. How do they do that? They are secretly sending hundreds of requests to their YouTube servers through your phone, receiving videos that you want them to play and ads that you don't.
- Instagram: Again, an app. When you open the application, you see all the awesome pics of the people you follow, and their stories. Remember, your phone is just a basic tool that does not have any of those photos. It is simply sending a request to Instagram servers, and receiving the photos of the people you follow.
Somehow, the server figures out who you are, and sends you only the photos of the people you follow. How? Let's say it's magic.
That magic, is what is done by APIs, and by extension, by us programmers. We make the magic happen.
And in the next blog post, I will talk about the different parts of APIs, and what really is DrawPI.
Comments
Post a Comment