This SDK version is compatible with Kuzzle 1.0.0-RC5 and higher
Please use SDK v1.x for earlier versions of Kuzzle.
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
For this reason, there is a slight difference with the generic SDK documentation: instead of 1 available port
option, there are actually a wsPort
and a ioPort
options.
These options are defaulted to Kuzzle default protocol plugins.
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
});
});
You can install this SDK with Bower.
bower install kuzzle-sdk --save
<!-- Don't forget to include socketio before kuzzle -->
<script type="text/javascript" src="bower_components/socket.io-client/socket.io.js"></script>
<script type="text/javascript" src="bower_components/kuzzle-sdk/dist/kuzzle.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
*/
});
Clone this github repository and run grunt
. A dist
directory will be created, containing a plain browserified version of this SDK, and a minified version.
- 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 values, you can do so using these two new options:
wsPort
(WebSocket port) andioPort
(Socket.IO port)