A NodeJs Package for interfacing Espressif Rainmaker IoT.
npm install rainmaker-client
import RainMaker from "rainmaker-client";
const client = new RainMaker("username", "password");
const SUCCESS = 200;
async function isAuth() {
const { status, result } = await client.authenticate();
if (status == SUCCESS) {
console.log(result);
} else {
console.log(result);
}
}
isAuth();
authenticate
method is used to get accesstoken for Authnticated APIs. Pass true
as param to extend session using refreshtoken
instead of password
.
Stored refreshtoken
can be retrieved by :
const token = client.refreshtoken;
getUserNodes
returns a list of nodes associated to the user. Pass argument true to get details information for the nodes.
getUserGroupDetails
returns a list of groups associated to the user or details about specific group.
It accepts three arguments
nodeList
(defaultfalse
): Passtrue
to get list of nodes in the group.groupID
: pass Group ID to get specific details of a particular group.nodeDetails
(defaultfalse
): to get node details associated to that group. Must provide a group ID.
createUserGroup
creates a new user group with the option of adding nodes and description.
It accepts three arguments
groupName
: Name of the group.nodeList
(optional): Array of Node IDs.description
(optional): Add description to user group.
deleteUserGroup
deletes a user group.
It accepts only one argument
groupID
: User Group ID to deletye.
getTimeSeriesData
returns time series data for a specific node. Currently it only supports aggregate = raw
.
This package is being developed to create a webApp dashboard for ESP Rainmaker IoT solution. Checkout the link below -