What is an API?
How do APIs work?

Image by J.A. Becker

This picture is the same thing as the women in the image above, there’s just more stuff in it. Think of it like this: Lady A is now the iPhone on the left and Lady B is the Web Server on the right. And all that’s between them is a fancy bunch of string that carries their communications to and from one another.

Standard Internet Communication

So before I get into how an API works, I need to explain a standard internet communication, which you’re probably already familiar with. In fact, it’s what makes viewing this Medium article possible. Works like this:

A.) You click a link to this article on your iPhone

B.) Your iPhone reaches out across the internet to contact a Web Server that has this article.

C.) The Web Server returns the article back to your iPhone and then you can read it.

And that is a standard internet communication that happens a gazillion times a day.

API Communication

Image by J.A. Becker

So same picture as before, but now I’ve put two API layers in it: one in front of the iPhone and one in front of the Web Server. The API layers are actually inside the iPhone and inside the Web Server, but I’ve drawn them outside cause I have no drawing skills and it’s easier to explain this way.

Now the communications go through the APIs. And that’s really the point of the API — it has a standard way to accept and process data for the system it is a part of.

That’s why APIs are usually represented with some kind of plug icon, like the image on the left. The data sent to the API has to match up with what the API will accept — else, you don’t connect. 🔌

So the iPhone API has a standard way of communicating and accepting data and the Web Server API has a standard way of communicating and accepting data.

And really that’s how an API works: the API is embedded in a device or a system and it defines how other devices or systems can talk to it.
['J.A. Becker']
['Learning To Code', 'How To', 'Technology', 'Beginners Guide', 'API']