Timothy Fitz

What webhooks are and why you should care

Posted in Uncategorized by timothyfitz on February 9, 2009

 Webhooks are user-defined HTTP callbacks. 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. 

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 life. 

For all of that power, webhooks are impressively simple to implement. It’s a one liner in almost every language.

urllib.urlopen(user.webhook.url)

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. 

I imagine a future where twitter feed updates instantly call a webhook. I’ve pointed that webhook at a service that does bayesian filtering. The filtering has been set up to determine if the tweet looks time-sensitive “Anyone interested in getting dinner tonight?” vs time-insensitive “Webhooks are cool.” Time sensitive posts call another webhook, this time set to sms my phone. Note that nowhere in this future am I writing any code. I don’t have to.

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. 

You should care because webhooks will be ubiquitous. You should care because they’re going to reshape the internet. You should care because webhooks are the next step in the evolution of communication on the internet and nothing will be left untouched.

36 Responses

Subscribe to comments with RSS.

  1. YHVH said, on February 9, 2009 at 2:01 am

    I’m looking for the “notify me of follow-up comments via web hook”, this is as dissapointing as last night, with your mother.

  2. Jesper Noehr said, on February 9, 2009 at 2:10 am

    http://webhooks.pbwiki.com/

  3. Pooly said, on February 9, 2009 at 5:11 am

    So it’s like user-specified XML-RPC…

  4. JohnW said, on February 9, 2009 at 6:22 am

    Sounds like an implementation of database triggers for the web world. Neat.

  5. Matt Wiseley said, on February 9, 2009 at 8:58 am

    Cool. Never used github, but that’s a great idea. Thanks.

  6. timothyfitz said, on February 9, 2009 at 9:37 am

    YHVH: If or when I eventually move off of wordpress.com (note that I started this blog three days ago) then I’ll probably add webhooks to it.

    JohnW: Yeah, that’s a good analogy. I didn’t talk about the bi-directional nature, on Devjavu (SVN/Trac as a service) there’s a pre-commit webhook that lets you cancel an svn hook with a message (like “Sorry, we don’t allow hard tabs in commits”) and in that way they’re even more like database triggers.

  7. pete1thomas said, on February 9, 2009 at 9:54 am

    Unfuddle supports this too: http://www.unfuddle.com/blog/2008/5/18/git-hosting-and-repository-improvements

    Not directly affiliated with them, just a satisfied customer. -pete

  8. Eric Larson said, on February 9, 2009 at 10:24 am

    Uche Ogbuji in fact thought of a very similar idea and in fact called it Web Triggers.

    http://notes.4suite.org/Bright_Content%3ADesign%3AWeb_Triggers

  9. Ivan said, on February 9, 2009 at 10:45 am

    old news for any web developer who has ever coded before ever. the new part is the catchy name :)

    long live webhooks!

  10. timothyfitz said, on February 9, 2009 at 11:10 am

    Ivan: Respectfully, I disagree. There are old examples of webhooks, like Paypal’s Instant Payment Notification; however, there are hardly any non-developer webhooks. This is about bringing the power of instant notification, integration and composability to the end-users, not just programmers.

  11. Donovan Preston said, on February 9, 2009 at 12:28 pm

    Webhooks are cool.

  12. ellaella said, on February 9, 2009 at 12:47 pm

    I just started using Chris Pearson’s premium theme, Thesis, a few days ago on my self-hosted blog. It uses hooks extensively and so far, I like doing things that way. Unhook, hook. Easy.

  13. Jessy said, on February 9, 2009 at 1:44 pm

    i think it’s a great idea but what you describe still strikes me as too low level for the average non-technical user. composability is huge. great term too :) . but what are your thoughts on creating an interface (and/or the literacy i suppose) that an average, busy user (think: a teacher; a hill staffer; a non tech-based small business…) will intuitively know HOW to compose? the example of inserting a url into a text box still requires the user understand in a low level way the notion of composability, and be familiar with what is out there to compose WITH. perhaps it’s building various options into the right hand click menu of your browser:

    right click –> send to service…

    which pulls up a selection of categories and choices in those categories. one mght be ‘notify’ (a more sophisticated middleware solution); another might be ‘publish’ with a list of blogs you have registered… i’m sure there are tons more.

    your AI service example strikes me as falling in the middleware category. most users dont think about bayesian filters, they think in terms of ’service = notify’. ‘notify’ would bring up a dialogue box where the user can select the threshold of timeliness they’re interested in.

    the middleware is where the fun is for the developers :) , and where really cool innovative evolutions of what the web can DO come in. but i think the user experience needs to be abstracted away from that.

    dunno, thoughts?

  14. Jeff Lindsay said, on February 9, 2009 at 2:36 pm

    Jessy, I agree. I’ve been playing with a lot of prototypes on making the user experience better, one similar to what you’re describing. However, I don’t believe it’s that important of a problem to solve now. But I appreciate more people thinking about it. As the value of web hooks becomes obvious from advanced users/early adopters using them, they will slowly become more usable for regular users. It’s just sort of inevitable for useful technology to evolve, at the very least, usable enough.

  15. Simon Willison said, on February 9, 2009 at 3:20 pm

    Disagree that webhooks are easy to implement – your one-liner will leave you open to abuse, where malicious users input the URL to a deliberately slow loading page. This will quickly tie up your web serving processes.

    Scaling webhooks properly requires offline processing of some sort, probably using a message queue. I’d be interested to know how GitHub handles this problem.

    • Yuvamani said, on August 11, 2009 at 12:05 am

      Good point. But that is why there are timeouts right ?

      The interesting challenge then is the fact that the callee may not be up all the time. And distinguishing between a genuine callee availability issue and a malicious callee becomes impossible to the caller.

      But there is a simple “good enough” solution for that too. Just put the callee behind a highly available Amazon SQS system.

      The caller then just implements a timeout based callback without a retry.

  16. Simon Willison said, on February 9, 2009 at 3:23 pm

    From your comment on Reddit I can see you’ve already thought about this problem. I’d like to see your memcache protocol compliant webhook forwarder, sounds like a neat solution.

  17. Peter Cooper said, on February 10, 2009 at 7:01 am

    BTW, Trackback is an example of a user-land webhook of sorts..

    Simon Willison: If you look at the github-services project on github, I think you can find out. I seem to recall this code was open sourced on there.

  18. Tom Preston-Werner said, on February 10, 2009 at 10:02 am

    At GitHub our webhooks are run as part of the post-receive queued job on non-web slices. The code is quite simple, in essence wrapping up some JSON and posting to the webhook URL. Here are the details if you’re interested in a reference:

    http://github.com/guides/post-receive-hooks

    We also have a bunch of pre-built services that users can activate to send their commit info to places like Twitter, Campfire, IRC, etc. All they have to do is enter a few connection details into a form. This code is open source:

    http://github.com/pjhyett/github-services

    Many of these services have been contributed by our users, so that they can have easy integration with their favorite app!

  19. Dustin Beltramo said, on February 10, 2009 at 10:24 am

    Just trying to wrap my head around this — so, are webhooks kind of like the pipe | on a Unix command line? A way to connect the output of one process/service to another, and chain things together?

  20. Pete Warden said, on February 10, 2009 at 12:24 pm

    “I imagine a future where twitter feed updates instantly call a webhook”
    I’m already using a free service that does just this, Gnip. See http://gnipcentral.com/ for a whole bunch of services that you can to have a webhook called whenever they update.

    The only downside is that Twitter are being stingy with their data, and only allow a link to the status update to be sent, which you then have to fetch from their servers to get the full message.

    • Toby Champion said, on March 24, 2009 at 4:53 pm

      Maybe Twitter don’t send the full message because it can be edited (at least for a while) by the user, and you might miss out on this.

  21. Jud Valeski said, on February 10, 2009 at 2:27 pm

    Nice post. Web Hooks are an ideal way to leverage the extremely vetted HTTP backbone for the traditional “event callback” pattern. Long overdue. Gnip’s filter “postURL” callback setting leverages the pattern heavily. Would love feedback on it.

  22. timothyfitz said, on February 10, 2009 at 6:02 pm

    Dustin Beltramo: Yeah, that’s a decent analogy. My twitter example would kinda be like: “twitter timothyfitz | bayes “time critical” | sms”. There are obvious differences because we’ve got a stream of requests instead of a file descriptor, but the analogy for what you can do to leverage them is vaild (and in fact Webhook evangelist Jeff Lindsay has used that analogy many times before).

  23. timothyfitz said, on February 10, 2009 at 6:06 pm

    Pete Warden/Jud Valeski: I haven’t actually used Gnip yet, but Jeff Lindsay and I have talked about it quite a bit. Just digging around on the website and reading the API docs, the very first thing that jumps out is that this still isn’t *quite* webhooks. It’s still targeting developers and it’s not just as easy as dropping a url into a textbox. It would be cool to see a single server site for whatever your largest use case is. Hypothetically, if it’s twitter then you’d have a webpage where you gave your twitter username and password and a webhook url (with a list of sample / common urls) and a submit button. Taking it to that level of simplicity has the potential to open the concept up to an order-of-magnitude larger market.

  24. [...] assembla, joe gregoria, jon udell, timothy fitz, triggers Timothy Fitz recently wrote on What webhooks are and why you should care. It’s a very clear and straightforward description of just that. It helps to have people [...]

  25. Why HTTP? « Timothy Fitz said, on February 12, 2009 at 2:20 am

    [...] a service to HTTP, and it becomes a team player in our ecosystem. Let’s revolutionize the last of our dinosaur protocols and move on. [...]

  26. ovi said, on February 12, 2009 at 8:41 am

    I’ve coded something similar, sort of, at http://qerio.com, using the web rack of “virtual devices” from http://virtual-devices.net. It adds the GUI element to the mix. The webhooks, in this case, are the patch cords in the back of the rack.

  27. [...] What webhooks are and why you should care 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. [...]

  28. Adam Smith said, on February 18, 2009 at 6:19 pm

    Timothy, I haz teh lazy. Please take my content and sell it as ur own in a future post, I know you like it: consuming webhook posts is so simple, even a bent snake could do it.

    I think a two-liner consumer would nicely compliment you one one-liner for posting.

    @easy_consume(80)
    def handle(req): return “meow”+req.args

  29. John Kalucki said, on May 6, 2009 at 4:08 pm

    See the Twitter Streaming API documentation at: http://apiwiki.twitter.com/Streaming-API-Documentation

    A different mechanism, same result.

  30. [...] [upmod] [downmod] What webhooks are and why you should care « Timothy Fitz (timothyfitz.wordpress.com) 1 points posted 3 months ago by jeethu tags webdev webhooks hooks [...]

  31. Yuvamani said, on August 11, 2009 at 12:15 am

    It will be awesome if you can chain these together. Like some sort of yahoo pipes.

  32. mitcho said, on August 29, 2009 at 4:24 pm

    Timothy— I notice you mention in a comment that you’d like to add webhooks to your blog if/when you move off of wordpress.com. If you enjoy WordPress and would like to incorporate webhooks, I recently released a wordpress.org plugin called HookPress which adds a simple interface to register webhooks against WordPress actions and filters. If/when you move to a self-served WordPress install, I invite you to take a look. :)

    http://mitcho.com/code/hookpress/


Leave a Reply