Ionburst Node.js SDK
The Ionburst SDK for Node.js is available now on npm.
Repository
The source code for the Ionburst Node.js SDK is available here.
NPM
ionburst-sdk-javascript
Node.js Configuration
Further configuration for the Ionburst Node.js SDK can be specified in a config.json
file.
"Ionburst": {
"Profile": "example_profile",
"IonburstUri": "https://api.example.ionburst.cloud/",
"TraceCredentialsFile": "OFF"
}
Profile
specifies the configuration to use from the Ionburst credentials file.IonburstUri
specifies the Ionburst API endpoint to use.TraceCredentialsFile
is a debug setting that can be used to trace how the SDK picks up credentials. This should not be set to ON in production.
Usage
Creating a Client
An Ionburst client can be created by passing an Ionburst API URI directly. Doing so will override any configured value:
const Ionburst = require('ionburst-sdk')
var ionburst = Ionburst("https://api.example.ionburst.cloud/");
If the value is defined in configuration then the client creation does not require parameters:
const Ionburst = require('ionburst-sdk')
var ionburst = Ionburst();
Classifications
A list of available Ionburst classifications can be retrieved like so:
const Ionburst = require('ionburst-sdk')
var ionburst = Ionburst();
Upload Data
Upload with callback:
ionburst.put({
id: '...',
data: '...',
classstr: '...' // Not Required
}, function(err, data) {
...
});
Upload with async/await:
let data = await ionburst.putAsync({
id: '...',
data: '...',
classstr: '...' // Not Required
});
Download Data
Download with callback:
ionburst.get(id, function(err, data) {
...
});
Download with async/await:
let data = await ionburst.getAsync(id);
Delete Data
ionburst.delete(id, function(err, data) {
...
});
Delete with async/await:
let data = await ionburst.deleteAsync(id);
Upload Data (Deferred)
Deferred upload with callback:
ionburst.startDeferredAction({
action: 'PUT',
id: '...',
data: '...',
classstr: '...' // Not Required
}, function(err, token) {
...
});
Deferred upload with async/await:
let token = await ionburst.startDeferredActionAsync({
action: 'PUT',
id: '...',
data: '...',
classstr: '...' // Not Required
});
Download Data (Deferred)
ionburst.startDeferredAction({
action: 'GET',
id: '...'
}, function(err, token) {
...
});
Deferred download with async/await:
let token = await ionburst.startDeferredActionAsync({
action: 'GET',
id: '...'
});
Check Deferred Request
Check deferred status with callback:
ionburst.checkDeferred(token, function(err, token) {
...
});
Check deferred status with async/await:
let result = await ionburst.checkDeferredAsync(token);
Fetch Data (Deferred)
Fetch data with callback:
ionburst.fetch(token, function(err, result) {
...
});
Fetch data with async/await:
let result = await ionburst.fetchAsync(token);