Skip to main content

An introduction to APIs

API is an acronym for Application Programming Interface.
Let's start with first defining some basic terms:
These are browsers. To visit any website on the internet, you need a 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, 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 "" 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 "" 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 ""? A website? Sure. But writing the name specifically, connects to Google's server and no other server. Writing "" 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!

  1. 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.
  2. 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.


Popular posts from this blog

Namaste JavaScript Quick Notes

Note:  Akshay Saini's Namaste JavaScript is probably the best course for JavaScript developers out there. These are my personal notes that I made while watching the course; they serve more of as an online quick reference for my understanding and revision, and I hope it benefits anyone reading it too! Everything in JS happens inside an Execution Context. Before a JS code is run, memory is allocated and variables are set as undefined   , and functions are set as their exact code in the scope within the Execution Context. The global execution context hosts all the global variables and function definitions. An Execution Context has 2 components: Memory, that stores variables and functions; and Code, that reads and executes the code. Call Stack maintains the order of execution contexts. Since JS is single threaded and asynchronous, at one point of time, only one function is executed which is at the top of the call stack. For each function, an execution context is created before executi

i3wm essentials - I (Brightness)

So you have started using i3 and somehow managed to open your browser and almost resumed your normal work.  But wait, the brightness is too much isn't it? Or is it too low? The mousepad used to work fine, but now all of a sudden tapping does not equal click?!  Don't worry.  This blog series will tell you all about the essential setup commands and common shortcuts that I use to navigate my work in i3, and how you can too. Changing the brightness So you just started i3 and you just can't take this brightness setting. You go for your function keys, and damn! They aren't working. Quick fix: Run the following command if you need to change the brightness ASAP. xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1 This will give an ouput that's the name of your monitor.  Use that monitor name here and change the values of brightness to suit your needs. xrandr --output <monitor-name> --brightness 0.7 Now that your eyes are comfortable, let me show

i3wm essentials - II

Welcome back! Let's continue this guide with other setup essentials for i3. Enabling Mousetap Chances are that if you're using a laptop, then tapping on the mousepad does not equal a click for you. You need to enable tapping in your config. Fortunately, there is one documentation available that works for majority of the setups. I don't need to explain this one in detail. Here you go: Enable tap to click in i3 . Volume Control This one is simple again. Do you remember the i3 config file I talked about in the previous blog ? All you need to do is go to that file and find the line: bindsym XF86AudioRaiseVolume Just below that line you will find lines with XF86AudioLowerVolume and XF86AudioMute too. Anyway, the truth is, there are 2 sets of lines with these keywords. Chances are that the line: bindsym XF86AudioRaiseVolume exec --no-startup-id pactl -- set-sink-volume 0 +5% Will be uncommented and the line: bindsym XF86AudioRaiseVolume exec --no-startup-id pactl -- set-sink vo