Beginner 4 min read

🔌 APIs Explained — How APIs Work

Ever wondered how your weather app knows it's raining outside? Or how a food delivery app shows live restaurant menus?

That's an API doing its job. Let's break it down — the easy way.


🧠 Easy Analogy (Must Read First!)

Think of a restaurant.

You (Customer) → Waiter → Kitchen → Waiter → You (Food!)
  • 🧍 You don't walk into the kitchen yourself
  • 🧑‍🍳 The kitchen doesn't come to your table either
  • 🧑‍💼 The waiter is the middleman who takes your order and brings back food

An API (Application Programming Interface) is the waiter.

It takes your request, delivers it to the system that has the answer, and brings the response back to you — without you needing to know how the kitchen actually works.


📘 What You Will Learn

  • 🔹 What an API actually is (in plain English)
  • 🔹 How a request-response cycle works
  • 🔹 What REST APIs are
  • 🔹 Common HTTP methods (GET, POST, PUT, DELETE)
  • 🔹 What an API endpoint looks like
  • 🔹 Status codes — and what they mean
  • 🔹 Why APIs matter for real-world apps

🔄 How an API Call Actually Works

[Client/App] → sends Request → [API] → talks to → [Server/Database]
                                                      |
[Client/App] ← sends Response ← [API] ← ----------- ↓

Step by step:

  1. Your app (the client) sends a request
  2. The API receives it and passes it to the server
  3. The server processes it (maybe checks a database)
  4. The server sends data back to the API
  5. The API delivers the response to your app

That's it. That's literally how Instagram loads your feed.


🌐 What Is a REST API?

REST is just a set of rules for how APIs should be designed.

Most APIs you'll use today (weather, payments, maps, chatbots) follow REST.

🧠 Easy way to remember: REST APIs treat everything like an address (URL) you can visit to get specific data.

https://api.weather.com/city/mumbai

This URL is called an endpoint — a specific door into the API.


🛠️ Common HTTP Methods

These are the "verbs" — they tell the API what action you want.

Method Action Real-Life Example
GET Read data Viewing a profile
POST Create data Signing up for an account
PUT Update data Editing your profile
DELETE Remove data Deleting a post

📦 What Does an API Request Look Like?

Here's a simple GET request example:

GET https://api.example.com/users/101

Response:
{
  "id": 101,
  "name": "Juned",
  "email": "juned@example.com"
}

You "ask" for user 101 → the API "replies" with their data.


🚦 API Status Codes (Very Important!)

Every API response comes with a status code — think of it as a quick health report.

Code Meaning Simple Explanation
200 OK ✅ Everything worked
201 Created ✅ New data was added
400 Bad Request ❌ You sent something wrong
401 Unauthorized 🔒 You need to log in / send a key
404 Not Found ❓ That endpoint doesn't exist
500 Server Error 🔥 Something broke on their end

🔑 Why Do APIs Need Keys?

Most APIs ask for an API key — think of it as your ID card.

Request → [Your API Key Attached] → API Checks ID → Allows/Denies Access

This helps the API: - Know who's calling - Track usage limits - Block random/unauthorized access


🏗️ Real-World Examples of APIs

  • 🌦️ Weather apps → Weather API
  • 💳 Online payments → Payment Gateway API
  • 🗺️ Maps & directions → Google Maps API
  • 🤖 Chatbots → OpenAI / Telegram Bot API
  • 📦 Order tracking → Shipping Carrier API

Basically — if two apps are "talking" to each other, there's an API involved.


🎯 Final Summary

🔌 API = A messenger between two systems
🍽️ Analogy = Waiter taking your order to the kitchen
🔄 Flow = Request → API → Server → Response
🛠️ Methods = GET, POST, PUT, DELETE
🚦 Status Codes = Tell you if it worked or failed
🔑 API Key = Your ID card for access

APIs are EVERYWHERE — once you understand them,
you start seeing how the entire internet connects! 🌐

📌 Next Tutorial

👉 Up next: GET vs POST Request — What is the Difference and When to Use Each. Now that you know what an API actually is, you'll see exactly how these two methods are used to talk to one.


TechWithJuned · Learn → Execute → Build