Lesson 4.3 – Understanding APIs and Webhooks (Basic Concepts)
1. What is an API?
API stands for Application Programming Interface.
It’s like a menu at a restaurant — it tells you what you can order (functions) and how to ask for it (commands).
-
Purpose: Allows different software applications to talk to each other.
-
Example: A weather app uses an API to fetch live data from a weather service.
Key Points:
-
APIs are request–response based (one app asks, the other replies).
-
They often require an API key for authentication.
2. How APIs Work (Simple Flow)
-
Your app sends a request to another app’s API.
-
The API processes the request.
-
The API sends back a response (data).
Example:
-
Request: “What’s the temperature in Delhi?”
-
Response: “32°C, sunny.”
3. What is a Webhook?
A Webhook is like an instant notification system.
-
Instead of asking repeatedly for updates, you get notified the moment something happens.
-
Works on an event → action basis.
Example:
-
When a new payment is made in Stripe, a webhook sends the payment details instantly to your app.
4. API vs Webhook – Quick Comparison
| Feature | API | Webhook |
|---|---|---|
| Initiator | You request data | System sends data automatically |
| Best For | On-demand data fetching | Real-time updates |
| Communication | Request → Response | Event → Push Notification |
| Example | “Get latest orders” | “Order received” alert |
5. Why They Matter for Automation
-
APIs let you connect to almost any service, even if your automation tool doesn’t have a native integration.
-
Webhooks make your automation instant instead of waiting for periodic checks.
6. Real-World Examples
-
API:
-
Pull tweets from Twitter into a spreadsheet.
-
Get currency exchange rates for an e-commerce app.
-
-
Webhook:
-
Notify your CRM when a new lead fills out a form.
-
Send a Slack alert when someone signs up on your website.
-
7. Activity
💡 Exercise:
Think of an online service you use (e.g., Gmail, Shopify, YouTube).
-
Write 1 example of API use.
-
Write 1 example of a webhook use.
📝 Practice Task: Fill in the Blanks
| Scenario | API or Webhook? | Reason |
|---|---|---|
| A stock trading app sends you the price only when it changes | ||
| You click “Check Weather” in an app to get the current forecast | ||
| Your online store gets instant alerts when a payment is successful |
