Freelancing Beginners: Web Design Part 3: Application Programming Interface (API)

Posted on Posted in Blogs, Technology

The phrase application programming interface has eluded me for a long time since I started working as a freelancer. You see this phrase or its abbreviation(API) everywhere but can’t find a definition that a beginner can properly understand.

The first paragraph in the wikipedia page says

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. An API may be for a web-based system, operating system, database system, computer hardware or software library. An API specification can take many forms, but often includes specifications for routines, data structures, object classes, variables or remote calls. POSIX, Windows API and ASPI are examples of different forms of APIs. Documentation for the API is usually provided to facilitate usage.

Ok. If you have understood the concept already you would want to skip the rest of the article. For the rest like us, lets dive deeper.



What is Application Programming Interface:

In the most basic of terms, its the interpreter(middleman) between two blocks of codes(programs/libraries/modules). For our discussion let us consider both the individual blocks of codes to be two separate programs. The API hides or abstracts the individual programming logic/code from each other. So one program never knows the implementation of logic of the other.



Application Programming Interface in web design: Web APIs:

Use of APIs in web apps have increased tremendously mostly because it provides a lot of functionalities to a web app that the web developer need not implement himself, thus he can concentrated more on the UI/UX of the app.

Let us consider a simple example. Everyone must have heard the phrase “Facebook API” and have seen “Login with facebook” button in many websites. In this scenario, the ultimate goal of the web developer is to get the new user’s information directly from facebook. So he need not write code to present the new user with a form and extract the information and validate them. He just have to integrate the “Facebook API” in his website and put a button in his login page. When the new user click the button and gives permission, the “Facebook API” sends the information of the user to the website, which the developer can then store in his own database.

This scenario is also beneficial to the user, as he doesn’t have to keep filling up forms in every website he wants to have an account in. Moreover this enhances the user-experience of the website and draws more traffic. Most of the big web companies like facebook, twitter, github, reddit etc have their web APIs and are extensively used by developers.



APIs in Mobile apps:

One of the most significant use of APIs is in developing mobile apps. Consider a web app with a huge business and thousands of users wants to develop a mobile app. Would they implement all their business logic in complete new platforms and languages(java for android, swift for iOS or any other) and migrate their databases? And how will things remains consistent across individual platforms? Moreover interacting with a remote database through a mobile app is not the best way to do things.

So instead the web app creates an API of its own and exposes “end-points” through which mobile apps can communicate with the entire system. The communication happens in a data format called JSON and uses http protocol which are support by all mobile app platforms and their implementation remains same across all languages. The mobile app developer doesn’t need to know about the implementation of logic in the original web app. This type of API is called REST(Representational state transfer) API. We will discuss about REST api in details in another blog.

Twitter in its early days didn’t have mobile apps of their own and exposed their API so that third party vendors made mobile apps for twitter.

This type of architecture is called a “client-server” architecture. Here the mobile app is the client and the web app is the server. Now to avoid any random client from accessing the server, the APIs need to implement authentication. Here by client we don’t mean individual users, but third party apps which interact with the exposed API. The most widely used authentication method today is OAuth. We will discuss about OAuth in another blog.



What we learnt about Application Programming Interface:

Contrary to general belief, application programming interface is a very simple concept. It has two basic purposes.

  • A means of communication between two programs.
  • Abstract the business logic/implementation from each other.

APIs are also used as external services like image processing, audio processing or any other complex functionality that the web developer doesn’t want to code himself. With the rise of API based services its getting easier for web developers to write powerful web applications giving more emphasis on the UI/UX part of the applicaton.


If you liked this article please comment and show your support and interest so that I’ll be motivated to continue this effort. Like our facebook page if you haven’t already.