Learn what an API is in less than 5 minutes.

What’s up, guys? Welcome back to another article! I’m so glad to see your amazing, beautiful and lovely and just amazing faces! 😀In this article, we are talking about API basically what an API is.

My good friend and Whatsdev lead product engineer Chris asked me a very interesting question and I feel a lot of people have this question.

So, what exactly is an API? It stands for 




Most people define it like this:

It helps software talk to each other

But most people still don't get it.

Chris, actually asked me a really good question, so what actually is a difference between a library and an API, and a lot of people have this question as well.

A library is a set of tools, a piece of code that somebody else has written so that you don’t have to write it yourself. You can just import in your project without having to code it from scratch so that you can build your application faster.

In essence, a library is a set of tools and methods that somebody wrote so you don’t have to.

An API - application programming interface - keyword here is “interface”. It is just a piece of code that you or somebody else wrote so that another person can access this library.

So, for example, bootstrap, react, they’re all libraries. But how do you access them? How do you use these methods in your codebase? API

This is actually just one type of API, there are many different types, for example, REST APIs.

How do you get your video on Youtube? How do you access Uber? How can you get the data to use Google Maps? Again, APIs

Let’s take Google for example, at some point  they must have realized they had a bunch of very valuable data, so they asked themselves: 

“Mmm, we have all this data, how can we make it accessible to other people?”

Guess what? APIs! 😎 They thought, why not create web services with an API so that people can make a request to this API and get data back based on the request performed.

So they did, they created an API, like google maps, so that people could connect to it, and make a request, for example, to get direction to your favorite coffee shop. All this is possible because some cool engineers at google sat down a wrote a piece of code that allows you to make this request to their server. And it allows their servers to understand this request and respond accordingly.

This very piece of software that is sitting between google’s data and your device is an API.

To give you the simplest example, you can think of an API as a function. Let’s look at an example.

We’ll create a const “MyAmazingApp” and we’ll assign an IIFE to it, that is a function that runs automatically without needing to be called.

const MyAmazingApp = (function() {})();

Inside this IIFE we’re gonna have two methods, “add” and “subtract”, nothing really crazy about them. They’ll receive two arguments and they’ll add them or subtract them.

const MyAmazingApp = (function() {

const add = (a,b) => return a + b

const subtract = (a,b) => return a - b


Now, what if I wanted to only have the “add” method be accessible to the outer scope, that is, whenever the function gets called.

In order to do that, I’ll return an objected at the end of the MyAmazingApp, and inside the object, I’ll refer to the “add” method only.

const MyAmazingApp = (function() {

const add = (a,b) => return a + b

const subtract = (a,b) => return a - b

return {add}


See, with this last piece of code

return { add }

We have created an API for our function! The code that we wrote to expose that method to public use...is an API. 🔥

So that, from now on, anyone can use our “MyAmazingApp” in their project, call the function, pass in two numbers and, lo and behold...get the sum of them!!

MyAmazingApp.add(2,2) // is gonna return 4, holy smoke!

Alright, this was my powerful explanation of what an API is, I hope it’s gonna be extremely valuable to you.

Now, quickly before I close this up, If you’re serious about knowing vanilla JavaScript like it’s nobody’s business, Check out my premium course at jabjabjavascript.com where I cover everything you need to master JavaScript from the ground up.

Yes, I want Tenzin to show me my coding potential.

Start the quiz