Why use webhooks
Webhooks provide a more efficient and responsive way to integrate systems compared to traditional API polling methods.
Webhooks vs API polling
Let's say that you want to notify users when they unlock a reward in Mambo. Here's how the two approaches compare:
Using webhooks:
- User completes an action in Mambo that unlocks a reward
- Mambo immediately sends the reward event data to your webhook endpoint
- Your application processes the event and notifies the user instantly
Using API polling:
- User completes an action in Mambo that unlocks a reward
- Your application repeatedly calls Mambo's API asking "Any new rewards?"
- Eventually, your application discovers the reward and notifies the user
The API polling approach requires constant requests, consumes more resources, creates unnecessary server load, and introduces delays in user notifications.
Benefits of webhooks
- Real-time updates: Events are delivered instantly when they occur
- Resource efficiency: No need for frequent API polling that wastes resources
- Reduced complexity: Your code only needs to handle events when they happen
- Better user experience: Users receive immediate feedback about their actions
- Scalability: Webhooks handle spikes in activity without requiring changes to your polling frequency