1.1.2 • Published 8 years ago

databoom.js v1.1.2

Weekly downloads
6
License
MIT
Repository
github
Last release
8 years ago

Alt text

databoom.js: client functionalities to send data to DATABOOM.

databoom.js is a simple Node.js module that helps you in sending your data to Databoom in an easy, intuitive, fast way. To date, the following protocols and services are available:

  • HTTP
  • MQTT
  • PubNub

Dependencies

databoom.js uses a number of modules to work properly:

  • mqtt - A library for the MQTT protocol
  • pubnub - Publish & Subscribe Real-time Messaging with PubNub
  • request - Simplified HTTP request client

databoom.js is open source with a public repository on GitHub.

Installation

You need first to install package with npm:

$ npm install databoom.js

In your Node.js script you just need the following line to access the different functionalities databoom.js offers.

var db = require('databoom.js');

Functions

  • db.initialize(token, APIkey)
  • db.setDevice(token)
  • db.setAPIKey(APIkey)
  • db.getSettings()
  • db.addSignals(signal 1, signal 2, ...)]
  • db.getSignals()
  • db.deleteSignals([index])
  • db.publishHTTP([signals], [date])
  • db.startMQTTClient()
  • db.endMQTTClient()
  • db.getMQTTClient()
  • db.publishMQTT([signals], [date])
  • db.initPubNub()
  • db.publishPubNub([signals], [date])

Databoom APIs

  • db.APIgetAlarms(callback)
  • db.APIgetAlarmById(idAlarm, callback)
  • db.APIgetChartSignal(idSignal, callback)
  • db.APIgetDashboards(callback)
  • db.APIgetDashboardById(idDashboard, callback)
  • db.APIgetWidgets(callback)
  • db.APIgetWidgetById(idWidget, callback)
  • db.APIgetDevices(callback)
  • db.APIgetDeviceById(idDevice, callback)
  • db.APIgetDeviceByToken(tokenDevice, callback)
  • db.APIgetDevicesTypes(callback)
  • db.APIgetRules(callback)
  • db.APIgetRuleById(idRule, callback)
  • db.APIgetUnits(callback)
  • db.APIgetSignals(callback)
  • db.APIgetSignalById(idSignal, callback)
  • db.APIgetTeams(callback)
  • db.APIgetTeamById(idTeam, callback)

db.initialize(token, APIkey)

To initialize both the device token and the API key. token is your Databoom device token, while APIkey is your personal Databoom API key. You need to set these values to use other functionalities.

db.setDevice(token)

To set the device you are working with. token is your Databoom device token. You need also to setAPIKey to access other functionalities.

db.setAPIKey(APIkey)

To set the API key. APIkey is your personal Databoom API key. You need also to setDevice to access other functionalities.

db.getSettings()

Returns an objects with the settings you provided.

{
   deviceToken: DEVICE TOKEN,
   userAPIKey: USER API KEY
}

db.addSignals(signal 1, signal 2, ...)

To add signals before publishing/posting them. At least a signal as argument is required. A signal is an object structured as follows:

{
   name: YOUR SIGNAL NAME,
   value: YOUR SIGNAL VALUE
}

db.getSignals()

Returns the signals list you already added, which are ready to be published/posted.

db.deleteSignals(index)

Specifying an index, the corresponding signal is removed from the list. If no index is provided, db.deleteSignals() removes all the stored signals.

db.publishHTTP(signals, date)

  • db.publishHTTP() sends an HTTP post request to Databoom with the signals you added before, if any. Uses the current date.
  • db.publishHTTP(signals) sends an HTTP post request to Databoom with the signals specified as arguments. signals can be a single signal
{ name: YOUR SIGNAL NAME, value: YOUR SIGNAL VALUE}

or a signals array

[{ name: YOUR SIGNAL1 NAME, value: YOUR SIGNAL1 VALUE }, { name: YOUR SIGNAL2 NAME, value: YOUR SIGNAL2 VALUE }, ... ]

Uses the current date.

  • db.publishHTTP(signals, date) works as db.publishHTTP(signals), but uses the specified date.

db.startMQTTClient()

Creates and starts a client MQTT. You need it to publish your device data on databoom topic.

db.endMQTTClient()

To close the client MQTT after the data are sent.

db.getMQTTClient()

Returns all the available client details.

db.publishMQTT(signals, date)

  • db.publishMQTT() publishes on Databoom topic the signals you added before, if any. Uses the current date.
  • db.publishMQTT(signals) publishes on Databoom topic the signals specified as arguments. signals can be a single signal
{ name: YOUR SIGNAL NAME, value: YOUR SIGNAL VALUE}

or a signals array

[{ name: YOUR SIGNAL1 NAME, value: YOUR SIGNAL1 VALUE }, { name: YOUR SIGNAL2 NAME, value: YOUR SIGNAL2 VALUE }, ... ]

Uses the current date.

  • db.publishMQTT(signals, date) works as db.publishMQTT(signals), but uses the specified date.

db.initPubNub()

Creates a PubNub instance. You need it to publish your device data on databoom channel.

db.publishPubNub(signals, date)

  • db.publishPubNub() publishes on Databoom channel the signals you added before, if any. Uses the current date.
  • db.publishPubNub(signals) publishes on Databoom channel the signals specified as arguments. signals can be a single signal
{ name: YOUR SIGNAL NAME, value: YOUR SIGNAL VALUE}

or a signals array

[{ name: YOUR SIGNAL1 NAME, value: YOUR SIGNAL1 VALUE }, { name: YOUR SIGNAL2 NAME, value: YOUR SIGNAL2 VALUE }, ... ]

Uses the current date.

  • db.publishPubNub(signals, date) works as db.publishPubNub(signals), but uses the specified date.

To use any of the APIs, you need to setAPIKey first.

db.APIgetAlarms(callback)

Callback returns as argument the alarms list matching the setted API key.

db.APIgetAlarmById(idAlarm, callback)

Callback returns as argument the alarm matching the id, if any.

db.APIgetChartSignal(idSignal, callback)

Callback returns as argument the chart values of the signal matching the id, if any.

db.APIgetDashboards(callback)

Callback returns as argument the dashboards list matching the setted API key.

db.APIgetDashboardById(idDashboard, callback)

Callback returns as argument the dashboard matching the id, if any.

db.APIgetWidgets(callback)

Callback returns as argument the widgets list matching the setted API key.

db.APIgetWidgetById(idWidget, callback)

Callback returns as argument the widget matching the id, if any.

db.APIgetDevices(callback)

Callback returns as argument the devices list matching the setted API key.

db.APIgetDeviceById(idDevice, callback)

Callback returns as argument the device matching the id, if any.

db.APIgetDeviceByToken(tokenDevice, callback)

Callback returns as argument the device matching the token, if any.

db.APIgetDevicesTypes(callback)

Callback returns as argument the devices types list.

db.APIgetRules(callback)

Callback returns as argument the rules list matching the setted API key.

db.APIgetRuleById(idRule, callback)

Callback returns as argument the rule matching the id, if any.

db.APIgetUnits(callback)

Callback returns as argument the units list.

db.APIgetSignals(callback)

Callback returns as argument the signals list matching the setted API key.

db.APIgetSignalById(idSignal, callback)

Callback returns as argument the signal matching the id, if any.

db.APIgetTeams(callback)

Callback returns as argument the teams list matching the setted API key.

db.APIgetTeamById(idTeam, callback)

Callback returns as argument the team matching the id, if any.


Version

1.1.2

License

MIT

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago