The Role of Webhooks in the API World
The main advantage of the webhooks pattern is that your application doesn’t have to make periodic calls to APIs while it’s waiting for changes. Below author Guy Levin makes a strong case for reasons to use the pattern.
Join the DZone community and get the full member experience.Join For Free
what is a webhook?
the main advantage of the webhooks pattern is that your application doesn’t have to make periodic calls to apis while it’s waiting for changes. instead, apis will call your application on a specific endpoint informing that something interesting has happened. what’s missing is a way to programmatically tell apis that you’re interested in receiving calls and registering endpoints.
here’s a common example: you go to github . there’s a textbox for their code post webhook. you drop in a url. now when you post your code to github, github will http post to your chosen url with details about the code post. there is no simpler way to allow open-ended integration with arbitrary web services.
tiny but powerful!
this tiny interface is used in obvious ways: bug tracking integration, sms messaging, irc, and twitter.
the same tiny interface is also used in non-obvious ways, like run code run which offers to build and run your project’s tests for you. all by just plugging a runcoderun.com url into github.
webhooks today offer a lot of value as an instant notification mechanism. have events your users care about? give them a webhook for those events and you’ve given them the power and flexibility to integrate that event stream into their lives.
for all of that power, webhooks are impressively simple to implement.
back to the future?
while there’s a lot of value in webhooks today, it’s the future that really interests me. webhooks are composable. you’ll point a webhook at a site that will call other webhooks. it might process the data, record it, fork it off to multiple webhooks or something stranger still. yahoo pipes tried to do this, but ultimately you were limited to what yahoo pipes was designed to do. webhooks can be integrated and implemented everywhere. they piggyback the fundamental decentralized nature of the web.
it’s important that we get to this level of customization for the masses. it’s also important for adoption that we use the web’s native verbs. we understand http on a fundamental level. it’s simple, scales, and makes sense.
a webhook (also called a web callback or http push api) is a way for an app to provide other applications with real-time information. a webhook delivers data to other applications as it happens, meaning you get data immediately. it is very important to do webhook testing , the testing is very simple and is very much like testing api calls .
webhooks are going to reshape the internet, they look like the next step in the evolution of communication on the internet and nothing will be left untouched. many sites like github, mailchimp, and others already support webhooks and the popularity of the pattern is only increasing.
Published at DZone with permission of Guy Levin, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.