API: A Perfect Introduction

APIs are everywhere, and you probably use them without even realizing it. But what exactly is it? Let’s take a look at a high-level explanation of what APIs are, and what they do for you.

API stands for “Application Programming Interface”, and is a fairly general term for what you could consider a sort of “bouncer” for programs and applications. It creates a way to safely interact with data from a database without providing direct access. So first, let’s talk about something that doesn’t use an API: Your WordPress website.

Well, kinda does, but that’s another discussion

When you use your WordPress site, it actually pulls data directly from a database and displays it to the viewer to be read. And if you have admin access, you can do other things to edit or even remove the data from your website. It has a username and password that it uses to prove it has access rights to the database. But what if it were an application?

Obviously, Facebook or Twitter are not going to build an application that has this database access information in the application. That would be incredibly stupid. Instead, they provide a gateway, such as an API, that does this for you. When you open your application, it’ll go attempt to get that information. The API will make sure that it’s a legit request for information, and provide information based on the user’s access capabilities. So the application has no knowledge of the actual database. Everything passes through the API.

When you go to submit data, the API will not only verify that you have rights to do so, but also that all of what you’re attempting to submit is properly formatted. This not only protects from incorrect data entry but also adds an extra level of security. If you don’t tell the API exactly what it needs in the EXACT right way, no sale.

A common example of this is comparing it to a restaurant. You go there to get food. You want food. Now, you may have the know-how to use a kitchen and even to cook/prepare the meal you want. Trouble is, that’s not your kitchen. You can’t just walk in there (without maybe getting arrested) and cook it yourself. That’s the cook’s job. Instead, you have a waiter who acts as the middleman. The waiter is the API in this situation. The waiter goes into the kitchen on your behalf and brings back the food you ordered (after you wait anywhere between 10 to 128,512 minutes) to your table.

APIs can do a lot more than just this, but that’s for another day. Hopefully, this has answered some questions and created new ones.