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 🙏

© 2026 – Pkg Stats / Ryan Hefner

allthingstalk

v2.0.6

Published

A node.js library for AllThingsTalk Cloud

Readme

Node.js SDK

AllThingsTalk Node.js SDK enables easy access to AllThingsTalk APIs. Use it to write your IoT applications and send data to the AllThingsTalk IoT platform.

Installation

After you download and install Node.js, run the command in the terminal:

npm install allthingstalk

This will initialize a new project, and place all dependencies in it.

Tutorial

Basic knowledge of JavaScript is expected in order to use the SDK.

Importing the library

Create an empty .js file and start by importing the library in your code:

const allthingstalk = require('allthingstalk');

Identifying your device on AllThingsTalk Maker

In order to connect your physical device, like a RPI or a web application implemented as a device to the platform, you'll need to map it to the device resource in the platform.

Once you register at maker.allthingstalk.com, and create a device, you'll find Device Id and Device Token under Settings > Authentication. Add it to your code:

allthingstalk.credentials = {
  "deviceId": "<yourDeviceId>",
  "token": "<yourDeviceToken>"
};

Adding assets

You'll need to add assets to your device, in order to map the data you're sending to the platform. For more info on assets see Assets article in our Docs.

In most cases you'll be sending data to the platform, e.g, your room temperature. Use a sensor asset for that.

allthingstalk.addAsset("counter", "Counter", "Count the number of user's visits", "integer")

This will create an asset with a unique asset name counter, human friendly title, description of what it represents, and type of data that will be sent. Supported profile types are number, integer, string, boolean and object. For more info on profile types see Profiles article in our Docs.

Add a success callback argument to the function if you want to handle the response (e.g. print out a status message):

allthingstalk.addAsset("counter", "Counter", "Count the number of user's visits", "integer",
  function (status, statusMsg) {
  console.log(statusMsg)
});

Sending data to the platform

Establish a connection to the platform:

allthingstalk.connect();

To send a sensor data to the platform do:

allthingstalk.send(<value>, "<assetName>");

To simulate sending counter values to the counter asset add:

function sendCount(i) {
    setTimeout(function() {
        allthingstalk.send(i, "counter");
        sendCount(++i);
    }, 2000)
};
    
sendCount(0);

Receiving commands from the platform

If you wish to send a command from the platform to physical device and actuate it, you can use actuator assets. In order to create an actuator you'll pass actuation callback argument to addAsset function which defines what happens when a command from the platform arrives:

allthingstalk.addAsset("led", "Led", "Blue led lamp", "boolean", 
    function() {
          console.log ("Awaiting a command");
    },
    function(message) {
        led.writeSync(0);  // your logic to actuate the device
    });

Once the asset is created you'll see in the terminal that your device awaits a command. When that happens a function that turns the led on will run.

Examples

To obtain the example you can either clone the repository, or copy the examples directly from GitHub.

Sensor example

Sensor example simulates a device which asks for a message and sends it to the platform.

Navigate to the example folder, and add your Device Id and Device Token to sensor.js file, e.g:

allthingstalk.credentials = {
    "deviceId": "71DTRZpn8SzXrfGMM7cGQ9Ui",
    "token": "afaketoken:4UT0JCOR9JTfW1VeVsQ1aXliBU4MJtXcLcp9NB7"
};

Save the changes and run the example:

node sensor.js

Enter “hello” in the terminal, and the Message asset will show your message.

Actuator example

Actuator example shows how to send commands from AllThingsTalk Maker and receive them in the terminal.

Navigate to the example folder, and add your Device Id and Device Token to actuator.js file, e.g:

allthingstalk.credentials = {
    "deviceId": "71DTRZpn8SzXrfGMM7cGQ9Ui",
    "token": "afaketoken:4UT0JCOR9JTfW1VeVsQ1aXliBU4MJtXcLcp9NB7"
};

Save the changes and run the example:

node actuator.js

In AllThingsTalk Maker, send a command from the Commander asset; you should see that the command is received in the terminal.