What are application programming interfaces (APIs), and why they matter.
It’s been a while, but it’s time to get back to work. This series looks at the world of independent development, and asks what makes it possible. In the first article in this series, I looked at cloud services. In order to explain, what these services can do, I need to explain how we can work with them, via APIs.

Making Connections

An interface lets two or more entities connect to each other. Hardware interfaces, like USB, let you plug devices into your computer. A user interface (UI) presents an abstraction that lets us communicate with machines. APIs let computer programs talk to each other. Here’s Wikipedia’s definition.

In computer programming, an application programming interface (API) is a set of subroutine definitions, protocols, and tools for building application software. In general terms, it is a set of clearly defined methods of communication between various software components. A good API makes it easier to develop a computer program by providing all the building blocks, which are then put together by the programmer… Wikipedia: Application programming interface

For the sake of simplicity, the rest of this article will concentrate on web-based APIs.

Spinning Webs

Although the Internet predates the web, it was the web that made it accessible. Two of it’s key innovations were the Uniform Resource Locator (URL) and the Hypertext Transfer Protocol (HTTP). URLs are a form of address that lets us locate web sites and pages. HTTP is a set of simple commands that enables a program make a request and receive data from another machine (web server). In conjunction with the Hypertext Markup Language (HTML), we had a new way to find, request, display, and link information.

From Static to Dynamic

Originally, the web let us create and consume static data in the form of formatted text and pictures. It looked great, and was mostly free, but you couldn’t do much with it. For a start, most pages were created and maintained by hand, and this meant that web pages quickly became out of date. More importantly, if you couldn’t interact with live data you couldn’t provide advanced online services like maps or shopping. Over time many realized that you could make the web dynamic by using a combination of URLs and HTTP. When this was combined with new data interchange formats, such as XML and , it became possible to create GMAIL and Google Maps.

APIs in Use

You can find an API for almost anything. Unfortunately, due to business and/or security concerns most of them aren’t freely available. The good news is that there are many publicly accessible APIs. For example, governments provide a lot of useful and interesting data via public web services. Recently, I wanted to learn more about air quality in real-time. After a bit of Googling, I discovered that the government of Israel has a realtime API for measuring air pollution levels. If you want to find out the latest air quality index, you can use the following command:

http://www.svivaaqm.net/api/stations/2?getLatestValue=true&type=json

If you click the link, you’ll get the latest data reported by local measuring stations. The information is formatted as JSON.

Wrapping Up

Today, web APIs let us interact with remote systems. Each time you use Amazon, Google, Facebook, or your bank, you are using an API. So, most people working as web, mobile, and enterprise developers spend a large amount of time working with APIs. Without them, we couldn’t take advantage of cloud service and I wouldn’t be able to work independently. In my next article, I’m going to take a deeper look into one API based service, and how this opens up almost limitless possibilities.