npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

beebotte

v1.7.0

Published

Beebotte is an open cloud platform for real time connected objects. This package provides the implementation of Beebotte API in nodejs.

Downloads

156

Readme

Beebotte Node.JS SDK

npm version

| what | where | |---------------|----------------------------------------| | overview | http://beebotte.com/overview | | tutorials | http://beebotte.com/tutorials | | apidoc | http://beebotte.com/docs/restapi | | source | https://github.com/beebotte/bbt_node |

Bugs / Feature Requests

Think you.ve found a bug? Want to see a new feature in beebotte? Please open an issue in github. Please provide as much information as possible about the issue type and how to reproduce it.

https://github.com/beebotte/bbt_node/issues

Install

To install the most recent release from npm, run:

npm install beebotte

Introduction

This Node.js library provides:

  • REST client, and,
  • Stream pub/sub client to Beebotte API

The Stream API supports two transports:

  • MQTT
  • Socket.io

Remember, Beebotte resource description uses a two levels hierarchy:

  • Channel: physical or virtual connected object (an application, an arduino, a coffee machine, etc) providing some resources
  • Resource: most elementary part of Beebotte, this is the actual data source (temperature from a domotics sensor)

Usage

REST Connector

  //Include the Beebotte SDK for nodejs
  var bbt = require('beebotte');

  //Create a Beebotte connector
  //Replace API key and secret key by those of your account
  var client = new bbt.Connector({apiKey: 'API KEY', secretKey: 'SECRET KEY'});

  //write (persistent message) to a given channel & resource
  client.write(
    {channel: 'mychannel', resource: 'resource1', data: 'Hello World'},
    function(err, res) {
      if(err) throw(err);
      console.log(res);
  });

  //publishe (transient message) to a given channel & resource
  client.write(
    {channel: 'mychannel', resource: 'resource1', data: 'Hello World'},
    function(err, res) {
      if(err) throw(err);
      console.log(res);
  });

  //read persistent messages from a given channel & resource
  client.read({
    channel: 'mychannel',
    resource: 'resource1', 
    limit: 5/* Retrieves last 5 records */
  }, function(err, res) {
    if(err) throw(err);
    console.log(res);
  });

Stream Connector - MQTT transport

  //Include the Beebotte SDK for nodejs
  var bbt = require('beebotte');

  //Replace API and secret keys by those of your account
  var transport = {
    type: 'mqtt',
    apiKey: 'API KEY', 
    secretKey: 'SECRET KEY',
  }
  
  //Create a Stream connector
  client = new bbt.Stream({ transport: transport });

  //On successful connection
  client.on('connected', function() {
    //subscribe to a channel/resource 
    client.subscribe( 'mychannel', 'myresource', function(message){
      console.log(message);
    })
    //On successful subscription
    .on('subscribed', function(sub) {
      client.publish( 'mychannel', 'myresource', 'Hello World');
    });
  });

You can use the Channel Token to authenticate the connection. Using the Channel Token grants read and write access to any resource of that channel. This is the recommended authentication sc heme.

  //Replace Channel Token by that of your account
  var transport = {
    type: 'mqtt',
    token: 'CHANNEL_TOKEN'
  }

Stream Connector - Socket.io transport

  //Include the Beebotte SDK for nodejs
  var bbt = require('beebotte');

  //Replace API and secret keys by those of your account
  var transport = {
    type: 'socketio',
    apiKey: 'API KEY',
    secretKey: 'SECRET KEY'
  }

  // Alternatively, you could specify an authentication endpoint (see beebotte.com/docs/clientauth)
  //Replace API key by that of your account
  var transport = {
    type: 'socketio',
    apiKey: 'API KEY', 
    auth_endpoint: 'YOUR AUTH ENDPOINT', //See https://beebotte.com/docs/clientauth 
  }
  
  //Create a Stream connector
  client = new bbt.Stream({ transport: transport });

  //On successful connection
  client.on('connected', function() {
    //subscribe to a channel/resource (with read and write access)
    client.subscribe( 'mychannel', 'myresource', {read: true, write: true}, function(message){
      console.log(message);
    })
    //On successful subscription
    .on('subscribed', function(sub) {
      client.publish( 'mychannel', 'myresource', 'Hello World');
    });
  });

You can use the Channel Token to authenticate the connection. Using the Channel Token grants read and write access to any resource of that channel. This is the recommended authentication scheme.

  //Replace Channel Token by that of your account
  var transport = {
    type: 'socketio',
    token: 'CHANNEL_TOKEN'
  }

Alternatively, you could specify an authentication endpoint (see client authentication)

  //Replace API key by that of your account
  var transport = {
    type: 'socketio',
    apiKey: 'API KEY',
    auth_endpoint: 'YOUR AUTH ENDPOINT', //See https://beebotte.com/docs/clientauth
  }

License

Copyright 2020 Beebotte.

The MIT License