HTTP API#
Wszystkie endpointy REST vCLU. Router oparty na frameworku Gin. Odpowiedzi w formacie JSON, chyba że zaznaczono inaczej.
Uwierzytelnianie#
- Sesja cookie:
vclu_session(ważność 7 dni) - Tworzenie sesji:
POST /loginz username/password - Usuwanie sesji:
GET /logout - Domyślnie: jeśli auth nie skonfigurowany, wszystkie ścieżki dostępne
Ścieżki publiczne (bez sesji):
/login, /static/*, /wizard, /setup, /api/wizard/*, /api/health
System#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/health | Nie | Health check |
| POST | /api/restart | Tak | Restart procesu vCLU |
| POST | /api/reset | Tak | Factory reset (kasuje wszystkie dane) |
| GET | /metrics | Tak | Metryki Prometheus (format tekstowy) |
GET /api/health#
{"status": "ok"}POST /api/restart#
{"message": "Restarting..."}POST /api/reset#
{"message": "Factory reset complete", "redirect": "/wizard"}Urządzenie i konfiguracja#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/device | Tak | Info o urządzeniu |
| GET | /api/keys | Tak | Status kluczy (bez wartości) |
| GET | /api/devices | Tak | Lista typów urządzeń |
| POST | /api/settings/save | Tak | Zapisz ustawienia |
GET /api/device#
{
"serialNumber": 2852799910974750602,
"macAddress": "72:b5:79:eb:92:5c",
"hardwareType": 19,
"hardwareVersion": 1,
"firmwareType": 3,
"firmwareVersion": 11163050,
"status": "OK"
}GET /api/keys#
{
"hasProjectKey": true,
"hasIV": true,
"pin": "00000000"
}POST /api/settings/save#
Body: obiekt CLUDeviceConfig (JSON)
{"message": "Settings saved"}Wizard (kreator konfiguracji)#
Wszystkie endpointy /api/wizard/* nie wymagają sesji.
| Metoda | Ścieżka | Opis |
|---|---|---|
| GET | /api/wizard/state | Bieżący stan wizarda |
| POST | /api/wizard/device-type | Ustaw typ urządzenia |
| POST | /api/wizard/module | Dodaj moduł I/O |
| DELETE | /api/wizard/module/:id | Usuń moduł |
| POST | /api/wizard/keys | Konfiguruj klucze szyfrowania |
| POST | /api/wizard/security | Konfiguruj uwierzytelnianie |
| POST | /api/wizard/finish | Zakończ konfigurację |
| GET | /api/wizard/om-preview | Podgląd om.lua |
GET /api/wizard/state#
{
"deviceTypeId": "clu",
"deviceTypeName": "CLU",
"category": "CLU",
"deviceTypeLocked": false,
"supportsModules": true,
"availableDeviceTypes": [],
"availableModuleTypes": [],
"modules": [],
"ioObjects": [],
"pin": "00000000",
"broadcastEnabled": false,
"broadcastKey": "",
"defaultIV": "",
"broadcastIV": "",
"authEnabled": false,
"authUsername": ""
}POST /api/wizard/device-type#
Body:
{"deviceTypeId": "clu"}Odpowiedź:
{"success": true, "deviceType": {...}}POST /api/wizard/module#
Body:
{"moduleTypeId": "dout8t", "name": "Moduł 1"}Odpowiedź:
{"module": {...}, "ioObjects": [...]}POST /api/wizard/keys#
Body:
{
"pin": "12345678",
"broadcastEnabled": true,
"broadcastKey": "base64...",
"defaultIV": "base64...",
"broadcastIV": "base64..."
}POST /api/wizard/security#
Body:
{
"authEnabled": true,
"username": "admin",
"password": "secret"
}POST /api/wizard/finish#
{"success": true, "device": {...}}Edytor Lua#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/editor/tree | Tak | Drzewo plików (main.lua, user.lua, om.lua, modules/) |
| GET | /api/editor/file/*path | Tak | Odczyt pliku |
| POST | /api/editor/file | Tak | Utwórz nowy plik w modules/ |
| PUT | /api/editor/file/*path | Tak | Zapisz plik |
| DELETE | /api/editor/file/*path | Tak | Usuń plik modułu |
| POST | /api/editor/folder | Tak | Utwórz folder w modules/ |
| DELETE | /api/editor/folder/*path | Tak | Usuń pusty folder |
| POST | /api/lua/reload | Tak | Przeładuj runtime Lua |
GET /api/editor/tree#
{
"system": ["main.lua"],
"modules": ["modules/my_module.lua"],
"proxy": ["om.lua", "user.lua"]
}GET /api/editor/file/*path#
{
"path": "user.lua",
"content": "-- user code here",
"size": 1234,
"readonly": false
}PUT /api/editor/file/*path#
Body:
{"content": "-- updated code"}Odpowiedź:
{"path": "user.lua", "size": 1234}POST /api/lua/reload#
{"success": true, "message": "Lua runtime reloaded"}Runtime i wykonanie#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| POST | /api/clu/execute | Tak | Wykonaj skrypt Lua |
| GET | /api/clus | Tak | Lista zarejestrowanych CLU |
POST /api/clu/execute#
Body:
{
"targetIP": "",
"script": "_:info()"
}Odpowiedź:
{"result": "=== Object Registry ===\n..."}Pusty targetIP = wykonanie lokalne. Podanie IP = wykonanie na zdalnym CLU.
GET /api/clus#
[
{"serial": "CLU221000290", "ip": "127.0.0.1", "local": true},
{"serial": "CLU285279991", "ip": "192.168.0.3", "local": false}
]Rejestr obiektów#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/registry/list | Tak | Wszystkie obiekty rejestru (JSON) |
| POST | /api/registry/subscribe | Tak | Subskrybuj stany ze zdalnych CLU |
GET /api/registry/list#
Zwraca wynik _:toJSON() — tablica JSON obiektów rejestru.
POST /api/registry/subscribe#
{"status": "ok", "result": "Subscribed to 3 CLUs"}MQTT Broker#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/mqtt/broker/stats | Tak | Statystyki brokera |
| GET | /api/mqtt/broker/clients | Tak | Podłączeni klienci MQTT |
| POST | /api/mqtt/broker/save | Tak | Konfiguracja brokera |
| GET | /api/mqtt/clients/stats | Tak | Statystyki klientów MQTT z Lua |
| POST | /api/mqtt/test/publish | Tak | Test publish MQTT |
GET /api/mqtt/broker/stats#
{
"running": true,
"port": 1883,
"clients": 3,
"subscriptions": 12,
"messagesReceived": 456,
"messagesSent": 789
}POST /api/mqtt/broker/save#
Body:
{
"enabled": true,
"port": 1883,
"wsPort": 8080,
"username": "mqtt_user",
"password": "mqtt_pass"
}POST /api/mqtt/test/publish#
Body:
{"topic": "test/topic", "payload": "hello"}Home Assistant#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| POST | /api/ha/discovery/publish | Tak | Publikuj HA Discovery dla wszystkich plików OM |
| POST | /api/ha/commands/enable | Tak | Włącz obsługę komend HA i publikację stanów |
POST /api/ha/discovery/publish#
{
"success": true,
"published": 15,
"states": 15,
"files": 2,
"errors": []
}POST /api/ha/commands/enable#
{"success": true, "message": "Command handling enabled"}HomeKit#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/homekit/status | Tak | Status serwera HomeKit |
| POST | /api/homekit/restart | Tak | Restart serwera HomeKit |
GET /api/homekit/status#
{
"running": true,
"accessoryCount": 12,
"pairingAvailable": true
}Access Control#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/access | Tak | Lista obiektów z poziomami dostępu |
| POST | /api/access | Tak | Ustaw poziom dostępu |
| GET | /api/access/integrations | Tak | Lista integracji |
GET /api/access#
{
"objects": [
{
"path": "CLU.DOUT1",
"type": "DOUT",
"name": "Lampa",
"mqtt": "full",
"homekit": "full"
}
],
"integrations": ["mqtt", "homekit"]
}POST /api/access#
Body:
{
"path": "CLU.DOUT1",
"integration": "mqtt",
"access": "readonly"
}Odpowiedź:
{
"success": true,
"path": "CLU.DOUT1",
"integration": "mqtt",
"access": "readonly"
}Poziomy: full (domyślny), readonly, hidden.
Backup#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| POST | /api/backup/create | Tak | Utwórz backup ZIP |
| GET | /api/backup/list | Tak | Lista backupów |
| GET | /api/backup/download/:filename | Tak | Pobierz plik backup |
| DELETE | /api/backup/:filename | Tak | Usuń backup |
POST /api/backup/create#
{
"success": true,
"filename": "backup_20260217_103000.zip",
"size": 12345,
"sizeHuman": "12.1 KB"
}GET /api/backup/list#
{
"backups": [
{
"filename": "backup_20260217_103000.zip",
"size": 12345,
"sizeHuman": "12.1 KB",
"createdAt": "2026-02-17T10:30:00Z"
}
]
}Pliki OM (zdalne CLU)#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| POST | /api/om/upload | Tak | Upload pliku OM (.lua lub diagnostyczny .zip) |
| GET | /api/om/list | Tak | Lista zaimportowanych plików OM |
| GET | /api/om/:serial | Tak | Szczegóły pliku OM |
| DELETE | /api/om/:serial | Tak | Usuń plik OM |
| POST | /api/om/regenerate | Tak | Regeneruj pliki proxy |
POST /api/om/upload#
Upload multipart (pole file). Obsługuje .lua i .zip (diagnostyczny).
Odpowiedź (.lua):
{
"success": true,
"filename": "om_285279991.lua",
"cluName": "DOM20",
"cluIP": "192.168.0.3",
"objectCount": 45,
"moduleCount": 5
}Odpowiedź (.zip):
{
"isZip": true,
"imported": 2,
"skipped": 0,
"results": [...],
"errors": []
}GET /api/om/:serial#
{
"file": {"filename": "om_285279991.lua", "serial": 285279991},
"clu": {"name": "DOM20", "ip": "192.168.0.3"},
"modules": [...],
"objects": [...]
}Pluginy#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/plugins/repositories | Tak | Lista repozytoriów |
| POST | /api/plugins/repositories | Tak | Dodaj repozytorium |
| DELETE | /api/plugins/repositories/:name | Tak | Usuń repozytorium |
| GET | /api/plugins/available | Tak | Dostępne pluginy z repozytoriów |
| GET | /api/plugins/installed | Tak | Zainstalowane pluginy |
| POST | /api/plugins/install | Tak | Instalacja/aktualizacja pluginu |
| DELETE | /api/plugins/:id | Tak | Odinstaluj plugin |
| POST | /api/plugins/:id/toggle | Tak | Włącz/wyłącz plugin |
| POST | /api/plugins/:id/config | Tak | Aktualizuj konfigurację pluginu |
| GET | /api/plugins/:id/schema | Tak | Schemat konfiguracji pluginu |
| GET | /api/plugins/:id/doc | Tak | Dokumentacja pluginu |
POST /api/plugins/install#
Body:
{
"id": "weather",
"fullId": "@vclu/weather",
"repository": "vCLU Official"
}POST /api/plugins/:id/toggle#
Body:
{"enabled": true}POST /api/plugins/:id/config#
Body:
{"config": {"apiKey": "abc123", "city": "Warsaw"}}Debug i logi#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/debug/stream | Tak | Strumień logów SSE (Server-Sent Events) |
| GET | /api/debug/sources | Tak | Dostępne źródła logów |
| GET | /api/debug/history | Tak | Historia logów (bufor) |
| GET | /api/debug/stats | Tak | Statystyki strumienia logów |
GET /api/debug/stream#
Server-Sent Events — strumień logów w czasie rzeczywistym.
data: {"level":"info","source":"lua","message":"Timer started","timestamp":"..."}
data: {"level":"error","source":"system","message":"Connection failed","timestamp":"..."}GET /api/debug/history#
{
"entries": [...],
"count": 100
}Statystyki i metryki#
| Metoda | Ścieżka | Auth | Opis |
|---|---|---|---|
| GET | /api/stats | Tak | Bieżący snapshot metryk |
| GET | /api/stats/timeseries | Tak | Dane historyczne dla wykresów |
GET /api/stats#
{
"timestamp": "2026-02-17T10:30:00Z",
"uptime": 86400,
"http": {"requestCount": 1234, "errorCount": 5},
"lua": {"executeCount": 5678, "errorCount": 2},
"mqtt": {"messagesIn": 100, "messagesOut": 200},
"memory": {"alloc": 12345678, "sys": 23456789}
}GET /api/stats/timeseries#
Query params:
since(opcjonalny) — timestamp w ms, od którego zwrócić dane
Strony HTML#
| Metoda | Ścieżka | Opis |
|---|---|---|
| GET | / | Index — redirect do wizarda lub statusu |
| GET | /login | Strona logowania |
| POST | /login | Logowanie (formularz) |
| GET | /logout | Wylogowanie |
| GET | /status | Status urządzenia |
| GET | /settings | Ustawienia |
| GET | /wizard | Kreator konfiguracji |
| GET | /modules | Konfiguracja modułów |
| GET | /stats | Statystyki |
| GET | /tools | Narzędzia deweloperskie |
| GET | /backup | Zarządzanie backupami |
| GET | /om-files | Zarządzanie plikami OM |
| GET | /mqtt | Konfiguracja MQTT |
| GET | /homekit | Konfiguracja HomeKit |
| GET | /access | Access control |
| GET | /plugins | Zarządzanie pluginami |
| GET | /editor | Edytor Lua |
| GET | /debug | Logi debug |
Uwagi#
- Język: query param
?lang=en|pl, fallback na cookie, potemAccept-Language - Middleware: Metrics → Language → Auth
- Format odpowiedzi błędów:
{"error": "Error description"}