What Is an API? Sync and Async Explained with a Restaurant

What Is an API? Sync and Async Explained with a Restaurant

How software talks, explained through ordering at a restaurant

An API is how software talks to software in an agreed way. A restaurant analogy, sync vs. async, and why async hands you a ticket first.

By · Fred KimUpdated
APIMade simpleTrail StudioAsynchronous

You've probably heard the phrase "API integration" at some point. An API is how software talks to other software in an agreed way. But when someone actually asks "What's an API?", it's hard to explain. It isn't hard, really. If you've ever ordered food at a restaurant, you already know how it works.

Think of a restaurant

When you walk into a restaurant, you don't go into the kitchen and cook. Instead, you do this.

The API explained through a restaurant order: the customer orders from the server using the menu, the server passes it to the kitchen and brings back the food

RestaurantSoftware conceptRole
KitchenThe service's internalsWhere the work actually happens. The customer doesn't need to know about it
MenuThe agreed request formatA list that defines "here's what you can order"
ServerAPITakes the order, passes it to the kitchen, and brings back the finished result

The customer (the app we use) doesn't need to know the kitchen (the service's internals). Just order from the server (the API) following the menu (the agreed format), and you get what you want. An API is "a server that hides the internals and lets you exchange things only through an agreed window."

We already use APIs every day

It sounds like grand technology, but you actually use it dozens of times a day.

  • When you open a weather app, the app orders from the weather service's API, "Tell me today's weather in Seoul," and brings back the result.
  • When you tap directions in a map app, it asks the map service's API for a route.
  • When you enter card details to pay, the app asks the payment company's API, "Charge this amount."

It's not just weather, maps, and payments. Sending a message, playing music, checking a delivery's status: behind almost every button we press stands a server.

The APIs we use in a day: weather, map directions, payments, messaging, music, and delivery apps all talk to services through a server (API)

Behind every button on the screen, servers (APIs) are busily passing orders back and forth. Behind every button click, an API is at work.

When you make card news in Trail Studio

The same thing happens in our service. When you press the "Create card news" button in Trail Studio, a conversation like this takes place out of sight.

The four steps when you make card news in Trail Studio: request, generation start, progress check, and receiving the finished result

  1. Request: You order, "Make a 6-card card news set on this topic."
  2. Generation start: Trail Studio accepts the order and immediately returns a ticket (job number). Making card news takes a while, so instead of waiting for the food to come out, you get a number first [1].
  3. Progress check: Every so often you ask, "How far along is that job?" It answers, "Still making it" or "All done."
  4. Receive the result: When it's done, you get the finished output.

The key to this flow is the ticket in step 2. Here's what it looks like.

The asynchronous approach of getting a ticket first and the result later: when you order, you first get a job number (ticket), and a little later you use that number to fetch the finished result

It's exactly like a restaurant where cooking takes time: you get a buzzer, wait at your table, and pick up your food when it buzzes.

This approach, where a request doesn't finish right away but you get a ticket and fetch the result later, is called asynchronous (running separately). It's a common way to handle heavy work smoothly.

Coming up next

So far, this has been about a person pressing a button, checking progress, and receiving the result. But what if AI placed the order instead of a person?

You'd just say, "Make card news on this topic," and an AI assistant would place the order, check progress, and bring you the link to the finished result. The agreement that makes this possible is MCP. We'll pick it up in the next post.

> You can try Trail Studio right now. Content generation runs on credits.

For related reading, see What is MCP (Model Context Protocol)? Connecting tools to your AI assistant, What is first-party data? How to use it in marketing after third-party cookies, and Defending against RAG hallucinations: classify the types and know the limits of automated verification.

Frequently asked questions

Can't you build an app without an API?

You can, but you'd have to deal with each service's internals directly every time, which is inefficient. An API hides the internals and lets you exchange things only through an agreed window, so different services can work together safely and quickly.

Why use the asynchronous (ticket) approach?

If you try to finish a time-consuming task like card news generation in the same moment as the request, the user has to keep waiting. Hand out a ticket (job number) first and let them fetch the result later, and even heavy work runs smoothly.

Does Trail Studio work through an API too?

Yes. When you press the "Create card news" button, four steps travel through the API: request, generation start (ticket issued), progress check, and receiving the finished result.

References

  1. [1]MDN Web Docs, "202 Accepted" HTTP status code

Summary

  • An API is how software talks to other software in an agreed way. It plays the role of a restaurant server.
  • Weather, maps, payments, messaging, music, delivery: there's an API behind almost every button we press.
  • When you make card news in Trail Studio, the API carries four steps: request, generation start (ticket issued), progress check, and receiving the finished result.
  • Time-consuming tasks use the asynchronous approach: get a ticket first and fetch the result later.

Why TRAIL Labs works this way

How a researcher-founder grounds measurement and recommendations, and how the three products relate to the company, is laid out on the about page, and how we work day to day is written up separately.

More posts

Keep reading on this topic

This post is part of the TRAIL Labs category, which collects all 19 posts on the topic. See all posts in TRAIL Labs