So, I was in a class the other day and someone mentioned this quote by Albert Einstein:
If you can not explain it simply, you do not understand it enough.
In this article, I will explain APIs in the most simple, basic and fun way.(so help me God.). Alright, lets get started.
What is an API?
API stands for Application Programming Interface.
It is a software intermediary that allows two applications to talk to each other. Huh, what?
It's like a language 2 systems use to communicate.
So, what does this mean?
To simplify, an API delivers a user's request to a system and sends the system’s response back to a user.
APIs are a set of functions and procedures that allow for the creation of applications that access data and features of other applications, services, or operating systems.
Okay picture this, you go to a restaurant and you want to get some good food. You don't go directly to chef and tell them what you want. You look at the menu and it tells you what the restaurant offers. This menu is the API. The API essentially tells you what certain application (our restaurant) is giving to you and the things you can use from the application. When you order something from the menu, the restaurant will give you want you ordered (data). So when you access an API, you send it what you want, then it'll send back information based on what you wanted, but if you go to this restaurant, assuming it's a local Nigerian restaurant, and you try to order something like chicken and fries. They'll throw an error at you And then tell you to pick something from the menu. That's also what makes APIs secure because they only expose what they want to expose to the world. You don't need to know the internal code/documentation/ of the service, you have to send a simple command or request and the service will return the appropriate data.
An example is a Weather API. If you want to know the weather conditions in a particular area, you know you just need your location and you know your weather app will tell you the information, the API tells the weather app that you entered your location and the app tells you the weather conditions at that location. (Delivering user's request to the system and sends the system's response back to the user.).
Also, you know when you order something from a website, let's say amalaistrash.com and when you want to pay it tells you to pay using Flutterwave? It just basically means that the website is using the Flutterwave API to process the payment.
Hope that was clear. Moving on.
Types of Web APIs
Web APIs can be accessed over the web using the http protocol. There are 4 main types of web APIs.
Open APIs
aka Public APIs. They have barely any restriction because they are publicly available.
Partner APIs
Quite similar to open APIs but the developer needs specific rights to access this because they are not available to the public.
Internal APIs
aka Private APIs. They're usually hidden from external users and are designed for internal use within a company.
Composite APIs
They combine different data and service APIs and allow developers to access several endpoints in one call.
REST and SOAP APIs
As a developer, you've probably heard about REST and SOAP. What are those?(besides being really catchy acronyms.)
REST stands for Representational State Transfer. It is a set of rules that developers follow when they create their API. A REST API leverages HTTP methods. It uses the following requests:
GET to fetch data.
PUT to alter the state of data (such as an object, file, or block).
POST to create data.
DELETE methods to delete/remove data.
SOAP stands for Simple Object Access Protocol. It is a standard communication protocol system that permits processes using different operating systems.
To understand more about REST and SOAP, you can read this
Examples of APIs
Weather APIs e.g Dark sky API, accuweather API, ClimaCell API.
Payment APIs e.g Flutterwave API, PayPal API, Stripe API.
Music APIs e.g Spotify API, iTunes API.
You can check these out. There are many more for different functions.
This brings us to the end of the article. I hope I was able to explain the basic concept of APIs properly.
Some resources that helped in writing this article and which further explain APIs include :
Thank you for reading and till next time,