Github Realtime Relay

Building realtime apps on top of GitHub is kind of a pain because GitHub only provides a plain HTTP API to it’s public events. This is why I built the GitHub Realtime Relay (GHRR) which polls all public events and then relays them directly via websockets. This is probably the simplest way to create a realtime application on top of GitHub.

Screenshot of GHRR app

Head over to GitHub for instructions how to use http://ghrr.gq or continue reading.

Usage Example

To get started all you need is an HTML file. We pull in the socket.io client, listen for push events and append them to a list.

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Github Events</title>
    <script src="http://cdn.jsdelivr.net/socket.io-client/1.2.0/socket.io.js"></script>
    <script>
      var url = 'http://ghrr.gq:80/events';
      var socket = io(url);
      socket.on('pushevent', function(event) {
        var logItem = '<li>' + event.actor.login + 'pushed code to ' + event.repo.name + '</li>';
        document.getElementById("eventlog").innerHTML += logItem;
      });
    </script>
  </head>
  <body>
    <ul id="eventlog"></ul>
  </body>
</html>

Screenshot of static website listening on GHRR socket

And that’s it. Because we support CORS you are able to access the public websocket from anywhere.