<aside> 💡

Your code works with local files. After this section, it talks to the internet.

</aside>


1. What is an API

Your app needs data it doesn't own. Weather, maps, payments, user posts. That data lives on someone else's server. The API is the door between your app and that server.

🧑‍💻 The Restaurant

Restaurant Code
You (customer) Your App
The waiter The API
The kitchen The Server
The menu The Documentation
Your order The Request
The food The Response

You never enter the kitchen. Your app never touches the database. The API carries everything back and forth.

The Pattern

image.png

Every API call follows this shape:

📌 Summary

Term Meaning
API The door between your app and a server
Request What you send (URL + method)
Response What comes back (status code + data)
Server Someone else's computer with the data you need

2. JSON

The format your app and the server agree on. Keys and values.

🧑‍💻 Example

{
    "id": 1,
    "name": "Bariis iyo Hilib",
    "category": "main",
    "price": 12.99
}

Rules:

  1. Keys are always strings in double quotes
  2. Values can be: strings, numbers, booleans, arrays, objects