What is an API?

Today's article is about answering a simple question that I myself needed to answer in order to fully understand the topic. The question is: what is an API? 



Quick Storytime

When I started learning to code, I started hearing the word "API! API!! API!!!  I got really confused about what it does, what it means & and why we needed it. After continuous practice and reading, I finally got a grasp of it (whoop whoop). So, I'm here to share what I know about API and how it works. With no further ado, let's dive right into it.


Image from Eset Online


An API stands for Application Programming Interface which basically means that it's an application that acts as an interface between the client side and server side (more like a gateway or access point).


There is this popular example that I saw online that made me understand the concept better. Here is an example "Imagine that you are sitting in a restaurant for lunch. First, you have to place an order for food right? So, you check what is available on the menu. After deciding on what to eat, you then ask the waiter if the item is available or not. If the item is available, the waiter will take your order and ask a chef who is in the kitchen to prepare the food for you. After preparing the food, the chef will give the order back to the waiter and then the waiter will give the food back to you". 


I really love this example because it sort of encapsulates what an API means and how it works. In that example, the waiter is the API (the person who listens to the request and sends our order to the chef). The chef is the backend or server who takes an action or request and then sends it back to the API (waiter).


Another simple illustration from the technical side of things is: when you type www.facebook.com into your browser (client), a request will be sent to Facebook's remote server. Once the server receives your response, it interprets the code and displays the page. In this example, the remote server isn't the API, however, the API is like a messenger who either grabs the message from the server and sends the responses.


Developers use API for so many things such as to fetch data from the server, add data to the database, delete a record, and validate a user, amongst others. 


There are four basic request methods that can be made with API:

HTTP methodCRUDAction
GETreadreturns requested data
POSTcreatecreates a new record
PUT or PATCHupdateupdates an existing record
DELETEdeletedeletes an existing record


If you are interested in working on some projects, here are some popular APIs that you can use:

1. Open Weather Map

2. Google Map

3. Skyscanner Flight Search

4. Spotify

5. Deezer

6. Url Shortener

7. Yahoo Finance

8. Urban Dictionary

9. NASA APIs

10. Words API


That will be all from me today. I hope you have been able to learn one or two things by reading this short piece from me. Remember to stay positive

Food for Thought:- "You do not access an API, rather you access a database, product, part of a webpage, etc through an API".


HAPPY CODING!!! ❤️