eschnou edited this page Mar 3, 2011 · 1 revision

PubSubHubBub (aka PuSH or PSHB) is a simple, open, server-to-server web-hook-based pubsub (publish/subscribe) protocol as an extension to Atom and RSS. Parties (servers) speaking the PubSubHubbub protocol can get near-instant notifications (via webhook callbacks) when a topic (feed URL) they're interested in is updated.


Note that our goal is not to implement the full protocol, we are not interested in providing a fully functional hub in the origianl PuSH sense. Instead, in an OStatus use case, your applications should be its own hub. It receives subscriptions requests from other OStatus nodes and is able to push them new content. It can also subscribe to remote node.

subscribe(url, parameters, callback)

Submit a subscription request to a hub (url). The parameters attribute is an associative array whose keys are the parameters as described in the protocol section #6.1. The result value in the callback will be a string with two possible values:

  • accepted: The requested was verified synchronously and accepted.
  • pending: The request is pending async verification.


var ostatus = require('ostatus');
var parameters = {
   "hub.callback": "",
   "hub.mode": "subscribe",
   "hub.topic": "",
   "hub.verify": "async",
   "hub.verify": "sync",
   "hub.secret": "A0F4D1C6B7DDF17645"
ostatus.push.subscribe("", parameters, function(error, status) {

verify(request, callback)

Verify a subscribe/unsubscribe request as per section #6.2 of the protocol. The request argument is an associative array containing the paramters of the received request. If the verification succeeds, the result contains the value of the subscribed topic. If it fails, an error is propagated to the callback.


var ostatus = require('ostatus');
var request = require("querystring").parse(body); // body was submitted by http for example
ostatus.push.verify(request, function(error, topic) {
  // if not an error, then the requets is verified. We can extract the topic,
  // callback url, etc. from the original request.

distribute(content, url, secret, callback)

Push new content to a subscriber callback url, signing it with your secret if provided. The content should be a string containing a properly formatted atom feed. On success, the callback returns the response status code.


var ostatus = require('ostatus');
var data = ostatus.atom.render(..);
ostatus.push.distribute(data, "", "A0F4D1C6B7DDF17645", function(err, status, body) {
     // err contains the error if any, false otherwise
     // status is the HTTP status code returned by the subscriber
     // body is the body returned by the subscribed (may be usefull for debugging).