Straight Talking Tech: What the heck is an API?

1st December 2020

Another day in tech, another acronym. Today, we are delving into the wonderful world of APIs – Application Programming Interfaces.

For anyone outside of tech, that might just sound like a randomly grouped set of words so here is what an API does in plain English.

An API is a type of messenger service that allows two systems to talk to each other and swap information. But let’s take the tech out a little bit more and look at how this might work in another more familiar situation.

You go to your favourite restaurant. A waiter gives you a menu listing all the dishes the kitchen is serving that day. You make a choice, tell the waiter and they go back to the kitchen and tell the chef what they need to cook. Your meal is prepared and brought to your table by the waiter.

An API acts like the waiter in this scenario – they present you the menu with some options, all messages and requests are then communicated through them to the kitchen and only the waiter is able to access the kitchen.

So to summarise, an API is simply software that enables two applications to communicate and/or swap data with each other.

3 Real-world examples of APIs

Now we have wrapped our head around how they work, let’s take a look at some real-world examples that you are probably already using in your day-to-day life.

  1. Weather apps

Your phone’s operating system will give you a handy feature that lets you check the weather forecast for the next few days or even a nifty symbol displayed on your home screen showing the current conditions and temperature in your location. 

Look closely and you will notice that this information is being provided by The Weather Channel or something similar. The likes of Google and Apple are pretty powerful these days but they aren’t weather experts so they rely on a third party to provide them with this information.

weather app on mobile phone
  1. PayPal

When we purchase something online, we are given various payment options, often including PayPal. If you choose to pay with PayPal, the website you are purchasing from will send a request to PayPal for that amount. PayPal will process the transaction without exposing any of your secure data.

  1. Flight comparison sites

Rather than book direct, some of us may prefer to shop around for the best flight deals and sites like SkyScanner and Kayak have made this easy for us by providing a one-stop shop to compare prices and times.

But how does Skyscanner know when and where Easyjet and Ryanair fly to? It would take a lot of work to stay on top of that information so they use APIs to communicate directly with the suppliers and present you with the information you requested.

Why are APIs so important?

APIs are really powerful on a number of levels.

First of all, they mean you don’t have to develop these systems and software from scratch if someone else has already created a functionality or collected data that you can reuse in your system.

Conversely, when you’re building a system that collects data or does something clever, you can create your own API ‘endpoints’ (the URL you would call) to allow others to access your data.

Recently, Telescopic built an internal tool for the Architects Registration Board which will manage the application processes with various complex rules and regulations. In order to get the applications information into the system, we adjusted the existing application forms and put an API ‘on top’. This exposed the applicant’s information to the system we were building and we could seamlessly receive the data in the application management system.

If there were no APIs, you’d be pretty stuck these days. It would kind of be like living in a pre-internet world, where your computer programmes could not get information from anywhere else in the world.

How does an API work?

Play by the rules

Like anything in the development world though, the value of an API all comes down to knowing how it works.

That’s why it’s essential to have high quality developer documentation. If no one knows how to use your API, no one will use it in the first place!

An example of terrible API documentation is Instagram. Not only is it subject to frequent updates, but they also don’t keep documentation up to date and to a lot of devs (especially more novice) it can be quite hard to decipher.

via GIPHY

As a way to combat this, the developer community came up with certain standards that would make APIs easier to understand. If all APIs work in roughly the same way, documentation needs are greatly reduced – and developers are lazy, so that’s a great thing.

The end game

So, on an API, you’ll usually have endpoints that can:

  • Add new bits of information
  • Get/read information
  • Update existing information
  • Delete information

This is also referred to by another wonderful acronym: CRUD (create, read, update, delete).

The actual response you receive from a request to an API is mostly sent in the so-called – wait for, another acronym – JSON (JavaScript Object Notation) format. Or maybe even XML (eXtensible Markup Language).

This means, when I, as a developer, request some information from an API endpoint (don’t forget this means the URL I’m calling), e.g. (https://mywebsite/api/v3/get-my-info), rather than just returning a string of information, for example:

“Hello, I’m Charlie and I’m 3 years old.”

I can expect to get back something like:

{
	data: “hello”,
	name: “Charly’,
	age: “3”
}


And as a developer, I know exactly what to do with this curly brackets-colons-quotes-comma collection so you don’t have to worry about it.

As with everything on the internet, APIs get built upon too. So sometimes you might use a service that uses an API, that uses an API, that uses an API… it’s all about sharing!

via GIPHY

Developing APIs to match our needs

There are of course then a whole host of things to consider when you use or create an API. 

I mean, you might not want just about anyone to access your highly sensitive payment information so security and authentication (i.e. login) are important. 

You want a proper lock on your front door too. If this is a publicly accessible API, you’ll need to make sure your hosting infrastructure does not collapse once you get thousands of users.

Then there’s speed. You don’t want your user to wait 3 minutes for their payment to complete. 

And, of course, you need to think about the potential amount of information you might be requesting. If you’re requesting weather data from the last 1000 years, you might not want to get everything in one big chunk. That could take an hour to be sent and be 4000GB big.

That’s where ‘pagination’ comes in. You could request only 10 items at a time and then flick through the other ‘pages’ one after the other. There are again various ways of doing this, but it might look a bit like this:

https://mywebsite/api/v3/get-my-info?page=1
https://mywebsite/api/v3/get-my-info?page=2
https://mywebsite/api/v3/get-my-info?page=3

API = greater workflow automation

So to round that all up, APIs are very powerful and, like in real life, with power comes great responsibility.

It allows us to interpret data and see the world from new perspectives. It basically creates a big network of data sharing on the internet.

In your day to day life, it enables you to bring all the systems together into one fluid workflow. For example, on an e-commerce site, it allows you to take an order, send the order information automatically to your accounting system, send the order information to your fulfillment system and then send an email confirmation or push notification to the end user.

And it doesn’t stop there. They can trigger e-tickets to be generated, send newsletters, notify departments, update project management tools or message followers on your social media platforms. The possibilities are endless!

In workflow automation, APIs are your very best friend.

Back to News