What is an API?

Edwin Walela
5 min readApr 28, 2020

--

Uber under the hood.

Photo by Dan Gold on Unsplash

Uber’s mission is transportation as reliable as running water, everywhere, for everyone. To make that possible, we create and work with complex data. Then we bundle it up neatly as a platform that enables drivers to get business and riders to get around.” — Lucie Lozinski

We interact with at least 9 apps on our phones every single day. From streaming services to our mail, these applications all have a similar goal — to provide us with a service.

Facebook became the first social networking platform to hit the one billion user mark and now it sits at about 2.5 billion active users. In 24 hours, more than 18 thousand years worth of TV shows are streamed by Netflix users and a whooping 14 million Uber trips are completed.

These are big numbers which our minds might find difficult to process. Under the hood of such complex systems of computers, one key entity does most of the weight lifting that allows you to catch that Uber after a great night out with friends — API’s

So what is an API?

An API — Application Programing Interface — can be thought of as a middle man who has 3 main purposes:

  • Receive a request from a user
  • Instruct the server on what to do depending on the request
  • Provide a response to the user.

Now let’s break this down using Uber as an example.

Photo by Fabien Bazanegue on Unsplash

Uber(formerly known as UberCabs) began back in 2009, when Garret Camp got tired of the inefficient taxi services of San Fransisco. According to Brad Stone’s interview with Camp in The Upstarts, people were missing flights and getting late for dates due to the unreliable town cab services. Camp’s idea was simply, to push a button and get a ride.

Uber has proven to be the benchmark of ride hailing services boasting 10 billion trips completed worldwide to date. So the question is, How do they do it?

Uber’s Architecture

Simplified system architecture at Uber

The systems architecture at Uber can be visualized with this diagram. However, this has been simplified for the purpose of this article. Uber makes use of multiple API’s and databases.

The journey begins at the mobile application — the client. A client is what we interact with when accessing an online service. Examples of clients are: a web browser or mobile application. Using either the Android or iOS app, you start by selecting your destination and the type of Uber you’d like (UberX, UberXL or UberCHAPCHAP among others).

The mobile application packages your request into a format the API can easily understand before sending it. This is usually the key purpose of most clients — to package your request, forward it to an API and display the response in a human friendly form.

Information captured by the application include: your location,your destination and the type of Uber you have requested.

Request sent to the API when requesting a ride.

Your request is then transmitted over the interwebs to Uber’s API.

Uber’s API has two major functions: to locate a nearby driver and calculate your trip distance. Using the user’s location, it is up to the API to query the drivers database at Uber and find the nearest driver available.

The user should also be provided with a fare estimate.This is calculated using the origin and destination coordinates provided by the user. After the computations are complete, the response is again packaged before being sent back to the user.

Response sent back from the API

A few seconds after first opening the app, your ride is already on its way.

Uber driver on his way to pick up a client.

The ability to simply push a button and get a ride is made possible by an API which sits between you and Uber’s databases. Many of the applications we interact with follow a similar architecture.

This is the same principal Netflix uses to ensure that you can watch your favorite show from whichever platform, be it from your browser, phone or TV. The API is the same but the client is what changes depending on the device you are using.

Other terms that float around when talking about API’s is REST — Representational State Transfer. Without diving in too deep, REST can be thought of as simply a design pattern for building API’s.

API’s can be developed using different programing languages: PHP(Laravel), Python(Django), NodeJS(Express), Golang(Mux) and Java(Spring) to name a few.

People frequently mistake API’s for servers (computers) which run on the internet. An API is the piece of code that handles and responds to requests from clients (mobile apps,desktop apps and web browsers)

An API isn’t the same as the remote server — rather it is the part of the server that receives requests and sends responses. — Petr Gazarov

Being the backbone of the internet, API’s allows devices to communicate with servers and databases on the cloud.

A good analogy is a waiter at restaurant. You give them your order, they take it to the kitchen where the chef prepares your meal using ingredients in the store and the waiter return with your meal.

Thank you for reading this article. I hope this inspires you to dig deeper and learn more about API’s and understand how the different applications and websites we interact with every day work.

Believe it or not, if it weren’t for James Bond, we might not have had Uber today as we know it.

Daniel Craig’s Casino Royale

--

--

Edwin Walela

Writing is a way of building relationships. Just because they are invisible doesn’t mean they are not there. | Web development | Cryptography | Everything Tech.