The Way of the Future...

The internet, as a resource, works a lot better with a healthy dose of cooperation. That’s why APIs are the coolest thing since sliced bread in the computer world.

https://media.giphy.com/media/jfLJxNiDN1a6Y/giphy.gif

By the end of this, hopefully you get an idea of what APIs are and the purpose they serve. So without further delay, let’s get into it.

But first…

Encapsulation

There’s an idea in computer science. Many, actually, but this one is called data encapsulation. The concept is this: imagine there’s an object in front of you. It’s a machine that takes some input and output. Encapsulation is the idea that there’s a lot of things that happen inside that machine that you’re not concerned about (or explicitly should not be exposed to) that eventually lead to an output you wanted in the first place. With this idea simmering on the backburner, let’s look at APIs now.

Application Programming Interfaces (APIs)

An API is the means to keeping the concept of encapsulation working proper, among other things. Just like in the previous example, a system may take a variety of inputs and outputs. More often than not, the user of these systems doesn’t need to know what’s happening under the hood. So there’s no real reason to show it to them… it’s encapsulated. The user has access to a couple of functions to get the job done, and that’s it. The API’s purpose in this system is to provide the user that access.

Say I’m writing a script that wants to check the most recent Bitcoin to Ethereum sales. Using their RESTful API, I can easily get the info I’m looking for simply by generating a hyperlink. If you click that link as a human, you’re gonna see a ton of data that hurts your eyes. If you get the data from that link as a computer, you’re looking at a well-organized set of data great for analysis.

I’ve written a short example script that uses the Requests library to handle the API. You can check it out here.

http://38.media.tumblr.com/466384be56193bc163b652bdf9540daa/tumblr_ndwmedR42T1u0edg8o1_1280.gif

The ease of access an API allows is what makes them the optimal solution for collaboration between different platforms. As demonstrated, an API lets completely independent developers quickly utilize an application. That’s the beauty of APIs: the ease of access.

With all of the above in mind, hopefully the concept of an API is better understood. In the end, the concept is fairly simple… but the benefits are too great to ignore! APIs are just one of many resources available on the internet that constitute a healthy level of collaboration and cooperation.

This article originally appeared at ryanh.net.