What APIs are really
Tags: api, webdev, programming, help
Published: 2022-09-19 09:56:28

#Today, I'm going to try to simplify what APIs are.
Over time, I've seen developers struggle to understand this concept (including myself).

Before going into the thread, pretend as if you're learning APIs for the first time and today might just be your day.

API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other.

{% embed https://giphy.com/gifs/strangerthings-netflix-stranger-things-ka55CqnDNjQ7iIKtRa %}

Okay, relax😅; I know that's the exact explanation you've seen in many places. This is correct in every way, but it does not narrow down

Now, an API is a part of a server ⚙️ that receives requests and sends a response back to you when navigating a website. For instance, when you click🖱 on a login button, a request is sent with a response received in return. This response could be that your password is incorrect🚫, or you get logged in successfully✅ if the password is correct.

Here, the API is what checks if your password is correct or not. The button you clicked triggers a URL which is called the endpoint.

An endpoint gives you access to an API (a way of sending our inputs to the API). Simple, right?!🤔

{% embed https://giphy.com/gifs/cbc-funny-comedy-l4pTosVr0iHCJ11hm %}

Note that we cannot access how the API does its thing.

Fun fact,🙃 The API is just some function connected to a URL/link (the endpoint) on the server-side code.

##Here's another example🤗

Imagine you went to process an international passport. The woman👩‍🦰 you meet at the desk to whom you submit your document is like the endpoint↔️. She helps you take your document to who's going to process your document👨🏽‍💻. This way you don't get to meet 🚫 those processing the document. They are the API, they do the processing.

Your application for the passport either gets accepted😃 or rejected😞 based on the information📃 you provided, and that's based on certain standards.

The same with APIs, your request might not be accepted all the time if you do not meet the set rules and protocols 👮‍♂️ for the APIs, but that's nothing you should worry about now 😊.

##So how does this relates to the initial definition you see all over? Here's it.

Let's say you're building a site that requires a user to put in their number so that you can send them a verification text message.

{% embed https://giphy.com/gifs/scaler-official-monday-computer-laptop-scZPhLqaVOM1qG4lT9 %}


Imagine, you have a friend (not necessarily a friend in real life) who built a site that can send text messages. Would you rather build that feature from scratch yourself or contact your friend? Of course💁, you'd contact him to make life easier for you.

To help you, something your friend can do is to create an API on his system/server with an endpoint that allows you to text messages 😃 but that's not enough😧.

What!😭😭 Wait, but why 🤷‍♂️?! To send a text message you need to provide a number and the message to send. Without sending these pieces of information to the API, you'd get an error. And that's because there is a protocol about what inputs are required and the result you'll get in return. So that's what the initial definition is passing across essentially, an API is a way for two systems to communicate with each other. PS: You might need an API key to access your friend's API if he doesn't want just anyone to use it.

{% embed https://giphy.com/gifs/latenightseth-boom-3o7btNa0RUYa5E7iiQ %}


I could go more in-depth but I hope this makes you understand what APIs are or gives you an interface😉 to understand it better. Anyway, I hope you enjoyed it, if so, like this tweet so it can get to others who need it.

Here's a link to a list of public APIs, https://github.com/public-apis/public-apis.

Peace ✌️❤️