This SDK version is compatible with Kuzzle 1.0.0-RC9.5 and higher
For UI and linked objects developers, Kuzzle is an open-source solution that handles all the data management (CRUD, real-time storage, search, high-level features, etc).
You can access the Kuzzle repository on Github
The complete SDK documentation is available here
The SDK Javascript implements two network protocols: raw WebSocket, and Socket.IO
The main reason behind this is that while Socket.IO offers better compatibility with older web browsers, our raw WebSocket implementation is about 20% faster
What protocol is used when you connect to Kuzzle depends on multiple factors:
The protocol used is always raw WebSocket.
The SDK will first try to use raw WebSocket to connect to Kuzzle. If the web browser does not support this protocol, then the SDK falls back to Socket.IO
This SDK can be used either in NodeJS or in a browser.
npm install kuzzle-sdk --save
var
  Kuzzle = require('kuzzle-sdk'),
  kuzzle = new Kuzzle('serverName');
var myDoc = {
  name: 'Rick Astley',
  birthDate: '1966/02/06',
  mainActivity: 'Singer',
  website: 'http://www.rickastley.co.uk',
  comment: 'Never gonna give you up, never gonna let you down'
};
kuzzle
  .dataCollectionFactory('music', 'people')
  .createDocument(myDoc, function(error, response) {
    if (error) {
      // handle error...
    }
    /*
    'response' is a KuzzleDocument object
    */
});
// In NodeJS version, you can also use Promise by suffixing functions with "Promise"
kuzzle
  .dataCollectionFactory('music', 'people')
  .createDocumentPromise(myDoc)
  .then(response => {
    /*
    'response' is a KuzzleDocument object
    */
  })
  .catch(error => {
    // handle error here
  });
});Clone this github repository and run npm run build. A dist directory will be created, containing a browser version of this SDK.
<script type="text/javascript" src="dist/kuzzle.js"></script>If you want to support older browser versions, you may load socket.io before Kuzzle, making the SDK compatible with browsers without websocket support:
<!-- Don't forget to include socketio before kuzzle SDK -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.6.0/socket.io.min.js"></script>var
  kuzzle = new Kuzzle('serverName');
var myDoc = {
  name: 'Rick Astley',
  birthDate: '1966/02/06',
  mainActivity: 'Singer',
  website: 'http://www.rickastley.co.uk',
  comment: 'Never gonna give you up, never gonna let you down'
};
kuzzle
  .dataCollectionFactory('music', 'people')
  .createDocument(myDoc, function(error, response) {
    if (error) {
      // handle error...
    }
    /*
    'response' is a KuzzleDocument object
    */
});- Kuzzle constructor has been changed. Instead of an URL, you have to provide a resolvable server name, or an IP address. If you need to specify a port different than the provided default value, you can do so using the portoption.