Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
N

node-wot

> 编程语言
Open source

A fast and extensible framework to connect any device with your browser and backend applications

192 stars0 likes1 views
WebsiteGitHub

About

A fast and extensible framework to connect any device with your browser and backend applications

A fast and extensible framework to connect any device with your application The Eclipse Thingweb node-wot is a framework for implementing Web of Things servers and clients in Node.js. It is written from the ground up with Typescript with the goal of providing a fast and extensible framework for IoT applications. Node-wot wants to give developers the ability to create complex business logic without worrying about protocol and low-level details leveraging on a standard metadata format, the Thing Description (TD). Thanks to the TD abstraction developers can find a set of satellite tools to create their applications in a fast and easy way.

Web of Things principles in a Nutshell

The Web of Things (WoT) tackles IoT fragmentation by extending standardized web technologies. It simplifies IoT application development, promoting flexibility and interoperability. WoT preserves existing IoT standards, ensuring reuse, and provides an adaptable, abstract architecture based on real-world use cases across domains. In essence, WoT paves the way for seamless IoT integration by defining an information model capable of describing Things and Services and how to interact with them. This information model is called the Thing Description (TD) and it is a JSON-LD document that describes the Thing and its capabilities, including its network services (APIs), its network interactions, and security requirements. The TD is the cornerstone of the Web of Things architecture and it is the main abstraction that node-wot uses to implement its functionalities. Every Thing has the following capabilities or "affordances":

  • ⚙️ Properties: a property is a value that can be read, written or observed. For example, a temperature sensor can have a property that represents the current temperature.
  • ** Actions**: an action is an operation that can be invoked. For example, a light bulb can have an action that turns it on or off.
  • ⚡ Events: an event is a notification. For example, a motion sensor can send an event when it detects motion.

For further information please refer to the official W3C Web of Things website.

Table of Contents

  • Installation
    • As a library
      • Node.js
      • Browser
    • As a CLI tool
      • As a docker image
  • Examples
  • Implemented/supported features
    • Protocol Support
    • MediaType Support
  • No time for explanations - show me a running example!
    • Using Node.js
    • Using Docker
    • Using a browser
  • Online Things
  • Documentation
    • The API
    • TD Tooling
    • Logging
    • Install new/different versions of Node.js
  • Contributing
  • License

Installation

The framework is composed by different packages that users can use as they please. The core package is @node-wot/core and it is the only mandatory package to install. The other packages are bindings that allow the framework to communicate with different protocols.

Prerequisite: Node.js with build tools

[!WARNING] We no longer actively support Node.js version 18 and lower.

  • Node.js version 20+
  • npm version 9+

Platforms specific prerequisites:

  • Linux: Meet the node-gyp requirements:
    • Python v3.6, v3.7, or v3.8
    • make
    • A proper C/C++ compiler toolchain, like GCC
  • Windows: Install the Windows build tools through a CMD shell as administrator:
    • npm install -g --production windows-build-tools
  • Mac OS: Meet the node-gyp requirements:
    • xcode-select --install

As a library

If you want to use node-wot as a library in your Node.js application, you can use npm to install the node-wot packages that you need. Todo so, cd inside your application folder and install at least the mandatory core package:

bash
npm i @node-wot/core

Usually, your application needs at least one protocol binding to commmunicate, e.g.,:

bash
npm i @node-wot/binding-http

In case the application shall consume Thing Descriptions that are stored locally, you would also need the file binding:

bash
npm i @node-wot/binding-file

You see other available bindings in the packages folder, which you can install via npm i @node-wot/.

In the browser

To use node-wot as JavaScript library insde the Web browser, it needs to support ECMAScript 2015+. Using a browser with only ES5 support (e.g., IE 11) might be possible if you add polyfills.

If you want to use node-wot as a library in your browser application,cd inside your application folder and install the browser bundle:

bash
npm i @node-wot/browser-bundle

You can find more (non-)installation options in the specific package README.

As a CLI tool

You can alternatively use node-wot via its command line interface (CLI). Please visit the CLI tool README to find out more.

As global tool

To make the node-wot command available on your machine, install the CLI tool in the global scope:

bash
npm i @node-wot/cli -g

As a docker image

Another option is to use node-wot inside a docker image. Make sure you are under Linux or under WSL if you are running on Windows.

Clone the repository:

bash
git clone https://github.com/eclipse-thingweb/node-wot

Go into the repository:

bash
cd node-wot

Build the Docker image named node-wot from the Dockerfile:

bash
npm run build:docker

Run the node-wot as a container:

bash
docker run --rm node-wot -h

Examples

With node-wot you can create server-side Things, in WoT jargon we call this operation "expose a Thing" or you can create client-side Things, in WoT jargon we call this operation "consume a Thing". An exposed Thing allows you to bring your device or services to the Web with just a few lines of code. On the other hand, with a consumed Thing, you have a fixed interface to interact with devices, potentially using different protocols/frameworks. In the following section, we will show how to create a simple counter Thing and how to consume it. Assuming you have installed and configured node-wot as a library, you can create and expose a counter Thing as follows:

…

Now supposing you want to interact with the device, you have to consume its Thing Description as follows:

…

If you execute both scripts you will see count: ${count} printed 5 times. We host a more complex version of this example at http://plugfest.thingweb.io/examples/counter.html and you can find the source code in the counter example folder. You can also find more examples in the examples folder for JavaScript and in the examples folder for TypeScript. Finally, for your convenience, we host a set of online Things that you can use to test your applications. You can find more information about them in the Online Things section.

Implemented/supported features

Protocol Support

  • HTTP :heavy_check_mark:
  • HTTPS :heavy_check_mark:
  • CoAP :heavy_check_mark:
  • CoAPS :heavy_check_mark:
  • MQTT :heavy_check_mark:
  • Firestore//lastSupportedVersion :heavy_check_mark:
  • Websocket :heavy_plus_sign: (Server only)
  • OPC-UA :heavy_plus_sign: (Client only)
  • NETCONF :heavy_plus_sign: (Client only)
  • Modbus :heavy_plus_sign: (Client only)
  • M-Bus :heavy_plus_sign: (Client only)

[!NOTE] More protocols can be easily added by implementing ProtocolClient, ProtocolClientFactory, and ProtocolServer interface.

MediaType Support

  • JSON :heavy_check_mark:
  • Text (HTML, CSS, XML, SVG) :heavy_check_mark:
  • Base64 (PNG, JPEG, GIF) :heavy_check_mark:
  • Octet stream :heavy_check_mark:
  • CBOR :heavy_check_mark:
  • EXI :timer_clock:

Can't find your preferred MediaType? More codecs can be easily added by implementing ContentCodec interface. Read more in the Documentation section.

No time for explanations - show me a running example!

Using Node.js

Run all the steps above including "Link Packages" and then run this:

bash
node-wot -h
cd examples/scripts
node-wot

Without the "Link Packages" step, the node-wot command is not available and node needs to be used (e.g., Windows CMD shell):

bash
# expose
node packages\cli\dist\cli.js examples\scripts\counter.js
# consume
node packages\cli\dist\cli.js --client-only examples\scripts\counter-client.js
  • Go to http://localhost:8080/counter and you'll find a thing description
  • Query the count by http://localhost:8080/counter/properties/count
  • Modify the count via POST on http://localhost:8080/counter/actions/increment and http://localhost:8080/counter/actions/decrement
  • Application logic is in examples/scripts/counter.js

Using Docker

First build the docker image and then run the counter example:

bash
# expose
docker run -it --init -p 8080:8080/tcp -p 5683:5683/udp -v "$(pwd)"/examples:/srv/examples --rm node-wot /srv/examples/scripts/counter.js
# consume
docker run -it --init -v "$(pwd)"/examples:/srv/examples --rm --net=host node-wot /srv/examples/scripts/counter-client.js --client-only
  • The counter exposes the HTTP endpoint at 8080/tcp and the CoAP endpoint at 5683/udp and they are bound to the host machine (with -p 8080:8080/tcp -p 5683:5683/udp).
  • The counter-client binds the network of the host machine (--net=host) so that it can access the counter thing's endpoints.
  • --init allows the containers to be killed with SIGINT (e.g., Ctrl+c)
  • -v "$(pwd)"/examples:/srv/examples mounts the examples directory to /srv/examples on the container so that the node inside the container can read the example scripts.

Using a browser

An example of how to use node-wot as a browser-side library can be found under examples/browser/index.html. To run it, open examples/browser/index.html in a modern browser, and consume the test Thing available under http://plugfest.thingweb.io:8083/testthing to interact with it.

The JavaScript code that uses node-wot as a library to power this

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptiotnodejswebweb-of-things

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言