Tutelage

Lessons › coding and computer science · taught by Leo

APIs explained: how apps talk to each other

Learn how APIs pass requests and responses between apps and servers, and why they act like a rulebook for software communication.

Learn this with Leo, freeA voiced lesson with a live whiteboard, quizzes and a tutor you can call, at tutelage.app

What an API does

Think of an API like a waiter in a restaurant. You do not go into the kitchen yourself.

You ask the waiter for something, and the waiter carries the message to the kitchen.

That is what an API does between two pieces of software.

request → response

Big idea: a contract

An API is a contract for how programs talk.

It tells you what to send, what you get back, and what shape the data should have.

It helps two different systems work together without knowing each other's code.

Predict the API role

If your app asks a weather service for today’s forecast, what is the API doing?

  1. Passing the request and response between them
  2. Turning rain into sunshine
  3. Deleting the app’s data
Show answer

Passing the request and response between them: Yes. The API is the messenger and rulebook for the exchange.

Request then response

First the client sends a request. The client is the app asking for something.

Then the API forwards it to the server and checks the format.

Finally the server sends back a response, and the app uses the data.

request

A simple API call

Here is a tiny example. The app asks for weather in Boston.

A successful response might start with 200 OK. That means the request worked.

Then the data comes back, often in JSON, which is a neat text format for objects.

200 OK

Quick check: which part next?

After sending a GET request, what is the most likely next thing to happen?

  1. The server sends back a response
  2. The API erases the request
  3. The app becomes the server
Show answer

The server sends back a response: Right. The next step is the response coming back.

Why APIs are useful

APIs save time. You can use a maps API instead of building maps from scratch.

They also separate jobs. One team can build the app, and another can build the service.

That makes software easier to reuse, update, and connect.

API terms to know

Request means what you send out. Response means what comes back.

You do not need to memorize every term at once. Just remember the direction.

request ↔ response

Common mistake to avoid

A common mistake is thinking the API is the whole app.

It is not. The API is the doorway, not the whole building.

The real work happens inside the client and server.

Your turn: what is the API?

Which description best fits an API?

  1. A rulebook and messenger between programs
  2. A database that stores all files
  3. A screen layout for buttons
Show answer

A rulebook and messenger between programs: Good. That is the best match: a rulebook and messenger between programs.

API checklist

Here is the whole flow. Send a request.

The API routes it, the server answers, and your app uses the response.

If you remember that flow, you understand the core idea of APIs.

Learn this with Leo, freeA voiced lesson with a live whiteboard, quizzes and a tutor you can call, at tutelage.app