UniFi Integration API
Use this skill for read-only UniFi monitoring through a UniFi API key.
Setup
Create the credentials file:
INLINECODE0
Example:
CODEBLOCK0
Notes:
- -
token is the UniFi API key - Requests use header INLINECODE2
- Scripts resolve the site ID automatically from INLINECODE3
- INLINECODE4 is used for classic read-only endpoints such as
stat/health, stat/alarm, rest/networkconf, and INLINECODE8
Commands
Sites
CODEBLOCK1
List available UniFi sites and their IDs.
Health
CODEBLOCK2
Show a compact summary with device totals, online/offline counts, roles, and client counts.
Devices
CODEBLOCK3
Show UniFi infrastructure devices with model, IP, state, firmware, and feature roles.
Clients
CODEBLOCK4
Show connected clients with type, IP, MAC, connection time, and uplink device ID.
Dashboard
CODEBLOCK5
Show a combined overview including:
- - site and console info
- UniFi version
- health subsystems
- devices
- networks
- WLANs
- top client list
- recent alarms summary
Alerts / alarms
CODEBLOCK6
Show recent UniFi alarms. If none exist, report that there are no recent alarms.
Top apps / DPI
CODEBLOCK7
Show top applications by DPI if the gateway returns DPI data. If not, report that no DPI data is currently available.
Current endpoint coverage
Working endpoints validated on this gateway:
- - INLINECODE9
- INLINECODE10
- INLINECODE11
- INLINECODE12
- INLINECODE13
- INLINECODE14
- INLINECODE15
- INLINECODE16
- INLINECODE17
Caveats:
- - alarms/events may legitimately return zero items
- DPI may return an empty payload even when the endpoint itself is reachable
- some management/config endpoints expose sensitive data; avoid dumping full raw payloads unless explicitly needed
Workflow
When the user asks:
- - "check UniFi" / "dashboard" → run INLINECODE18
- "is everything healthy?" → run INLINECODE19
- "show devices" → run INLINECODE20
- "who is on the network?" / "clients" → run INLINECODE21
- "what sites exist?" → run INLINECODE22
- "any alarms?" / "alerts" → run INLINECODE23
- "top apps" / "traffic" / "DPI" → run INLINECODE24
Always sanity-check the response before reporting back:
- - verify the API returned JSON
- verify counts look reasonable
- if alarms or DPI are empty, say they are empty rather than treating that as an auth or endpoint failure
- avoid pasting sensitive management payloads back to the user unless they explicitly ask for raw details
UniFi 集成 API
通过 UniFi API 密钥使用此技能进行只读的 UniFi 监控。
设置
创建凭证文件:
~/.clawdbot/credentials/unifi/config.json
示例:
json
{
url: https://gateway.local,
token: YOURAPIKEY,
site: default
}
说明:
- - token 是 UniFi API 密钥
- 请求使用标头 X-API-KEY:
- 脚本会自动从 /proxy/network/integration/v1/sites 解析站点 ID
- site 用于传统的只读端点,例如 stat/health、stat/alarm、rest/networkconf 和 rest/wlanconf
命令
站点
bash
bash scripts/sites.sh
bash scripts/sites.sh json
列出可用的 UniFi 站点及其 ID。
健康状态
bash
bash scripts/health.sh
bash scripts/health.sh json
显示包含设备总数、在线/离线数量、角色和客户端数量的紧凑摘要。
设备
bash
bash scripts/devices.sh
bash scripts/devices.sh json
显示 UniFi 基础设施设备,包括型号、IP、状态、固件和功能角色。
客户端
bash
bash scripts/clients.sh
bash scripts/clients.sh json
显示已连接的客户端,包括类型、IP、MAC、连接时间和上行设备 ID。
仪表盘
bash
bash scripts/dashboard.sh
bash scripts/dashboard.sh json
显示综合概览,包括:
- - 站点和控制台信息
- UniFi 版本
- 健康子系统
- 设备
- 网络
- 无线网络
- 热门客户端列表
- 最近警报摘要
警报
bash
bash scripts/alerts.sh
显示最近的 UniFi 警报。如果没有警报,则报告没有最近的警报。
热门应用/DPI
bash
bash scripts/top-apps.sh
bash scripts/top-apps.sh 15
如果网关返回 DPI 数据,则显示按 DPI 排序的热门应用。如果没有,则报告当前没有可用的 DPI 数据。
当前端点覆盖范围
在此网关上已验证可用的端点:
- - /proxy/network/integration/v1/sites
- /proxy/network/integration/v1/sites/{siteId}/devices
- /proxy/network/integration/v1/sites/{siteId}/clients
- /proxy/network/api/s/{site}/stat/health
- /proxy/network/api/s/{site}/stat/sysinfo
- /proxy/network/api/s/{site}/stat/alarm
- /proxy/network/api/s/{site}/stat/sitedpi
- /proxy/network/api/s/{site}/rest/networkconf
- /proxy/network/api/s/{site}/rest/wlanconf
注意事项:
- - 警报/事件可能合法地返回零条项目
- 即使端点本身可访问,DPI 也可能返回空负载
- 某些管理/配置端点会暴露敏感数据;除非明确需要,否则避免转储完整的原始负载
工作流程
当用户询问时:
- - 检查 UniFi / 仪表盘 → 运行 bash scripts/dashboard.sh
- 一切健康吗? → 运行 bash scripts/health.sh
- 显示设备 → 运行 bash scripts/devices.sh
- 谁在网络中? / 客户端 → 运行 bash scripts/clients.sh
- 有哪些站点? → 运行 bash scripts/sites.sh
- 有警报吗? → 运行 bash scripts/alerts.sh
- 热门应用 / 流量 / DPI → 运行 bash scripts/top-apps.sh
在报告之前始终检查响应的合理性:
- - 验证 API 返回了 JSON
- 验证计数看起来合理
- 如果警报或 DPI 为空,则说明它们为空,而不是将其视为认证或端点故障
- 除非用户明确要求原始详细信息,否则避免将敏感的管理负载粘贴回给用户