Realtime REST demo

Realtime improves user experience (UX) and the speed of communication. lets your application subscribe to Data Events in realtime. This example shows a chat application that visualises REST Data Events (PUT, POST, DELETE) and the executing code block. To get started, create a new database, read the docs and look at the Github code example.

Send a link to this page to your team/friends, start chatting, and watch the events propagate.


Double click or swipe right to delete

The code

// Called when new records are inserted into the database'POST', function(err, mess) {
        	var line = $("<div>").text( + " " +;
// Called when a record is changed in the database'PUT', function(err, mess) {{"_id":}, {}, function(err, updatedline){
// Called when one or more record is deleted in the database'DELETE', function(err, mess) {
            _.each(, function(oneid){
// The initial setup and connection the a realtime database
        var apikey = "577ed0a645c8ac6e5b035fbe";
        var db = null; 
        try {
            db = new restdb(apikey, {realtime: true});
            $("#status").text("Ok, got the api").addClass("online");
        } catch (ex) {
            $("#status").text("Error loading jsapi");
// Called when a user types something in the input field
        	if(e.keyCode == 13)
        		var payload = {"oneliner": $(this).val()};
        		var newline = new;
// Called when a connection is established
        db.on("CONNECT", function() {
        	$("#messages").empty();{}, {"$max": 100,"$orderby": {"_created": -1}}, function(err, lines){
        	    _.each(lines, function(aline){
//Called when the connection is lost, unplug your wifi to see this
        db.on("DISCONNECT", function() {
        	console.log("Realtime closed: ");
// Called after a lost connection is regained
        db.on("RECONNECT", function() {
        	$("#status").addClass("online").removeClass("offline").text("Back again");
View Source