Have you come across or heard of this acronym API but don't really know what is it and/or what its used for? I remember the first time I heard about it. It was in a boot camp when I was told to build a web app that can consume API I was like, what the heck is API?
Here in this article we will address the following :-
- What is an API
- Why API
All set? Ready? Go!
What is API?
API (Application Programming Interface) is a set of subroutine definitions, protocols, and tools for building application software. -wikipedia
Does that sound more confusing, Ok let push aside the fancy development lingo - I mean the “wikipedia standard” and imagine an API being a messenger that accepts requests and delivers messeages. Are you following or should we makes it more interesting?
Imagine API to be Pizza hut (a company that sells pizza and does home delivery) everybody loves pizza 🍕 right? We pick our phone and call Pizza hut to place an order with the type of pizza we want, the quantity we want and the address we want it delivered (i.e sending a request). Pizza hut takes our order and sends a pizza to that address.
Have you ever wondered how Pizza Hut prepares it’s pizza and delivers it on time? how they do it is actually none of our business). And tyhat is basically how API works.
APIs allow software(application) to talk to each other without user intervention. When we place our order with Pizza Hut, we gave them our address how pizza hut delivery guy found the address is not something we must know or worry about and I am sure nobody wants to be bored with that detail.
Why API
Let’s imagine everyone have to go to pizza hut (the pizzeria) to get their pizza, no delivery guy, no waiter, no order arrangement. Can you imagine how time consuming and inconvenient that will be; following long queues and getting stress out.
Instead of going to Pizza Hut ourselves anytime we want pizza, we can make Pizza hut come to us. Pizza hut makes it easier for us by delivering what we want to our convenient address. That is how API make our work easier in development.
Now let say we want to build an app that displays weather report, the region, humidity, temperature, time and date. We can just assign a static data and that will never change but we all know the weather changes every time. So the question is how do we get the data to change? Luckily for us we have a lot of web services (provider of weather report) that we can get these data from without having to mount whether sensors all over the world just to get data for our simple app. We will send a GET request to their server through an API endpoint, just like we place order for pizza from pizza hut. The server respond to our request in a ‘‘JSON’’ format. Just like the pizza delivery guy deliver our pizza.
There’s a lot more we can do with the API, but to keep this simple that’s all we will cover in this article. Thanks for reading.
For more information on API visit How stuff work or Introduction to API by Biodun Chris.
Top comments (4)
Nice
Thanks man
Definitely loved the pizza analogy :D
Nice read!