APIs explained: A connected future

desktop computer in white table
Photo by bongkarn thanyakij on Pexels.com

If you’ve done so much as opened your smartphone today, you have indirectly come in contact with a number of APIs. Opened the Twitter app, shopped online, or checked prices for a flight? By now likely hundreds of unique APIs. 

APIs have changed the way we conduct business, and they are here to stay. Over the next few years we’ll start to see them shift even more from the technical talks to the business conversation. Here we are explaining APIs and how they work. 

What is an API?

API stands for Application Programming Interface. Helpful, right?

In concrete terms, an API is an exposed function, or piece of code, that allows access to data for the consumers of a product or service. Some may describe it as a messaging tool for sharing data, which is an accurate way to depict it. APIs allow lightweight, fast sharing of data for B2B or to consumers. 

Think of an API as a pre-built query for important information you may want to know. When you request the information for your specific data requirements, it returns a response with what you need. Let’s take a look at a few examples used in business today.

Examples of APIs that exist today

Think of a product or a service that contains information you need. Maybe it’s an online store, your banking app, or a restaurant reservation system. When you enter a specific search parameter (Women’s shoes, Size 6, Sandals), it displays the shoes they have in stock.

Now let’s take it a step further for some of the business uses. To offer a service or product, businesses may have to rely on the data of other businesses. Take for example Mint, the budgeting application. It’s imperative for Mint to have integration and API access to credit card companies, banks, and lenders. Without it, the budgeting process would be much more arduous for the end-user.

Back in college, I developed a simple program for an IT services company. This program would calculate and display a coverage map. The objective was to find, given a list of addresses for service operators and a list of addresses for the retail locations, what percentage of retail locations of the 14,000 in the list would fall within a 90-mile serviceable range from the operators. But for the application to work, I had to be able to calculate driving distance for each of these. Enter the Google Maps Drive Distance API. 

By passing the two addresses from my program as parameters, this specific Google Maps API would return drive distance between the two. Because of the data from the Google Maps API, I was able to provide value with my program to determine how many locations would fit within the 90-mile range of the operators.

APIs exist for more than just retrieving data. Let’s use a reservation system for example. When you check availability for a hotel online you may be using the “Check Availability” API to query for the selected dates and location. And when you book a reservation you’re using the “Reserve Room” API to insert a new reservation record in the system.

Now we’ve seen some examples. Let’s dive into more of the details.

How APIs actually work

Think about how you interact with a website. When you load a page or click a button, you are sending a request, via HTTP (HyperText Transfer Protocol). That little delay between clicking a button and having the page fully loaded is the server working to process your request and return a response. There is information on the response message containing the information queried. That data is paired with HTML, JavaScript and CSS to make up the page and graphics you see. 

Most APIs today are actually built on the exact same HTTP protocol. An API is hosted on a server endpoint, similar to a website, which will be a specific URL. For security, APIs leverage “API Keys”, also referred to as “auth tokens” included in a request payload. These are used validate that a request is coming from a trusted user. 

An API call to an endpoint includes information in the request, including the parameters, auth token, request method, and more. The server logic processes this combination of information to determine which logic to invoke. An example is below.

Good APIs are specific, well-documented, and don’t change often

APIs should be very specific in the technical and business functions they perform. This makes the process more efficient for the server that the API is hosted on, leading to faster response times that benefit both the producer and consumer of the data. APIs should also be well-documented in order for the end-user to understand what function is actually being performed. 

Businesses write API calls to other services into their code. For this to work, is crucial for the producer of the API maintain the same “contracts”, or messaging payloads. One small change in the text required could cause an error and render an entire application useless if it relies on data from the API. 

APIs will only become more important over the next few years

As we process more and more data, the need for flexibility in how we process and manage this data will increase. We have already begun to see some companies emerge that are “API-first”, meaning they prioritize their API development over a user interface and do most of their business through this. 

%d bloggers like this: