One of the most exciting trends on the Internet today is interconnectedness. Application programming interfaces (APIs) help make this possible. For example, if I have created a blog at WordPress, I can get a free key to use the API at Akismet, a comment-spam-prevention service. Additionally, if I have a Flickr account, I can get another free key to access its API to display my photos from Flickr on my new blog. By interfacing with other websites, in other words, my blog is now more functional than it used to be. So what are APIs, and why should I pay attention to them?
What is an API?
The first question is much easier than the second, so let’s start with it. When a website such as Flickr offers an API it provides a method for other applications, such as other websites, to access its content. In the same way a person can visit Flickr and be presented with web pages, an API provides a way for computers to visit Flickr and be presented with the requested content.
Here’s an example. Say a user visits the hypothetical blog I spoke of and is presented with images from Flickr via his or her API. First, a request is sent to a particular URL, such as Myblog.wordpress.com, which triggers the server to begin processing the scripts that make up that web page. During this processing period, the server also contacts a particular URL at Flickr, passing some variables such as a user’s access key, user name and any other criteria the API understands. Flickr’s API then responds to the server that made that request, sending it the location of photos that match the user’s request criteria. Now that the user’s blog server has gotten what it needs from the Flickr API, it builds the web page the user asked for in the first place and sends it to him or her. In a nutshell, this is how web services work.
Why focus on APIs?
So if an API is simply a way for computers to interface with each other, why exactly should I pay any attention to it? There are two issues to consider here. As discussed above, by interacting with the Flickr API my blog is able to display photos from my Flickr account. Additionally, by interfacing with the Akismet API, I can protect my blog from comment spam, since comments are first sent to Akismet where they are checked against known spam to determine if they, in fact, qualify as spam. Once the comments clear Akismet, they are allowed to appear on our blog. By taking advantage of the APIs that these services made available, I can seamlessly benefit from their services.
Also consider providing an API for others to use. A website owner may want to implement an API into his or her site in an effort to boost marketing or provide a service to his or her users. For example, let’s pretend the blog I set up earlier is supposed to be a promotional tool for my online store. My intention is to blog about new products available at my online store and how I feel about them as a consumer. By implementing an API, I can have my blog interact with the store and allow me to include the products in my blog. I’ve now created a new method of distributing my content without more maintenance. If I change the product information on my online store, it changes automatically on the blog and any other websites that access the API.
With the amount of new web services created daily, paying attention to which companies are offering APIs can help with important decisions. Providing an API for your partners or customers can help with marketing and with distributing your content. Interacting with an API just might make your website more personable and boost sales.