The word to really pay attention to is “Interface”. If you have any experience at all with programming, all kinds of abstractions and contracts must be coming to your mind when you hear the word “interface” but we are more interested in the classical meaning of the term.
An interface is a common boundary between two separate systems. It is the means or the medium via which these two systems communicate.
An API is the interface implemented by an application which allows other applications to communicate with it.
Why Is It Needed?
In one word – communication. You might ask why communication is so important. Just imagine Notepad couldn’t copy-paste to and from Microsoft Word or Google Chrome. Imagine having to type each and every time although the text is already there in some other application. This is only one of the examples of communication between applications and all this communication is made possible via APIs.
What Is It Really?
You cannot run an API like you would run say a Notepad application. This is because APIs are generally invisible to the end users like you and me. APIs are carefully thought out pieces of code created by programmers for their applications that allow other applications to interact with their application.
APIs are specially crafted to expose only chosen functionality and/or data while safeguarding other parts of the application which provides the interface. Creating an API is indeed time well spent, because ultimately the more applications that interact with your application the more popular it becomes.
An excellent example is Twitter. Most people prefer their favorite Twitter client instead of the web interface. You can interact with Twitter whether you are using a mobile phone, a smart phone, an iPod or a computer. This has been made possible by the excellent Twitter API.
What Is It Good For?
As we have seen, APIs facilitate communication allowing different applications to communicate effectively with each other. So these are really well suited for extending a platform and for mashups. We have already seen Twitter as an example of how APIs are useful in extending a platform. When you combine data or functionality from more than one application to create another application, you have essentially created a mashup.
Such mashups are extremely popular on the Internet these days. The Internet thrives on communication so it is an ideal place to take advantage of APIs. It is a common practice to expose part of your functionality or data as an API to others on the Web. They can then tap into what you offer, combine it with what they (or someone else) offers and then provide improved and added functionality to their users.
Yelp for example has data on restaurants, hotels, shopping destinations and other local services but it would be a wasteful and tedious job if they set out to create their own Maps engine to let users know where the various destinations are. So instead they tap into the Google Maps API and plot their data on top of it, thereby increasing the utility of their service to the end user. This is a typical use of an API.
Popular APIs You Can Use Or Try
APIs are all over the place. The most popular ones are the Web APIs like Google Maps API, Twitter API and the Flickr API. These are not the only ones though. You can find a complete, classified and searchable directory of APIs at Programmable Web and WebMashup. Here you can see the level of interest in an API, what services are provided by the API and which services are making use of the API.
How you actually use an API depends upon your needs and your level of expertise. You might want to create the next big thing on the Internet, in which case you would most likely need to program for the Web using languages such as PHP, ASP.NET, Java or Python. A good starting point is to visit the official API page for the service you choose. Look for libraries others have written in the language of your choice. Usually these libraries make your job a lot easier and faster. Twitter for example mentions a number of these libraries on its API wiki. You can also find tutorials, official documentation and best practices on these pages.
APIs have existed in one form or another for a very long time. The first communication between cooperating applications may or may not have been through an officially documented API, but nowadays they are an important component of your application especially if yours is a Web application.
Have you ever created or used an API? We would love to hear about your experiences in the comments.