Javascript real-time SDK
iotflows-js npm package https://www.npmjs.com/package/@iotflows/iotflows-js
Last updated
Was this helpful?
iotflows-js npm package https://www.npmjs.com/package/@iotflows/iotflows-js
Last updated
Was this helpful?
IoTFlows Open Source JavaScript WebSocket SDK.
With this tool you can:
Publish secure real-time data streams.
Subscribe to the data streams and access real-time data on your web/mobile/IoT apps.
Publish alerts to the alert channels with a defined severity level. Subscribers will get notified in the form of SMS/Email/Push.
Define cloud actions that can be called from other IoT devices/web applications.
Use npm
to install the iotflows.js module:
This function will create and initialize an IoTFlows instance. This is an async function and you would need to use 'await' to ensure proper initialization.
Make sure to change API_KEY_USERNAME
and API_KEY_PASSWORD
with the proper credentials obtained from IoTFlows console. These credentials can be either one of these options:
To publish a real-time data stream, you need to pass these parameters in a json object:
data_stream_uuid: the uuid of the data stream
data: the data to be published to the data stream
Read more:
Example:
To listen to real-time data streams that are published, you need to define the following parameters in a json object:
data_stream_uuid: data stream uuid
qos (optional): quality of service 0, 1, or 2 (0: At most once, 1: At least once, 2: Exactly once)
callback: handler function to be called when data received
Example:
To publish an alert, you need to pass these parameters in a json object:
alert_channel_uuid: the uuid of the alert channel
severity: the severity of the alert. It can be MAJOR, MINOR or INFORMATIVE
subject: the subject of the alert
description: the description/message of the alert
Read more:
Example:
To define a cloud action that can be called from other IoT/web applications, you need to define the following parameters in a json object:
action_uuid action uuid
qos (optional): quality of service 0, 1, or 2 (0: At most once, 1: At least once, 2: Exactly once)
callback: handler function to be called when action gets executed
Read more:
Example:
To publish an alert, you need to pass these parameters in a json object:
action_uuid: the uuid of the action
payload: the payload to be published to the action
Example:
To publish an MQTT message with a defined topic, you need to pass these parameters:
topic: the mqtt topic
payload: the message payload to be sent
Example:
To subscribe to a generic MQTT topic, you need to define the following parameters:
topic: the mqtt topic
callback: the callback handler function that gets triggered once a message is received
Example:
A that has permission to interact with the resources available in its project, or
An Organization that can have read-only or read/write permissions to the entire organization resources
A that is authorized to interact with the permitted resources of the user. This option is most useful when you need to build a web or mobile app. For this option, you need to register your Application in IoTFlows and authenticate users using . With the obtained , you can perform a HTTP request to generate a User Client.