DEV Community

Cover image for What APIs are really
Emmanuel Temitope
Emmanuel Temitope

Posted on • Originally published at techemmy.hashnode.dev

What APIs are really

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.

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?!๐Ÿค”

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.

Work Coding GIF by Scaler - Find & Share on GIPHY

Discover & share this Scaler GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.

favicon giphy.com

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.

GIF by Late Night with Seth Meyers - Find & Share on GIPHY

The official GIPHY channel for Late Night with Seth Meyers, airing weeknights at 12:35/11:35c on NBC. #LNSM

favicon giphy.com

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 โœŒ๏ธโค๏ธ

Top comments (0)