REST API - 设置与诊断
除专门标明的主题和语言读取外,各方法都需要会话 cookie。本页的命令会更改正在运行的应用程序的设置;更改网络可能中断输出,而 reboot 会重启计算机。
Art-Net:快速命令
| 方法与路径 | 主体 | 结果 |
|---|---|---|
GET /api/artnet/interfaces |
— | 适配器数组:name、ip、physicalAddress、info。
|
GET /api/artnet/status |
— | {"enabled":true,"physicalAddress":"..."}。
|
POST /api/artnet/interface |
{"physicalAddress":"001122334455"} |
按 MAC 选择适配器;若 Art-Net 正在运行,则重启它。204;MAC 格式错误——400。
|
POST /api/artnet/enable |
{"enabled":true} |
启动 Art-Net,false——停止。204。
|
示例中的 MAC 仅为占位:请使用 /interfaces 返回的 physicalAddress。命令执行后,请检查 /status 和 /api/diagnostics/summary:204 并不能证明物理设备可访问。
按分区的设置
GET /api/settings/remote 返回一个包含 startup、artNet、location、cache、osc、timecode、access 各分区的对象。
要进行更改,请读取该对象,修改分区中所需的字段,然后用相应的 POST 发送整个分区。这不是 PATCH:遗漏的字段可能被重置为默认值。成功的响应为 200,并带有该分区的实际设置。
| 方法 | 可修改的字段与限制 |
|---|---|
POST /api/settings/startup |
runOnWindowsStart、openProjectOnStartup、projectFilename、startSchedulerOnStartup、enableArtNetOnStartup、hideUiOnAutoLoadFile、autoPlayTimelineOnProjectOpen、autosaveEnabled、autosaveIntervalMinutes(1–1440)、autosaveBackupCount(1–1000)、showFPS。其余所列开关均为 boolean。
|
POST /api/settings/artnet |
enabled、physicalAddress、fps(1–240)、sendWorkers(0–32)、sync、dontTouchAutomatically、projectId。请保留最近一次 GET 返回的 projectId;项目更换时请重新读取设置。
|
POST /api/settings/location |
name、address、latitude(−90…90)、longitude(−180…180)。会结合地理位置重新生成日程。
|
POST /api/settings/cache |
cacheVideoSequence、cachedFrames(10–100000)、limitGb(10–100000)。
|
POST /api/settings/osc |
enabled、inputPort、feedbackPort(端口 1–65535)、feedbackIp(IPv4)、autoIp。
|
POST /api/settings/timecode |
allInterfaces、physicalAddress、outputEnabled。
|
只读字段:location.sunrise、location.sunset、location.timeZone;cache.folder、cache.usedBytes、cache.freeBytes;osc.running。将这些字段回传不会改变它们。响应中的缓存大小以字节为单位;freeBytes:-1 表示可用空间未知。location.timeZone 报告的是 Windows 时区,位置的 POST 不会更改它。
启用 openProjectOnStartup 时,projectFilename 必须是 LS4 计算机上现有 .ls 文件的完整路径。sync 是项目的 ArtSync 设置;要使其保存到 .ls 中,请保存项目。
按连接说明登录后,通过 PowerShell 仅更改 Art-Net 帧率的示例:
$settings = Invoke-RestMethod -Uri "$base/api/settings/remote" -WebSession $ls4
$artnet = $settings.artNet
$artnet.fps = 30
$body = $artnet | ConvertTo-Json
Invoke-RestMethod -Uri "$base/api/settings/artnet" -Method Post -WebSession $ls4 `
-ContentType 'application/json; charset=utf-8' `
-Body ([System.Text.Encoding]::UTF8.GetBytes($body))
应用错误返回 400 并带有 {"code":"..."}:ProjectMissing、AdapterMissing、ProjectChanged、InvalidValues、InvalidIp、ArtNetStartFailed、OscStartFailed、TimecodeStartFailed、RequestFailed。JSON 范围检查可能返回标准的验证错误对象。意外错误为 500 且 code:RequestFailed。服务启动失败时,请重新读取设置:部分更改可能已经生效。
清除缓存
POST /api/settings/cache/clear 带主体 {"confirmed":true} 会清除缓存,并返回 200 和 cache 分区。若 confirmed:false——400,{"code":"ConfirmationRequired"}。在客户端界面中,请在发送命令之前向操作员请求此确认。
凭据与二维码
POST /api/settings/access 接受:
{
"login":"operator",
"tokenLifetimeMinutes":60,
"currentPassword":"CURRENT_PASSWORD",
"newPassword":"NEW_PASSWORD"
}
login 为非空字符串,最长 128 个字符;tokenLifetimeMinutes 为 1–10080,即二维码令牌的有效期(分钟)。更改登录名或传入新密码时,需要正确的 currentPassword;密码最长 256 个字符。若只更改有效期,请传入当前登录名,密码字段可以省略。newPassword 为空或缺失时,密码保持不变。
200 响应:{"settings":{"login":"operator","tokenLifetimeMinutes":60},"credentialsChanged":true}。凭据更改后,旧会话将无法通过验证,二维码令牌会被撤销。请重新登录。错误:400 并带有 code:CurrentPasswordIncorrect 或 code:InvalidValues。
不带主体的 POST /api/settings/access/qr 会创建二维码链接。200 响应:url、image(PNG,data URL 形式)、expires(UTC 时间)。该链接允许无需输入密码即可登录,且只能使用一次;用于交给特定的操作员。
常规设置、主题与语言
| 方法与路径 | 主体/响应 |
|---|---|
GET /api/settings |
常规对象:runOnWindowsStart、openProjectOnStartup、projectStartupFilename、startSchedulerOnStartup、enableArtNetOnStartup、hideUiOnAutoLoadFile、showFPS、darkTheme。
|
POST /api/settings |
同样形式的完整对象;204。
|
GET /api/settings/theme |
无需登录:{"darkTheme":true}。
|
POST /api/settings/theme |
{"darkTheme":true};204。
|
GET /api/settings/language |
无需登录:{"culture":"ru"},为当前请求的语言。
|
POST /api/settings/language |
{"culture":"ru"};204 以及语言 cookie。不支持的代码——400。
|
在 /api/settings 中,自动加载路径名为 projectStartupFilename,而在 /api/settings/startup 中为 projectFilename。这两种模式不能互相替代。
语言代码:en、zh、zh-Hant、it、de、fr、es、ja、ko、pt、pl、tr、ar、ru。语言 cookie 改变的是该浏览器/会话的语言,与桌面界面及其他浏览器无关。
系统监控
| 方法与路径 | 200 响应
|
|---|---|
GET /api/system/fps |
{"fps":60}——当前帧率。
|
GET /api/system/uptime |
application、server——应用程序和 Web 服务器的运行时长;server 可能为 null。
|
GET /api/system/info |
buildVersion、licenseKey、licenseExpires、universes、processor、video、ram、windowsVersion。
|
GET /api/system/metrics |
负载、温度和性能的快照,见下文。 |
GET /api/system/history?metric=0&hours=24 |
所选指标的历史记录。 |
uptime 以及指标中的对应字段是形如 01:23:45 或 1.01:23:45(天数在小时之前)的时长字符串,而不是秒数。licenseExpires 在日期被识别时格式为 dd-MM-yyyy。licenseKey 包含许可证数据:请勿将 /info 的完整响应写入公开的集成日志。
/metrics 的字段
| 字段 | 单位与含义 |
|---|---|
timestamp |
带时区偏移的快照时间。 |
cpuPercent、gpuPercent、ramPercent、diskPercent |
负载百分比。 |
memoryUsedBytes、memoryTotalBytes |
内存,单位为字节。 |
cpuTemperature、gpuTemperature |
温度,单位 °C。 |
cpuTemperatureStatus |
0——等待中;1——可用;2——无驱动;3——访问被拒绝;4——无传感器;5——服务不可用。 |
networkReceiveMbps、networkSendMbps |
接收和发送速率,单位为兆比特每秒。 |
fps、targetFps、droppedFrames |
当前/目标帧率以及丢帧数。 |
applicationUptime、serverUptime |
运行时长。 |
drives |
磁盘数组:name、label、usedBytes、totalBytes、bytesPerSecond。
|
不可用的数值读数可能为 null;这不是零。如果还没有快照或快照已超过 5 秒,服务器返回 503。
负载历史
metric:0——CPU,1——GPU,2——RAM,3——磁盘。hours:仅限 1、6 或 24;默认 metric=0、hours=24。
可以指定精确的范围:GET /api/system/history?metric=0&from=...&to=...。from 和 to 为以秒计的 Unix 时间,必须同时给出;from>=0,to>from,范围不超过 86400 秒,to 不得比当前时间超前超过 2 秒。如果同时传入了 hours,它也必须是有效值。参数无效——400。
响应:from、to、bucketSeconds、persisted、average、maximum、samples、points、availableFrom、availableTo、timeZone。每个点包含 timestamp、average、maximum、samples。时间戳为 Unix 秒;bucketSeconds 为平均区间的长度。
设备诊断
这些方法返回的数据与 Web 控制面板的“诊断”页面所显示的相同;该页面还说明了设备状态和问题的含义。
| 方法与路径 | 结果 |
|---|---|
GET /api/diagnostics/summary |
problemCount、offlineCount、total、stamp。
|
GET /api/diagnostics/status |
engine、devices、events、problemCount、offlineCount、total、stamp、nowUtc。
|
POST /api/diagnostics/poll |
请求一次计划外的轮询,204;然后重新读取状态。
|
POST /api/diagnostics/locate/{uid} |
发送设备识别命令,204;GUID 无效——400 并带有 error:bad-uid,无地址——400 并带有 error:no-address。
|
对于 locate,请使用状态中的 devices[].uid。诊断事件:timeUtc、kind、uid、device、detail;最多返回 100 个事件。
engine 字段:running、suppressedReason、overloaded、ticksPerSecond、targetFps、workers、universesInProject、foreignSenders、pollIntervalSeconds、offlineAfterSeconds、lastPollUtc、pollsSent、pollError、listenerError。foreignSenders 包含第三方发送方:address、name、universes(从一开始编号)、packetsPerSecond。
设备字段:uid、kind、iconKey、outputStatus、name、owner、ip、mac、startUniverse、universeCount、ports、presence、lastSeenUtc、offlineSinceUtc、replyName、firmware、nodeReport、sendError、subnetWarning、issues。进行初步监控时,请使用汇总计数器、sendError 和 issues 列表;kind、outputStatus、presence 字段以数字传输。
| 字段 | 取值 |
|---|---|
kind |
1——转换器,2——Player。 |
outputStatus |
1——运行中,2——暂停,3——已停止,4——错误。 |
presence |
0——未知,1——有响应,2——无响应,3——未绑定地址,4——不轮询(例如 sACN)。 |
issues |
代码数组:offline、send-error、subnet、unlinked、duplicate-ip。
|
两台服务器的冗余
| 方法与路径 | 主体/结果 |
|---|---|
GET /api/redundancy/status |
本地服务器、伙伴服务器和项目传输的状态。 |
GET /api/redundancy/settings |
当前的冗余设置。 |
POST /api/redundancy/settings |
完整的设置对象;200 并带有实际应用的值。
|
POST /api/redundancy/takeover |
无主体:为当前服务器请求输出权。204。
|
POST /api/redundancy/release |
无主体:释放输出权。204。
|
POST /api/redundancy/send-project?media=false |
无主体:开始向伙伴服务器传输项目;media=true——连同媒体。204,完成情况通过状态检查。
|
命令被拒绝时返回 400 并带有 {"error":"..."}。设置:
| 字段 | 含义 |
|---|---|
enabled |
启用冗余。 |
role |
1——主服务器,2——备用服务器。 |
peerAddress |
伙伴服务器的 IP 或名称。 |
port |
冗余使用的公共 UDP/TCP 端口号,默认 6473。允许 1024–65535;无效的端口号会被替换为 6473。 |
sharedKey |
这一对服务器的共享密钥。读取时也会返回;请勿公开包含真实密钥的响应。 |
heartbeatMs |
交换周期,单位 ms,200–10000;默认 1000。 |
failoverMs |
切换阈值,单位 ms,不小于 1000 且不小于两个 heartbeat 周期,最大 120000;默认 5000。 |
autoFailback |
自动将输出权交还给主服务器。 |
failbackDelayMs |
交还延迟,单位 ms,0–600000;默认 10000。 |
服务器会对范围进行规范化,因此请使用 POST 响应中的值。启用冗余需要 peerAddress;否则返回 400 并带有 error:peer-address。
状态字段:settings、local、peer(可能为 null)、peerKnown、peerOnline、peerSilentSeconds、peerLastSeenUtc、reason、projectsMatch(可能为 null)、outputSuppressed、socketError、transfer、events、nowUtc。
local/peer 对象:host、address、version、role、state、artNetRunning、artNetTicksPerSecond、projectName、projectPath、projectHash、projectModifiedUtc、playing、fps、uptimeSeconds、manualStandby。state 的取值:0——冗余关闭,1——启动/等待,2——活动,3——待机备用。
transfer 对象:phase(0——无传输,1——打包,2——发送,3——已完成,4——错误)、fileName、bytesSent、bytesTotal、percent、error、finishedUtc。events 事件:timeUtc、kind、detail,最多 60 条记录。
日志与重启
| 方法与路径 | 结果 |
|---|---|
GET /api/log |
200:total 以及带有 date、level、message 字段的 entries 数组。
|
GET /api/log/download |
文本文件 log.txt,text/plain; charset=utf-8。
|
POST /api/log/clear |
清除日志,204;无主体。
|
POST /api/system/reboot |
立即重启 LS4 计算机上的 Windows,无主体,也没有额外的确认参数。 |
对于 reboot,正常响应为 204,命令启动失败为 500;连接可能因重启而中断。这是整台计算机的重启,而不仅仅是应用程序。请在您的客户端中提供明确的操作员确认。日志读取/清除错误可能返回 500 并带有文本消息。