Ready to Start Your Career?
July 15, 2018
What is an API?
July 15, 2018
While many computer users do not know what an application program interface or API is, all of them indirectly interact with and benefit from them every day in the applications and devices they use. As indicated by its name, an application programming interface is a boundary across which two entities communicate to relay requests or information to carry out tasks. In the context of computers and Internet-connected devices, an API is a set of programming protocols and guidelines that must be followed for one system to access and communicate with another. The two systems or entities can be two software applications, operating system software and hardware, hardware and an application, a website and a web browser, a website and a server, or a number of other combination pairs.
What Does an API Do?Application programming interfaces essentially work as intermediaries or messengers that not only send information back and forth between two systems but also specify how the two systems should interact and communicate, particularly when it comes to things like what information should be shared between them and how the receiving party should present that information to an end-user of an application, for instance.
How an API WorksAs intermediary messengers, application programming interfaces function similarly to waiters at a restaurant. A user on a smartphone with multiple apps is like a patron at a restaurant with a menu listing several meal choices to select from. When that user opens an app and logs into his account, he is sending a request to the server that app is on to connect to the app’s system. This is similar to the restaurant patron putting in a request to the kitchen to prepare and send him a steak dinner. Like a waiter who takes the patron’s order including details like how well to cook the steak and sends the order to the kitchen, the API takes the user’s username and password and transfers it to the server. Once the server receives the login credentials from the API, it uses them to retrieve the account record that corresponds to those credentials, and through the API, it delivers access to the account in the form of the account dashboard to be displayed on the phone screen in a predefined format to the user. This is just like the kitchen receiving the patron’s order from the waiter, cooking the steak dinner to the patron’s specifications, for example, well done, and passing the prepared meal to the waiter for the waiter to present to the patron.Another real-life example of how APIs work is a travel website like Kayak.com. A traveler looking to book a flight will visit this site and enter information including travel dates, times, and departure and destination locations in a request to view all the available flight options and prices from multiple airlines for his specified dates and times. Kayak, in turn, sends the traveler’s information to all of the airlines’ databases through each airline’s respective API. Each airline’s database server takes the traveler’s trip details, finds flight dates and times matching closest to those of the trip, and sends them back to the Kayak website through its API. The Kayak site then takes all of the information from all of the airlines and displays them to the traveler on the results page.
APIs Make Things EasierApplication programming interfaces primarily serve to facilitate processes for both end users and developers. For example, in the travel website example above, the traveler can get information on all the available flights for his trip in one convenient place on Kayak.com instead of visiting the sites of all the airlines separately to look up flight times and prices, which would be much more time-consuming. Another example of how APIs benefit end users is embedded objects on websites that provide supplemental information. If a patient visiting a dental office needs to find the address and location of that office, he would typically go to Google Maps or Mapquest and enter the name of the office on one of those map sites to get the address and visual of the location on a map. However, if that dental office has a website that includes a contact page displaying a Google Map that is embedded through Google’s map API, then that patient can save time trying to find where the office is located.Similarly, the web developer working on that dental office website also benefits from the Google Maps API that can embed map objects on websites. By utilizing a third-party API to display maps on websites, developers don’t have to invest man hours and resources into creating their own maps from scratch and retrieving raw geolocation data that must be formatted and customized for incorporation into those maps. Likewise, operating systems on computers and smartphones have APIs in place that allow third-party apps installed on their systems to interact with the device’s components, such as built-in cameras. For example, if webcam software is installed onto a Windows OS computer, then it can use Windows’ camera API to access the camera for recordings, eliminating the need for developers of the webcam program to write customized software code to enable interaction between the program and the hardware of the camera. This is also how mobile apps work with the APIs of smartphone operating systems. Social media app Instagram, as an example, interacts with the APIs on an iPhone’s iOS system to access the phone’s microphone and camera to allow users to make videos that are recorded and displayed in the app instead of having to create code that directly accesses the device’s microphone and camera hardware.Therefore, for developers, APIs can make the software or web development process for an application or website more efficient and streamlined. It prevents developers from having to expend labor and costs in “reinventing the wheel.”
APIs Make Things SaferBecause application programming interfaces enable only indirect communication through an intermediate between two applications or systems, they prevent full exposure and access between the two parties, which provides a layer of protection to users, their devices, and the interacting applications.Going back to the camera example in the previous section, before Instagram can access the iPhone’s camera through the iOS camera API, the user must first opt to enable access to the camera through a dialog screen that appears when the user selects the button to create a new recording.Internet users who visit retail websites to find physical stores in their local areas may see a dialog box pop up that says the website wants to know their location and displays two button options of “Allow” and “Block.” This dialog box comes up when the website is trying to access the geolocation API of the user’s web browser. It is only through this geolocation API that the website can obtain the physical location of the user through the device’s location sensing hardware or software, and it is up to the user to decide whether to allow or block access to his location.Therefore, APIs provide controlled access to data that can keep users and their information protected from potential outside threats.
More API ExamplesWith such a huge range of applications, APIs are used everywhere. Here are just a few more examples of platforms that utilize them:
- Twitter – Social media platform Twitter has a developer site that provides developers with tools and resources that include APIs so that they can embed Tweets on websites, search for Tweets, and more.
- YouTube – YouTube also has a developers’ suite where developers can get guides to embed video players so that they can play videos directly in their applications on different operating systems like Android and iOS.
- Foursquare – Foursquare is a mobile app that uses location intelligence to help users find new places and venue recommendations like restaurant choices in their local areas. It provides a Places API that developers can use to incorporate location discovery and destination sharing features into their applications for end users.