In the past years, it seems like more and more people have been talking about APIs and yet a lot of people don’t seem to really know what an API is. An API in short is defined as an Application Programming Interface, doesn’t sound so special does it? Well to a developer it’s not that special, APIs have been around for a long time and have been a pretty standard concept. Typically, a developer that wants to use a 3rd party tool, or any object/class will read a document that explains how to use the object and then will make a connection to this object with code. So, in a nutshell an API just allows one piece of code to talk with another piece of code. I’m sure at some higher level, the real definition is much more abstract than that :).
Think of RSS
API’s as a buzz word has grown in recent years because it has become standard practice to develop web applications that share data with other applications. If you’re at all confused then think of RSS feeds and consider how you can read RSS feeds with various programs or web sites. The concept is similar for an API, there’s a source that provides a information in a standardized format so that the consumer applications (e.g. – RSS reader) know how to read and present the data.
So why is an API important?
Now if you take the model of an RSS and take it further, so that the source application can provide various types of information, you have what is the makings of a RESTful web application (another buzz word). A web application provides an “interface” for other applications wishing to use the data by exposing a public API that tells the consumer applications how to use the data. For example, Twitter and Facebook define and refine their public API to dictate what data 3rd party applications can use. In most cases, a web application’s API should provide ways to create, read, update, and delete (CRUD) data. So this means that some applications can build around applications like Twitter to extend their own application. For Twitter, their API has led to an explosion of web applications that allow users to do amazing things. One good example is hootsuite, a powerful social media dashboard, that combines data from Twitter, Facebook, Linked In, Foursquare and their list keeps growing!
Is that it? Pros and Cons…
Well not really, I’ve just tried to explain why an API is such an important concept. It basically allows web applications to work together to build even more powerful applications. At the moment, the major players (Facebook, Twitter, Google, etc…) use APIs to grow their user base and extend their reach. For the small players, APIs are like a VIP pass to a club with all the people you want to sell your products to. You can see that there are dangers with this type of system. Now all the control lies with the source provider, and generally speaking there is nothing stopping the source from changing the rule. Speaking from experience, having developed several Facebook applications with their API, there have been more than several times where changes to their API have broken my application. Or consider the risk you face if the source provider has down time? There are a lot of factors to take into consideration before creating an API driven application. Just think of this, Facebook and Twitter do not communicate with each through an API (at least to my knowledge). It all comes down to the business strategy and has nothing to do with technology. An interesting side effect of an API driven web world is that each business must consider new risks about the trade-offs and benefits of using or providing an API.
This was just a short intro at a very high level to what APIs are and why they have become the buzz word for many business IT folk. I took liberties in my definitions as my focus for this article was to explain at a high level and not to get bogged down in technicalities. I will follow this post up with a more technical article explaining the options for PHP developers looking to build a RESTful API.