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
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.
A good everyday example is a travel comparison site. When you search for flights from Manchester to Rome, the site doesn't hold every airline's timetable itself. Instead, it sends the same question to many airlines and booking systems through their APIs, collects the answers within seconds, and lays them out side by side. When you pay, the shop typically passes your card details to a specialist payment company through another API, so the shop itself never needs to store them. This is why so much modern software is put together like building blocks: rather than creating everything from scratch, developers connect existing services, each doing the one job it's best at.
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.
Frequently asked questions
Are APIs safe?
An API is only as safe as the way it's built and run. Well-designed APIs check who is asking, using keys or logins, only hand over the data each app is allowed to see, and send everything over encrypted HTTPS connections. Problems arise when an API is poorly protected and gives out more information than it should, which is behind some of the data leaks that make the news.
What is an API key, and should I keep it secret?
An API key is a long code that identifies the app or person making requests, a bit like a membership card. In most cases it should be kept secret: anyone who copies it can make requests in your name, which could use up your allowance, run up charges on a paid service, or expose your data. Never post one publicly, for example in code you share online.
Do I need to know how to code to use an API?
To build something with an API directly, some basic coding helps, because requests are usually sent from a program. But there are also no-code tools that link services together through their APIs behind the scenes - for example, automatically saving email attachments to cloud storage - so you can benefit without writing any code. And as an ordinary user, you rely on APIs every day without doing anything at all.
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.