What is an API?

An API is a way for one app or website to ask another app or website for information.

Think of it like this

An API is like a waiter in a restaurant. You don't walk into the kitchen and cook - you choose from the menu, tell the waiter, and the waiter brings back your food. The menu is the list of things you're allowed to ask for, and the kitchen can completely change how it works without you noticing, as long as the same dish arrives.

What's happening

Diagram showing an app sending a request to an API and receiving data back

Summary

An API is a published menu of requests one piece of software can make to another, so apps can use each other's data and features without ever seeing each other's code.

A Closer Look

API stands for Application Programming Interface. In practice it's a list of requests a service agrees to answer, and the exact format the answers will come back in. A weather app on your phone doesn't own any weather satellites - it sends a request to a weather service's API, something like "current conditions for London", and gets back neat, structured data it can display. The same thing happens when a site lets you "Log in with Google" or shows an embedded map.

On the web, most APIs work over the same HTTP requests your browser uses to load pages, and the answers usually come back as JSON - plain text organised into labelled values like "temperature": 14. Because the API is a fixed agreement, the company behind it can rebuild everything behind the scenes without breaking the apps that rely on it. Many APIs also require a key - a long, password-like code that identifies which app is asking, so the provider can limit usage or charge for it.

Common Misconceptions

  • An API isn't a physical thing or a programming language - it's just an agreed-upon way for two systems to communicate.
  • APIs aren't only for developers - every time you log in with Google or see a map embedded in a site, you're using one.
  • "API" doesn't always mean a web API - there are APIs built into operating systems, apps, and hardware too.

How it connects

APIs are how the modern web shares data:

Try it yourself

Open a new tab and go to api.github.com/users/github - you'll see raw JSON data returned directly from GitHub's API, exactly what apps receive when they make a request.