A WoT runtime in Python for Thing and Consumer applications
wotpy is an implementation of a W3C WoT Runtime and the W3C WoT Scripting API in Python.
See the wotpy documentation.
- K. Kajimoto, M. Kovatsch, and U. Davuluru, ‘Web of Things (WoT) Architecture’, W3C, W3C First Public Working Draft, Sep. 2017. [Online]. Available: https://www.w3.org/TR/2017/WD-wot-architecture-20170914/
- Z. Kis, K. Nimura, D. Peintner, and J. Hund, ‘Web of Things (WoT) Scripting API’, W3C, W3C Working Draft, Nov. 2018. [Online]. Available: https://www.w3.org/TR/2018/WD-wot-scripting-api-20181129/
- S. Käbisch and T. Kamiya, ‘Web of Things (WoT) Thing Description’, W3C, W3C Working Draft, Oct. 2018. [Online]. Available: https://www.w3.org/TR/2018/WD-wot-thing-description-20181021/
ℹ️ It is in our plans to get wotpy up to speed with the latest version of the specifications. We don't have an ETA for this, but we will be working on it in the near future.
If you are looking for a Python-like reference for the current Scripting API, see the
WoTnamespace definition in the W3C WoT Scripting API specification. The canonical reference implementation is node-wot.
In summary, wotpy is mature enough to be used in projects; in fact, it is being used in production at CTIC. However, it is not an adequate representation of the current status of the W3C WoT. We greatly encourage you to check the Developer Resources section on the WoT website to find out about the current state of the art.
The wotpy project provides implementations of these protocol bindings:
- HTTP
- WebSockets
- CoAP
- MQTT
- Zenoh
- Modbus
These bindings are built on top of the following dependencies, which are instrumental to the project:
| Feature | Implementation based on | Client | Server |
|---|---|---|---|
| HTTP binding | tornadoweb/tornado | ✔️ | ✔️ |
| WebSockets binding | tornadoweb/tornado | ✔️ | ✔️ |
| CoAP binding | chrysn/aiocoap | ✔️ | ✔️ |
| MQTT binding | Yakifo/amqtt | ✔️ | ✔️ |
| Zenoh binding | eclipse-zenoh/zenoh-python | ✔️ | ✔️ |
| Modbus binding | pymodbus-dev/pymodbus | ✔️ | - |
Install wotpy using pip:
pip install wotpyThe development workflow of wotpy is based on Taskfile v3.28 or later, so that's the first thing you need to install. If you are on Windows, see Running tests on Windows.
Create a .venv virtual environment and install the project in development mode with its development, documentation, and test dependencies.
Using pip:
task venvUsing uv:
task uv-venvIf task is not available or you have an older version, you can run the underlying commands directly:
Using pip:
python3 -m venv .venv
.venv/bin/pip install -U -e ".[dev,docs,tests]"Using uv:
uv venv .venv
uv sync --extra dev --extra docs --extra testsThe docs are built with Sphinx and the Furo theme, installed with the development dependencies above.
From the docs/ directory:
cd docs
make htmlTo preview, open _build/html/index.html in a browser.
From the docs/ directory:
cd docs
make multiversion make multiversion builds every release tag above v0.17.0 plus the develop branch (as develop/) with sphinx-multiversion, and writes a root index.html redirecting to develop/. Open docs/_build/index.html in a browser (serve over HTTP, e.g. python3 -m http.server). Use make clean && make multiversion to force a full rebuild.
Some wotpy features (e.g., the CoAP binding) are not available outside of Linux. If you have Docker installed and want to run the full test suite in a Linux environment, you can use the Docker-based test task:
PYTHON_TAG=<version> task docker-testsReplace <version> with the Python version you want to test. The task starts the MQTT broker and Zenoh router required by the tests and sets the corresponding environment variables.
You should use the version.sh file and not change any versions anywhere manually.
Running version.sh minor will bump the minor version, push the tags and update the master branch and also trigger the release.
Make sure to clear the .venv environment and reinstall the packages before publishing.
An unclean tree will fail the script, i.e. the develop branch must be in a clean state first.
Note: This can be only used by those who have force push rights to the develop branch. See here.