API & Webhooks Guide
1. API kya hota hai?
API ka full form hai Application Programming Interface. API ek bridge hota hai do systems ke beech
jo unko baat karne aur data exchange karne deta hai.
Example 1 (Real Life): Restaurant me waiter customer aur kitchen ke beech bridge ka kaam karta
hai. API bhi waise hi kaam karti hai.
Example 2 (Technology): Weather app weather ka data API se fetch karti hai. API server se data
lekar app ko provide karti hai.
2. Webhook kya hota hai?
Webhook ek real-time notification system hai jo server se data push karta hai jab koi specific event
hota hai. Yani aapko request bhejne ki zarurat nahi, server automatically aapko inform karega.
Example 1 (WhatsApp Webhook): Jab WhatsApp pe naya message aata hai, WhatsApp aapke
webhook URL pe automatically data bhej deta hai.
Example 2 (Payment Webhook): Jab customer payment complete karta hai, webhook trigger hota
hai, n8n workflow start hota hai, invoice generate hoti hai aur confirmation email send hoti hai.
3. API vs Webhook (Difference)
• API → Client request karta hai, server response deta hai
• Webhook → Server automatically data push karta hai jab event hota hai
• API → On-demand data fetching
• Webhook → Real-time notifications
• Example: API → Weather data fetch karna, Webhook → WhatsApp new message alert
4. n8n me API & Webhooks ka use
API Example:
• Workflow: Get data from OpenAI GPT API
• Trigger Node → Manually start hota hai
• HTTP Request Node → GPT API ko call karta hai
• Action Node → Result WhatsApp pe send hota hai
Webhook Example:
• Workflow: WhatsApp Auto Reply
• Webhook Node → Jab WhatsApp pe new message aaye
• AI Node → Message GPT ko send hota hai
• Action Node → GPT ka reply WhatsApp pe automatically send hota hai