Module 0How it all works · Free lesson
What an API is
- 7 min read
- 7 sections
- 5 exercises
The word API turns up everywhere. You will see it on tool websites, in job adverts and in any conversation about AI. In this lesson you will understand what it is with a restaurant example. Then you will see three real cases you use almost every day.
What an API is
API stands for Application Programming Interface. The name sounds scary, but the idea is simple. An API is an agreed way for two programs to talk to each other. One program asks for something. The other gives it.
The waiter in the restaurant
Think of a restaurant. You are the customer. You do not walk into the kitchen. You give your order to the waiter. The waiter takes it to the kitchen. Then brings you the dish.
In this comparison, the waiter is the API. The kitchen is the other program. The dish is the response.
You do not need to know how to cook. The kitchen does not need to come out into the dining room. The waiter acts as a bridge between the two.
Also, you can only order what is on the menu. An API has its menu too. It is the list of things you can ask it for and how to ask. It is called the documentation.
Request and response
What a program asks for is called a request. What it receives is called a response. The request says what you want and with what data. The response brings the result.
Request
Give me tomorrow's weather for Seville
Response
{ "city": "Seville", "max": 27, "sky": "clear" }
The response above is in JSON. It is a text format that many APIs use to send data. Each piece of data has a name and a value. It reads quite easily even if you cannot code.
Three real examples
The weather on your phone
The weather app on your phone does not have weather stations of its own. When you open it, it sends a request to the API of a weather service. It tells it where you are. The API sends back the temperature and the forecast. The app just takes care of showing it to you nicely.
Paying by card on a website
This way the shop does not have to build its own payment system. And it does not have to store your card details either.
Signing in with Google
Many websites have a button that says "Continue with Google". When you press it, the website asks Google through its API who you are. Google asks you for permission. If you accept, it confirms your name and email to the website. The website never sees your Google password.
The API key
Many APIs ask for an API key. It is a long code that identifies who is making the request. It is used to control who gets in. It is also used to charge according to use. For example, the ChatGPT or Claude APIs charge for each request you make.
Why it matters to you
AI tools have an API too. Many companies connect ChatGPT or Claude to their own programs through it. You will see this in modules 3 and 4. From now on, when someone says "that connects through an API", you will know what they mean.
Key words
- API: an agreed way for two programs to ask each other for things and reply.
- request: what one program asks of another through an API.
- response: what the API returns after a request.
- documentation: the "menu" of an API, with what you can ask it and how.
- JSON: a text format with names and values that many APIs use to send data.
- API key: a secret code that identifies who is using an API.