Getting started with deepstreamHub is easy and takes less than ten minutes. However, if you have any questions, please get in touch.
This guide will take you through deepstreamHub's three core concepts: Records, Events and RPCs.
We'll use just the JavaScript client SDK and a bit of jQuery.
Create a free account and get your API key
Connect to deepstreamHub and log in
Include the JS-client library
<script src="//cdnjs.cloudflare.com/ajax/libs/deepstream.io-client-js/2.1.1/deepstream.js"></script>
Get your app url from the dashboard and establish a connection to deepstreamHub
var ds = deepstream( '<YOUR APP URL>' );
and log in (we didn't configure any authentication, so there are no credentials required)
ds.login();
Records (realtime datastore)
Records are the documents in deepstreamHub’s realtime datastore. A record is identified by a unique id and can contain any kind of JSON data. Clients and backend processes can create, read, write, update and observe the entire record as well as paths within it. Any change is immediately synchronized amongst all connected subscribers.
Records can be arranged in lists and collections and can contain references to other records to allow for the modelling of relational data structures.
You can learn more about records in the records tutorial.
var myRecord = ds.record.getRecord( 'test/johndoe' );
Values can be stored using the .set()
method
myRecord.set({
firstname: 'John',
lastname: 'Doe'
});
Let's set up two-way bindings with an input field - whenever a path within our record, e.g. firstname
changes we want to update the input. Whenever a user types, we want to update the record.
var input = $( '#firstname-input' );
// Update the input when the record changes
myRecord.subscribe( 'firstname', function( firstname ){
input.val( firstname );
});
// Update the record when the input changes
input.on( 'keyup', function(){
myRecord.set( 'firstname', input.val() );
});
Events (publish-subscribe)
Events are deepstreamHub’s publish-subscribe mechanism. Clients and backend processes can subscribe to event-names (sometimes also called “topics” or “channels”) and receive messages published by other endpoints.
Events are non-persistent, one-off messages. For persistent data, please use records.

Clients and backend processes can receive events using .subscribe()
ds.event.subscribe( 'test-event', function( eventData ){ /*do stuff*/ });
... and publish events using .emit()
ds.event.emit( 'test-event', {some: 'data'} );
RPCs (request-response)
Remote Procedure Calls are deepstreamHub’s request-response mechanism. Clients and backend processes can register as “providers” for a given RPC, identified by a unique name. Other endpoints can request said RPC.
deepstreamHub will route requests to the right provider, load-balance between multiple providers for the same RPC, and handle data-serialisation and transport.

You can make a request using .make()
ds.rpc.make( 'multiply-numbers', { a: 6, b: 7 }, function( err, result ){
//result === 42
});
and answer it using .provide()
ds.rpc.provide( 'multiply-numbers', function( data, response ){
resp.send( data.a * data.b );
});
Where to go next?
To learn how to use deepstreamHub with Angular, React, Vue or other frontend frameworks head over to the tutorial section. To learn how to use the JavaScript SDK with NodeJS rather than in a browser, head over to the getting started with NodeJS tutorial.