What Is An API?

Wondering what an API is? API stands for Application Programming Interface. It is a piece of code that lets two programs talk to each other. A way to pass information and data between two programs. Directly. Don’t worry, they’re not as complicated as they sound. An API is quite simple to use. You’re really only sending a small piece of code to a server to get a response.

What’s the point of an API?

There are many reasons to use an API. But ultimately it’s to quickly send useful information between two programs. For example, imagine you’re developing a website. You want the website’s background to change based on the current weather. How do you do it? You could set up a camera to look out the window, add some complicated machine learning to figure out whether it’s raining or not, and then change the background based on the result. Alternatively, you could create a program that scraped your local news and grab the weather from the webpage.

Both of those options are rather inefficient. Instead, you can just go to OpenWeather and use their API to ask them what the weather is. All through one line of code. Much easier. This is a rather basic example. In the real world, you’re likely sending data from your application to a third party, they process it on their end, and then you retrieve the answer. But the principle is the same. APIs take a complicated task and turn it into just a few lines of code.

How do they work?

An API can only send and retrieve data or functions that have been programmed in. The creator of the API will show which commands you’ll need to send to retrieve or send data to them. Often, you’ll also need an authentication code. This is basically your login information and proves that the command you’re sending is coming from you. To interact with an API, it’s very similar to just typing in a web address. You’re just adding a little code to the URL, so it looks like this:
api.acme.com/?get=bunny_season=a[authcode]

Once you send that, you’ll get a response. The format for the data you get back will depend on the API, but is often something like XML or JSON. And exactly how you make this request inside your code will depend on the programming language you’re using.

What can an API do?

There are typically only four actions you can take:

  • Get. Ask for data from the server.
  • Post. Send data to the server and add it.
  • Put. Change data.
  • Delete. Deletes data.

Using a combination of these actions, you can do pretty much anything you like with an API. It all depends on what the developer has set the API up to do.

How might you use an API?

You might use an API in three different ways:

An internal system

Let’s imagine you’re a global cinema company. You have a website with a booking system and a lot of cinemas, each with their own screens and seats. How do you know how many seats are available?

You might have a giant database that syncs everything, but that’s quite impractical. Instead, you could have an API with each cinema. Your website then pings the cinema, checks how many seats are available (and which ones they are) for the movie and then it sends back the response. Your website can do all the heavy lifting of showing it to the user in a nice neat way. And because it’s a simple request, it doesn’t clog up the bandwidth for the cinema itself. That way, the user gets the same experience for every cinema. But also, you can easily just update the website if you have a design change.

Link with a partner

This time, let’s imagine we’re a data analytics company. You might have a tool that collects data from a museum. It takes data from the audio-tour device you give to people, records their path and then figures out what people enjoy. Great. But what if the museum wants to see that data in a better way? You might not have the skills in-house to create the visualization. Instead, you might partner up with another company and use their software. An API is great for this. You can plug your two pieces of software into each other and have them work as a single unit. It’s not public data, so they use an authentication code to prove they can use the data.

Open up to the public

Lastly, you might just want to make your data public. OpenWeather, for example, wants anybody to be able to use its data. An API lets you give this data to people, without them getting access to the raw database.

Learn to use APIs and more

If you’re interested in learning to program your own websites and use APIs to give them more functionality, you can check out our bootcamp. You’ll get hands-on experience and learn to code three full stacks in a few months. Check it out.

dojo guide

Looking for a Career in Web Development?

Read our quick-start guide to becoming a Developer

  • Includes exclusive insight from a seasoned Web Developer
  • Uncovers the top career misconceptions holding you back
  • Highlights the must-have qualities all employers require
  • 89,615 downloads to date

Leave a Reply

Your email address will not be published. Required fields are marked *