- Language
- 🐍 Python
- Package
dojo-swos·import dojo.swos- Latest version
- 0.1.0 · 9 November 2026
- Requires
- Python ≥ 3.9
- Dependencies
- none
- License
- MIT
- Language
- 🐘 PHP
- Package
dojo/swos·Dojo\Swos- Latest version
- 0.1.0 · 9 November 2026
- Requires
- PHP ≥ 8.1
- Dependencies
ext-curl *,ext-json *- License
- MIT
Works with: SwOS 2.x (tested on SwOS 2.16); MikroTik smart switches running SwOS, CRS3xx series and similar.
Independent MikroTik Dojo project library: it is not MikroTik software nor is it approved by MikroTik. Test it in a lab first.
Installation and usage
Installation (Python)
pip install --index-url https://mikrotikdojo.com/en/pypi/<your-address>/simple/ dojo-swosThe library is installed with pip from the dojo index, using a personal URL reserved for dojo members. Joining is free: you only need your email.
Usage example (Python)
from dojo.swos import SwOS
sw = SwOS("192.0.2.10") # utente admin, password vuota (default SwOS)
print(sw.system()["identity"]) # -> SWOS
for p in sw.ports():
print(p["name"], "UP" if p["link"] else "giu'")
# configurare una VLAN (attento alla porta di gestione!)
sw.set_vlans([{"vid": 10, "ports": [2, 3], "name": "lab"}])
# scrivi via b-file, verifica via SNMP
sw.set_snmp(location="sala-rack")Installation (PHP)
composer config repositories.dojo composer https://mikrotikdojo.com/en/composer/<your-address>/
composer require dojo/swosThe library is installed with Composer from the dojo repository, using a personal URL reserved for dojo members. Joining is free: you only need your email.
Usage example (PHP)
use Dojo\Swos\SwOS;
$sw = new SwOS("192.0.2.10"); // utente admin, password vuota (default SwOS)
echo $sw->system()["identity"]; // -> SWOS
foreach ($sw->ports() as $p) {
echo $p["name"], $p["link"] ? " UP\n" : " giu'\n";
}
// configurare una VLAN (attento alla porta di gestione!)
$sw->setVlans([["vid" => 10, "ports" => [2, 3], "name" => "lab"]]);What it does
dojo.swos talks to MikroTik smart switches running SwOS through its undocumented HTTP interface — the so-called b-files (sys.b, link.b, vlan.b…). SwOS is officially browser-only: this library opens that channel from code, so you can read status, counters and configuration, and write configuration, without opening the GUI.
What it does: reads system (identity, IP, temperature, fans), ports (link, speed, names), MAC table, per-port statistics, VLANs, RSTP and SNMP; writes identity, SNMP settings and the VLAN table. It wraps the b-file format (hex numbers, hex-ASCII strings, per-port bitmasks, little-endian IPs) and HTTP Digest authentication.
When it helps: automation and provisioning of SwOS switches, config backup, traffic monitoring, control scripts — everything the GUI does by hand, made repeatable.
Limits: SwOS uses cleartext HTTP with Digest auth (no HTTPS): use it on trusted networks or in the lab. The b-file format is reverse-engineered and MikroTik may change it between releases. Writes are immediate: a wrong VLAN on the management port cuts access.
Versions
| Version | News | File |
|---|---|---|
| 0.1.0 PHP latest 9 November 2026 | First public release (PHP). Requires PHP 8.1+ with the curl and json extensions. Namespace |
|
| 0.1.0 Python latest 9 November 2026 | First public release. Reads system, ports, VLANs, RSTP, SNMP, MAC table and statistics; writes identity, SNMP and VLANs. No external dependencies (standard library only). |
Each file has its SHA-256 fingerprint (pip and Composer check it automatically) and an OpenTimestamps proof registered on Bitcoin: anyone can verify that the file is the one published on that date. Files are downloaded only if you are in the dojo.
How-tos that use it
Frequently asked questions
Does it work with RouterOS?
No: it targets SwOS, MikroTik's switch OS. RouterOS already has the official binary API and REST. On dual-boot devices it applies when they are booted into SwOS.
Which credentials does it need?
The SwOS credentials, which are separate from RouterOS. The default is user admin with an empty password: change it immediately on a real network.
Is HTTPS required?
No, SwOS only exposes HTTP with Digest authentication. That is why the library should be used on trusted networks or in the lab, never exposed to the Internet.
Can I configure VLANs from code?
Yes, both reading and writing (POST to the vlan.b table). Be careful not to isolate the port you manage from, and remember to save the config in SwOS (Actions → Save Config).
Does it read PoE and power draw?
Yes on PoE models, from the b-files. Over SNMP, PoE and power are not exposed: for that data you need the library.