Julian Porras
Julian Porras

Reputation: 95

How integrate Nest API with node js for listen Nest event on real time

According with Nest API Client Libraries (explicitly Javascript for me). https://developers.nest.com/documentation/cloud/firebase-client-libraries

We can listen on Client/Side all events emitted by Nest.
They have an EXCELLENT sample code in his documentation, I downloaded it and worked perfectly.

Is possible implement the same functionality in NodeJs?

I read everything on Nest REST GUIDE https://developers.nest.com/documentation/cloud/rest-guide and I couldn't find calls that may help me.

It is posible?

Upvotes: 0

Views: 894

Answers (2)

Kashif Chandio
Kashif Chandio

Reputation: 49

Yeah, you can do that by using firebase library version 1.1.3 for nodejs.

Here are the following Steps.

Install firebase version 1.1.3 by using node package manager.

npm install [email protected]
var Firebase = require('firebase');
var client = Firebase('wss://developer-api.nest.com');

//Authenticating firebase client by using access token
client.authWithCustomToken('Put Access Token Here', function(error) {
  if (error)
   console.log('Error in connecting Firebase Socket.', error);
  else
   console.log('Firebase socket is connected.');
});

//Now we can listen any changes in Nest Devices
client.on('value', function(snapshot) {
    var obj          =   snapshot.val();
    var nestDevices  =   obj.devices; //Getting All Nest Devices
});

Upvotes: 0

urman
urman

Reputation: 596

Yes. This sample code should help you out. It uses Rest Streaming in node to display events from all three products.

https://github.com/nestlabs/rest-streaming

Upvotes: 1

Related Questions