How to publish an Event using the Wia Node.js SDK

Hi all, Here's a quick tutorial on how to publish an event using the Wia Node.js SDK. Before you get started, you will need to create a Wia account (you can do so here) and add a device.

Firstly, setup your project. Create a folder (let's call it wia-publish-event). Go inside the folder and run npm init (just hit Enter for everything). Now install the Wia SDK by running the command npm install --save wia.

Go to the device you created earlier and get the device's secret key (you can find this in the device's 'Settings' panel). Replace device-secret-key in the code below and run it.

var wia = require('wia')('device-seret-key');{
  name: "motionDetected"

To add a data payload to the event use the code example below.

var wia = require('wia')('device-seret-key');{
  name: "temperature",
  data: 21

That's all folks! CL

Ready to get started?
Talk to our sales team or setup an account.