Application Programming Interface 101

Nimish Nama
Tech Trek for rookies
5 min readSep 22, 2020

Do apps like Uber, Pokémon Go and Zomato build their own maps to show where available cars are, help the user find wild Pokémon, or display nearby restaurants. Do these apps need to spend thousands of person-hours making their own maps? We all know, that the answer is no. They embed a Google Map in their app. Uber app draws the route you’ll take on a Google Map and calculates the approximate time it’ll take to get there.

Google lets you include a small snippet of code in your app to draw a Google Map, and it provides other snippets of code to let you draw on the maps, calculate driving directions between points on the map, and even find out the speed limit for a particular road. All of these tools are cheap or even free. These tools are big win for developers; they can use the technology which took Google years to perfect with just a small amount of code. There’s no need to reinvent the wheel!

These snippets of code that let you borrow another app’s functionality or data are called APIs, or Application Programming Interfaces. In short, APIs let apps talk to each other.

So, what is an API? It’s like a Menu.

In another analogy, you’re a program and the restaurants are programs that you want to interact with. To receive what you want (food) from the other program (restaurant), you need to make a request (place an order) in a specific way (defined by the menu).

APIs are like menus. Menus define a list of dishes and, when someone orders one of those dishes, the restaurant does a bunch of stuff and then sends the requested dish back. APIs define a list of commands and, when a program uses one of those commands, the other program does a bunch of stuff and then sends back what was requested by that command (usually some kind of data).

What is an API?

It’s important to note that food ordering analogy isn’t perfect. When you order food, there are many variations you could use to get the same result. But programs aren’t as smart and flexible as humans. When making a request to another program, the request has to be formatted in a very specific way.

If restaurants were like programs, saying “House Burger, medium-rare, no pickles, replace the fries with coleslaw” would get you your food but saying “may I please have the House Burger cooked medium-rare with coleslaw instead of fries and no pickles on the burger” would not. The restaurant wouldn’t understand what you’re asking because the request isn’t formatted correctly.

So APIs define a list of commands as well as the necessary format of those commands. When a company releases an API for their software, it means that they’ve basically told everyone: here is what you can get from our program and here is exactly how you have to ask to get it.

Types of APIs

There are three main kinds of APIs:

The first kind of API lets one app ask another specialized app to solve a particular problem, like calculating driving directions, sending text messages, or translating sentences. It’s like how you could call a plumber or carpenter to fix problems around your house instead of trying to do it yourself. Here’s an example: apps like Uber can use PayPal’s Braintree API, which lets anyone use PayPal’s algorithm for processing credit card payments with just a few lines of code. It’s pain to write code yourself that sends emails or text messages — so when apps like Venmo need to send you confirmation emails or texts, they can just use a specialised API. And any app that lets you log in via Facebook or Google uses those websites’ APIs for verifying someone’s identity.

The second type of API lets one app ask another app to hand over some interesting information, such as sports scores, recent Tweets, or today’s weather. It’s like calling the front desk at a hotel to learn which museums and restaurants they recommend. ESPN offers an API that lets you get rosters for every major-league sports team and scores for every game. New York’s subway system lets you track where trains are and predict when the next train will arrive at a station. And don’t worry, there’s even an API to get random images of cats.

The final kind of APIs, lets developers access features of the device itself. Snapchat taps into your phone Camera’s API to zoom, focus, and snap photos. Google Maps itself uses your phone’s Geolocation API to figure out where in the world you are. Your phone even has sensors called accelerometers and gyroscopes, which fitness apps (and Pokémon Go) use to determine in which direction you’re walking and how fast you’re moving.

It’s worth noting that APIs aren’t perfect. Using an API makes app developers’ lives easier, but it also makes their apps dependent on the API. If PayPal’s Braintree payment API somehow stopped working, Uber would be unable to process payments — not great for their business. Still, a specialized company’s API will likely be more reliable than any similar feature that a non-specialist company could make themselves.

How are they connected?

Let’s imagine that you are building an e-commerce application that takes orders from customers, verifies inventory and available credit, and ships them. The application consists of several components including the user interface, along with some backend services for checking credit, maintaining inventory and shipping orders.

APIs and UI let you connect to the multiple backhand services which are built on these Mircroservices architecture (described in previous post).

Software Architecture

Nimish Nama, IIM Calcutta (2019–21)

References:

  1. Swipe to Unlock- A Primer on Technology and Business Strategy by Aditya Agashe, Neel Mehta, and Parth Detroja
  2. What is an API? — A Simple, Non-Technical Explanation article by Calum McClelland
  3. Pattern: Microservice Architecture article by Chris Richardson

--

--