noted.do
The Tech Guy

An API Is Just a Way for Programs to Ask Each Other for Things

API stands for application programming interface, which is a phrase that explains nothing. Here's the plain version: it's a set of rules for how one program can ask another program to do something or hand over some information.

You use them all day without seeing them. The weather app on your phone doesn't own a weather station. It asks a weather service's API for the forecast at your location and draws the answer nicely. When a site has a "Sign in with Google" button, it's talking to Google's API. When a store shows you live shipping rates, it's asking the shipping carrier's API. Your banking app is mostly a pretty face on top of your bank's API.

The useful mental picture is a service counter. There's a fixed list of things you're allowed to ask for, a specific way you have to ask, and a predictable format for what you get back. You don't get to wander into the back room and rummage around. That's the point. The company running the API decides exactly what's exposed and keeps everything else private.

Most APIs on the web work over the same HTTP your browser uses. A program sends a request to a specific address, called an endpoint, and gets data back, usually as JSON. A request might look like this:

curl https://api.example.com/v1/weather?city=Boston \
  -H "Authorization: Bearer $WEATHER_API_KEY"

And the answer comes back as something like:

{
  "city": "Boston",
  "temperature": 12,
  "conditions": "cloudy"
}

That's not meant for humans to look at. It's meant for the app to read, pull out the temperature, and put it on screen with a little cloud icon.

That Authorization line is an API key. Most APIs want to know who's asking, both to limit how much you can request and, for paid ones, to bill you. Treat a key like a password. It shouldn't go in public code or a screenshot, which is why the example pulls it from an environment variable instead of pasting it in.

Why should a non-programmer care? Mostly because APIs are how your apps and services connect. When people talk about automation tools like Zapier, IFTTT or Apple Shortcuts linking one service to another, it's APIs underneath. It's also why a service shutting down or restricting its API can suddenly break a bunch of third-party apps you liked. They were all asking the same counter, and the counter closed.

Comments

Be kind. See the rules.