If you are in tech domain, you will invariably bump in references to something called an “API”. You just can’t skip it – if you do, you are bound to hear it again. APIs are being used almost everywhere. But, if you have ever wondered what exactly is an API? or Why are they important? or How do they help? this article will help you out.
In this article, I will explain what is an API in simple terms. I will tell various categories / types of API. Then I will be introducing you to the different APIs which you commonly encounter in your day to day life. To add more value, I have listed down 5 useful projects you can work on using an API. I bet you will be tempted to try your hands on at least one of them.
Let’s get started!
In simple words, an API is a (hypothetical) contract between 2 softwares saying if the user software provides input in a pre-defined format, the later with extend its functionality and provide the outcome to the user software. Think of it like this, Graphical user interface (GUI) or command line interface (CLI) allows humans to Interact with code, where as an Application programmable interface (API) allows one piece of code to interact with other code.
One of the most common use case for APIs is on the web. If you have spent a few hours on internet, you have certainly used APIs. Sharing things on social media, making payments over the web, displaying list of tweets through a social handle – all of these services use API at the back.
APIs are widely used by developers for implementing various features in their software. They simply use a simple API call within their software to implement complex features instead of having to code it by themselves.
Let’s try and understand it better with the help of an example:
Pokemon Go has been one of the most popular smartphone games. But in order to build such a game taking in account the large ecosystem, one requires complete information of routes and roads across the globe. I’m sure the developers of the Pokemon Go must have faced a dilemma if they should code the maps of the entire world or use the existing Google maps to build their application on top of it. They choose the latter, simply because it’s practically not possible to create something similar to Google maps in a short span of time.
This is just one example. There are a lot of developers using various APIs to implement complex features into their applications instead of coding it themselves. Therefore, API provides a very convenient way of making code reusable.
Basic elements of an API:
An API has three primary elements:
A web API is an interface to either a web server or a web browser. These APIs are used extensively for the development of web applications. These APIs work at either the server end or the client end. Companies like Google, Amazon, eBay all provide web-based API.
Some popular examples of web based API are Twitter REST API, Facebook Graph API, Amazon S3 REST API, etc.
There are multiple OS based API that offers the functionality of various OS features that can be incorporated in creating windows or mac applications.
Some of the examples of OS based API are Cocoa, Carbon, WinAPI, etc.
Interaction with most of the database is done using the API calls to the database. These APIs are defined in a manner to pass out the requested data in a predefined format that is understandable by the requesting client.
This makes the process of interaction with databases generalised and thereby enhancing the compatibility of applications with the various database. They are very robust and provide a structured interface to database.
Some popular examples are Drupal 7 Database API, Drupal 8 Database API, Django API.
These APIs allows access to the various hardware components of a system. They are extremely crucial for establishing communication to the hardware. Due to which it makes possible for a range of functions from the collection of sensor data to even display on your screens.
For example, the Google PowerMeter API will allow device manufacturers to build home energy monitoring devices that work with Google PowerMeter.
Some other examples of Hardware APIs are: QUANT Electronic, WareNet CheckWare,OpenVX Hardware Acceleration, CubeSensore, etc.
At this point, I believe you might be scratching your head and confusing APIs with libraries. Let me simplify it for you, an application programming interface (API) is an interface that defines the way by which an application program may request service from the libraries.
An API is a set of rules with which the interaction between various entities is defined. We are specifically talking about interaction between two software.
Even a library also has an API which denotes the area of the library which is actually accessible to the user from outside.
IBM Watson has made certain data science APIs public for people like us to build amazing projects with only a few lines of code. Here, we’ll be looking at one such amazing API offered by IBM called Personality Insights.
This API takes as input in JSON, HTML or simple text format. The input contains text related to the person whose personality interests you. It can be anything like tweets, daily experiences, applications, opinion, etc of that person.
The output generated by the API is in the standard format of JSON or CSV file that contains the information on various social traits of that person. And the developer only needs to display this generated file to the user instead of coding the whole functionality yourself.
There is also a demo on the IBM website that can be accessed here. You can choose either the tweets or replies of few famous personalities to analyze their personality traits. The text can also be customized based on what input you want to provide and analyze the personality traits of that person.
You can integrate this API in your code as well and build an application on top of this API.
Facebook API provides an interface to a large amount of data generated everyday. The innumerable post, comments and shares in various groups & pages produces massive data. And this massive public data provides a large number of opportunities for analyzing the crowd.
It is also incredibly convenient to use Facebook Graph API with both R and python to extract data. To read more about the Facebook API, click here.
Google Map API is one of the commonly used API. Its applications vary from integration in a cab service application to the popular Pokemon Go.
You can retrieve all the information like location coordinates, distances between locations, routes etc. The fun part is that you can also use this API for creating the distance feature in your datasets as well. Read here to find out its complete implementation.
Just like Facebook Graph API, Twitter data can be accessed using the Twitter API as well. You can access all the data like tweets made by any user, the tweets containing a particular term or even a combination of terms, tweets done on the topic in a particular date range, etc.
Twitter data is a great resource for performing the tasks like opinion mining, sentiment analysis. For detailed usage of twitter API, read here.
IBM Watson offers a set of APIs for performing a host of complex tasks such as Tone analyzer, document conversion, personality insights, visual recognition, text to speech, speech to text, etc by using just few lines of code.
This set of APIs differ from the other APIs discussed so far, as they provide service for manipulating and deriving insights from the data. To know indepth details about this API, read here.
Quandl lets you invoke the time series information of a large number of stocks for the specified date range. The setting up of Quandl API is very easy and provides a great resource for projects like Stock price prediction, stock profiling, etc. Click here, to read more details about Quandl API.
I am sure that you are fascinated after reading about the above APIs, but wondering if you could a create project using these APIs which will be great value add to your CV? Well, here’s the list of ideas you can start with. You can either use these APIs to retrieve data & manipulate it to extract insights from it or pass the data to these APIs & perform complex functions.
Here are the list of the projects for you. I’ll leave the execution of these ideas to you.
Further reads:
Take a step back – you have just got a glimpse of an entirely new world. Think of all the possibilities it enables – need face recognition on your mobile application – no worries! just invoke Google Face recognition API. Need to translate documents in Japanese to English – why not try Google Translate! The possibilities are limitless!
A few things to keep in mind while you think of building and using APIs:
After going through this article, I believe you would have acquired a better understanding of APIs and how helpful they can be. I have only mentioned some of the popular APIs but the list is endless. If you would like to add to the list of APIs, please share them in the comments below.
I’ll encourage you to pick up any of the suggested projects and work on it. I bet you’ll be shocked by the power and ease with which you’ll be able to perform a complex task that would otherwise have been difficult to implement yourself.
Did you enjoyed reading this article? Do share your views in the comment section below.
That's fine! good informative article. Thanks for sharing your knowlegde with everyone.
Hey Jacques. Glad you liked it!
Thanks for your sharing. Learned a lot~
Hey Wang Hao. Happy to help.
Thank you for the insightful post on API. Ihave actually book marked it for my future. I am actually studying MATLAB and before study ML with the same language sometimes later. Are these APIs applicable to MATLAB, Specially for web-based API because MATLAB is not extensively used with the web (I might be wrong, because I am only a beginner).
Hey James. Thank you! Yes MATLAB isn't the most popular we talk in context of APIs. But there are a few of them available. If you really wish to web-based APIs, you might find it convenient to do using Python or R instead.