ExplainlyUnderstand anything.
Technology

What Is an API?

An API is a menu one program offers another: here is what you can ask me for, and here is exactly how to ask. You use dozens of them every day without ever seeing one.

What Is an API?

An API is a menu that one piece of software offers to another: here is what you can ask me for, and here is exactly how to ask. Nothing more mysterious than that. The letters stand for Application Programming Interface, which is a mouthful for a simple idea.

When you check the weather on your phone, your weather app does not own a single thermometer. It asks a weather service, in a precise format that service published in advance, and gets back a tidy answer. That agreed format is the API.

The restaurant version

Imagine sitting in a restaurant. You do not walk into the kitchen, find the chef, and describe what you want. You read a menu, which lists exactly what is available and what each thing is called. You give your order to a waiter. The waiter brings back food.

The menu is the API. It tells you what you may ask for and what you will get. The kitchen is the other program, and you never see inside it. That is the point: you do not need to know how the kitchen works to eat there, and the kitchen can be completely rebuilt without changing your order.

What an actual request looks like

Most APIs on the web run over the same protocol your browser uses, so a request travels across the internet exactly like a page request does. A program sends a request to an address, and a response comes back.

A request to a weather service might mean, in effect, "give me the current conditions for London." The answer arrives as structured data rather than a web page, usually in a format called JSON, which looks roughly like this:

{
  "city": "London",
  "temperature_c": 14,
  "condition": "light rain"
}

That is deliberately boring. It is meant to be read by another program, not by you, so it strips out everything a human page would carry: layout, colour, fonts, adverts. A program can pull the number 14 out of it in one line of code.

Why APIs exist at all

Three reasons, and they compound.

  • Nobody has to rebuild everything. A shop does not write its own card-payment system. It calls a payment company's API and gets a yes or a no.
  • The two sides can change independently. As long as the menu stays the same, the kitchen can be renovated. This is the whole reason large systems can be maintained at all.
  • Access can be controlled and measured. An API is a doorway, so it can check who is knocking, limit how often they knock, and charge for it.

That second point is the deep one. An API is a promise about the interface, not about the implementation. What sits behind it can be a hand-written algorithm, a database lookup, or a machine learning model, and the caller cannot tell and does not need to.

The key you need to get in

Most useful APIs do not answer anonymous strangers. You register, and the service issues an API key: a long string of characters your program sends with every request. It identifies you, lets the service count your usage, and lets them cut you off if you misbehave.

This is why an API key should be treated like a password. Anyone holding it can make requests that are billed to you and attributed to you.

Metering is also the business model. Paid APIs charge per request, which is a much cleaner arrangement than the indirect one behind most consumer software, where the product is free and the revenue comes from somewhere else.

Where you meet APIs without noticing

Signing into a new site with your Google account is an API call. So is a map embedded in a restaurant's contact page, a delivery tracker, the exchange rate shown at checkout, and every "share this" button. A modern app is mostly a well-arranged pile of other people's APIs with some original work in the middle.

Every chatbot and writing assistant is one too. A large language model is almost never running on your device; the app sends your text to a model somewhere else through an API and displays what comes back.

This is also why an outage at a large infrastructure provider can seem to break half the internet at once. Thousands of independent sites were quietly asking the same service the same question, and it stopped answering.

The short answer

An API is a published agreement about what one program will do when another program asks. The asking program never needs to know how the work gets done, only how to ask and what it will get back.

If you take one thing from this: an API is not a technology, it is a contract. The technology underneath can be anything.

Keep going

Understand something new every week.

One email. The explainers worth your time, and nothing else.

No spam. Unsubscribe in one click.