The node.js client is used for simplifying the interaction with the IoT Worker and Home Insights API. The client helps you to interact with shields and shield-codes, etc within your tenant.
const IoTWHIApiClient = require('iotwhi-api-client').IoTWHIApiClient;
const iotwhiApiHost = 'https://iotworkerinsights.ibm.com';
const iotwhiApiPath = 'api/v1';
const tenantId = 'te_asd37mm9';
const bearerToken = 'Bearer ...';
const iotwhiApiClient = new IoTWHIApiClient(iotwhiApiHost, iotwhiApiPath, tenantId, bearerToken);
const myShieldId = 'sh_qod5rebg';
const desiredRole = 'administrator';
iotwhiApiClient.findRecord('shield', myShieldId, desiredRole)
.then((myShield) => {
console.log(myShield);
});
The client code is in the lib folder and the tests are in the test folder.
npm install
- install the dependenciesnpm run test
- run the tests once
The API documentation can be found here.