简介
官方群晖 DSM API 封装,支持 NAS 文件管理、下载任务及系统信息查询,适合家庭用户远程自动化运维。
原始描述
Manage Synology NAS via DSM Web API. Authenticate, browse and manage files (FileStation), manage download tasks (DownloadStation), and query system info. Use...
通过你的 Agent 添加
安装目录:synology-dsm/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Synology DSM Skill 是一套完整的群晖 NAS 管理指南,通过标准化的 DSM Web API 实现与本地 NAS 设备的交互。用户需预先配置 SYNOLOGY_HOST、SYNOLOGY_PORT、SYNOLOGY_USER、SYNOLOGY_PASS 四个环境变量,即可通过 curl 命令完成身份认证、文件管理、下载控制及系统监控等全套操作。
认证流程:所有会话始于登录请求,返回的 session ID(SID)用于后续所有 API 调用的身份验证,会话约 15 分钟无活动后自动过期,支持 2FA 双因素认证。完整工作流包括:登录获取 SID → 执行文件/下载/系统操作 → 登出清理会话。
功能模块:
- FileStation 文件管理:共享文件夹浏览、文件列表查询、创建/重命名/删除目录、文件上传下载、全局搜索
- DownloadStation 下载控制:任务列表查询、URL/种子文件添加下载、暂停/恢复/删除任务、传输速度监控
- 系统信息查询:DSM 版本、硬件型号、内存状态、存储卷信息、网络配置
显著优点
-
官方 API 原生支持:基于 Synology 官方 DSM Web API,非逆向工程,接口稳定性与兼容性有官方保障,支持 DSM 6.x/7.x 全系列版本。
-
零依赖轻量设计:纯文档型 Skill,无第三方库依赖,仅需系统自带的 curl 和 jq 工具即可运行,适合各类精简环境。
-
安全实践完善:强制建议使用 HTTPS(5001 端口),明确禁止硬编码凭据,要求通过环境变量传递敏感信息,内置 2FA 支持及会话超时处理机制。
-
功能覆盖全面:涵盖文件管理的全生命周期操作(CRUD)、下载任务的完整控制链路、系统状态的实时监控,满足家庭及小型企业 NAS 运维需求。
-
错误处理规范:提供完整的错误代码对照表(100-107 通用错误、400-406 认证错误),支持自动化重试与会话恢复逻辑。
潜在缺点与局限性
-
网络环境限制:仅支持局域网或已配置端口转发的场景,无法直接处理外网穿透、DDNS 动态域名等复杂网络拓扑,需用户自行解决网络可达性问题。
-
会话管理开销:15 分钟会话超时机制要求长时间任务中实现自动重认证逻辑,批量操作场景下需额外处理会话续期,增加调用复杂度。
-
无原生异步支持:curl 同步调用模式在处理大文件上传、批量删除等耗时操作时可能阻塞,需结合 method=start 任务模式进行轮询状态管理。
-
权限粒度依赖 DSM 账户:API 权限完全绑定 DSM 用户配置,无法实现更细粒度的 API 密钥或 OAuth 授权,多用户场景下需维护多个账户体系。
-
T3 来源可信度:由个人开发者 eric1932 维护,未关联 GitHub 等公开源码托管平台,长期维护与更新保障存在不确定性。
适合的目标群体
- 家庭 NAS 用户:需要远程管理影音资源、监控下载任务、自动化文件整理的极客用户
- 小型工作室/团队:5-20 人规模,需共享文件存储、协作下载、基础权限管理的轻量级运维场景
- DevOps 学习者:希望理解 RESTful API 设计、会话管理、错误处理模式的初学者实践项目
- 自动化脚本开发者:需要将 NAS 操作集成至 CI/CD 流水线、备份策略、监控告警系统的工程师
常规使用风险
官方 API 原生支持:基于 Synology 官方 DSM Web API,非逆向工程,接口稳定性与兼容性有官方保障,支持 DSM 6.x/7.x 全系列版本。
零依赖轻量设计:纯文档型 Skill,无第三方库依赖,仅需系统自带的 curl 和 jq 工具即可运行,适合各类精简环境。
安全实践完善:强制建议使用 HTTPS(5001 端口),明确禁止硬编码凭据,要求通过环境变量传递敏感信息,内置 2FA 支持及会话超时处理机制。
功能覆盖全面:涵盖文件管理的全生命周期操作(CRUD)、下载任务的完整控制链路、系统状态的实时监控,满足家庭及小型企业 NAS 运维需求。
错误处理规范:提供完整的错误代码对照表(100-107 通用错误、400-406 认证错误),支持自动化重试与会话恢复逻辑。
-
网络环境限制:仅支持局域网或已配置端口转发的场景,无法直接处理外网穿透、DDNS 动态域名等复杂网络拓扑,需用户自行解决网络可达性问题。
-
会话管理开销:15 分钟会话超时机制要求长时间任务中实现自动重认证逻辑,批量操作场景下需额外处理会话续期,增加调用复杂度。
-
无原生异步支持:curl 同步调用模式在处理大文件上传、批量删除等耗时操作时可能阻塞,需结合
method=start任务模式进行轮询状态管理。 -
权限粒度依赖 DSM 账户:API 权限完全绑定 DSM 用户配置,无法实现更细粒度的 API 密钥或 OAuth 授权,多用户场景下需维护多个账户体系。
-
T3 来源可信度:由个人开发者 eric1932 维护,未关联 GitHub 等公开源码托管平台,长期维护与更新保障存在不确定性。
适合的目标群体
- 家庭 NAS 用户:需要远程管理影音资源、监控下载任务、自动化文件整理的极客用户
- 小型工作室/团队:5-20 人规模,需共享文件存储、协作下载、基础权限管理的轻量级运维场景
- DevOps 学习者:希望理解 RESTful API 设计、会话管理、错误处理模式的初学者实践项目
- 自动化脚本开发者:需要将 NAS 操作集成至 CI/CD 流水线、备份策略、监控告警系统的工程师
常规使用风险
操作风险:文件删除、覆盖上传等操作具有不可逆性,文档虽已提示用户确认,但误操作仍可能导致数据丢失。建议生产环境使用前在测试库验证路径参数。
网络安全风险:HTTP(5000 端口)通信存在凭据截获风险,务必优先使用 HTTPS;若必须 HTTP 传输,确保局域网环境可信,避免公共 Wi-Fi 场景。
会话安全风险:SID 泄露将导致未授权访问,避免在日志中打印完整 URL(含 _sid 参数),建议配合反向代理的 IP 白名单机制。
依赖可用性风险:NAS 系统升级可能导致 API 版本变更(如 DSM 7.x 部分 API 版本号调整),需关注 Synology 官方更新日志,及时调整 version 参数。
维护连续性风险:个人开发者维护模式存在更新延迟或停止维护可能,建议关注 ClawHub 平台的版本更新通知,关键业务场景做好技能迁移预案。
技能正文
name: synology-dsm
description: >
Manage Synology NAS via DSM Web API. Authenticate, browse and manage files
(FileStation), manage download tasks (DownloadStation), and query system info.
Use when the user mentions Synology, NAS, DSM, FileStation, DownloadStation,
or wants to interact with their NAS device.
Synology DSM Skill
Interact with a Synology NAS through the DSM Web API using curl.
Prerequisites
The user must have these environment variables set (or provide them inline):
SYNOLOGY_HOST— NAS hostname or IP (e.g.,192.168.1.100)SYNOLOGY_PORT— DSM port (5000for HTTP,5001for HTTPS)SYNOLOGY_USER— DSM usernameSYNOLOGY_PASS— DSM password
Base URL: http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi
Security: Always prefer HTTPS (port 5001). Never hardcode credentials in commands shown to the user — use
$SYNOLOGY_PASSreferences. If the user hasn't set env vars, ask them to provide connection details.
Step 1: Authentication
Every session starts with login. Use format=sid to get a session ID.
Login
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.API.Auth&version=6&method=login\
&account=$SYNOLOGY_USER&passwd=$SYNOLOGY_PASS\
&session=FileStation&format=sid" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.API.Auth&version=6&method=login\
&account=$SYNOLOGY_USER&passwd=$SYNOLOGY_PASS\
&session=FileStation&format=sid" | jq .
Response:
{"data": {"sid": "YOUR_SESSION_ID"}, "success": true}
Save the sid for all subsequent requests: SID=<value from response>
Logout
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.API.Auth&version=6&method=logout\
&session=FileStation&_sid=$SID"
2FA Handling
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.API.Auth&version=6&method=logout\
&session=FileStation&_sid=$SID"
If login returns error code 406, the account has 2FA enabled. Ask the user for their OTP code, then include &otp_code=<CODE> in the login request.
Session Notes
- Sessions timeout after ~15 minutes of inactivity
- If you get error code
106 (session timeout), re-authenticate
- Always logout when done to clean up sessions
Step 2: API Discovery (Optional)
106 (session timeout), re-authenticateQuery all available APIs on the NAS:
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/query.cgi?\
api=SYNO.API.Info&version=1&method=query" | jq .
This returns every API name, path, and supported version range. Useful for checking what packages are installed.
Step 3: FileStation — File Management
All FileStation calls use _sid=$SID for authentication.
List shared folders (root)
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=list_share&_sid=$SID" | jq .
List files in a folder
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=list\
&folder_path=/volume1/homes&additional=size,time&_sid=$SID" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=list_share&_sid=$SID" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=list\
&folder_path=/volume1/homes&additional=size,time&_sid=$SID" | jq .
Parameters: folder_path (required), offset, limit, sort_by (name|size|mtime), sort_direction (asc|desc), additional (size,time,perm,type)
Create folder
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.CreateFolder&version=2&method=create\
&folder_path=/volume1/homes&name=new_folder&_sid=$SID" | jq .
Rename file or folder
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Rename&version=2&method=rename\
&path=/volume1/homes/old_name&name=new_name&_sid=$SID" | jq .
Delete file or folder
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Delete&version=2&method=delete\
&path=/volume1/homes/unwanted_file&_sid=$SID" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.CreateFolder&version=2&method=create\
&folder_path=/volume1/homes&name=new_folder&_sid=$SID" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Rename&version=2&method=rename\
&path=/volume1/homes/old_name&name=new_name&_sid=$SID" | jq .
Delete file or folder
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Delete&version=2&method=delete\
&path=/volume1/homes/unwanted_file&_sid=$SID" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Delete&version=2&method=delete\
&path=/volume1/homes/unwanted_file&_sid=$SID" | jq .
For large deletions, use method=start to get a task ID, then poll with method=status&taskid=<id>.
Upload file
curl -s -X POST \
-F "api=SYNO.FileStation.Upload" \
-F "version=2" \
-F "method=upload" \
-F "path=/volume1/homes" \
-F "overwrite=true" \
-F "file=@/local/path/to/file.txt" \
-F "_sid=$SID" \
"http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi"
Download file
curl -s -o output_file.txt \
"http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Download&version=2&method=download\
&path=/volume1/homes/file.txt&mode=download&_sid=$SID"
Search files
# Start search
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Search&version=2&method=start\
&folder_path=/volume1&pattern=*.pdf&_sid=$SID" | jq .
# Returns taskid
# Get results
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Search&version=2&method=list\
&taskid=<TASK_ID>&_sid=$SID" | jq .
Get file/folder info
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=getinfo\
&path=/volume1/homes/file.txt&additional=size,time&_sid=$SID" | jq .
curl -s -X POST \
-F "api=SYNO.FileStation.Upload" \
-F "version=2" \
-F "method=upload" \
-F "path=/volume1/homes" \
-F "overwrite=true" \
-F "file=@/local/path/to/file.txt" \
-F "_sid=$SID" \
"http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi"
curl -s -o output_file.txt \
"http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Download&version=2&method=download\
&path=/volume1/homes/file.txt&mode=download&_sid=$SID"
Search files
# Start search
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Search&version=2&method=start\
&folder_path=/volume1&pattern=*.pdf&_sid=$SID" | jq .
# Returns taskid
# Get results
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Search&version=2&method=list\
&taskid=<TASK_ID>&_sid=$SID" | jq .
Get file/folder info
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=getinfo\
&path=/volume1/homes/file.txt&additional=size,time&_sid=$SID" | jq .
# Start search
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Search&version=2&method=start\
&folder_path=/volume1&pattern=*.pdf&_sid=$SID" | jq .
# Returns taskid
# Get results
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.Search&version=2&method=list\
&taskid=<TASK_ID>&_sid=$SID" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=getinfo\
&path=/volume1/homes/file.txt&additional=size,time&_sid=$SID" | jq .
For full FileStation API reference, see references/filestation-api.md.
Step 4: DownloadStation — Download Management
Get DownloadStation info
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Info&version=1&method=getinfo&_sid=$SID" | jq .
List all download tasks
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=list\
&additional=transfer&_sid=$SID" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=list\
&additional=transfer&_sid=$SID" | jq .
The additional=transfer parameter includes download/upload speed and progress.
Add download task (URL)
curl -s -X POST \
-d "api=SYNO.DownloadStation.Task&version=1&method=create\
&uri=https://example.com/file.zip&_sid=$SID" \
"http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi"
Add download task (torrent file)
curl -s -X POST \
-F "api=SYNO.DownloadStation.Task" \
-F "version=1" \
-F "method=create" \
-F "file=@/local/path/to/file.torrent" \
-F "_sid=$SID" \
"http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi"
Pause / Resume / Delete tasks
# Pause
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=pause\
&id=<TASK_ID>&_sid=$SID"
# Resume
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=resume\
&id=<TASK_ID>&_sid=$SID"
# Delete (force_complete=false keeps downloaded files)
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=delete\
&id=<TASK_ID>&force_complete=false&_sid=$SID"
curl -s -X POST \
-d "api=SYNO.DownloadStation.Task&version=1&method=create\
&uri=https://example.com/file.zip&_sid=$SID" \
"http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi"
curl -s -X POST \
-F "api=SYNO.DownloadStation.Task" \
-F "version=1" \
-F "method=create" \
-F "file=@/local/path/to/file.torrent" \
-F "_sid=$SID" \
"http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi"
Pause / Resume / Delete tasks
# Pause
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=pause\
&id=<TASK_ID>&_sid=$SID"
# Resume
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=resume\
&id=<TASK_ID>&_sid=$SID"
# Delete (force_complete=false keeps downloaded files)
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=delete\
&id=<TASK_ID>&force_complete=false&_sid=$SID"
# Pause
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=pause\
&id=<TASK_ID>&_sid=$SID"
# Resume
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=resume\
&id=<TASK_ID>&_sid=$SID"
# Delete (force_complete=false keeps downloaded files)
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=delete\
&id=<TASK_ID>&force_complete=false&_sid=$SID"
Multiple task IDs can be comma-separated: &id=task1,task2,task3
For full DownloadStation API reference, see references/downloadstation-api.md.
Step 5: System Info
Get DSM system information
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DSM.Info&version=2&method=getinfo&_sid=$SID" | jq .
Returns: model, RAM, serial, DSM version, uptime, temperature.
Get storage/volume info
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.Storage.CGI.Storage&version=1&method=load_info&_sid=$SID" | jq .
Get network info
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DSM.Network&version=1&method=list&_sid=$SID" | jq .
Error Handling
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.Storage.CGI.Storage&version=1&method=load_info&_sid=$SID" | jq .
curl -s "http://$SYNOLOGY_HOST:$SYNOLOGY_PORT/webapi/entry.cgi?\
api=SYNO.DSM.Network&version=1&method=list&_sid=$SID" | jq .
Error Handling
All API responses follow: {"success": true/false, "data": {...}, "error": {"code": N}}
Common error codes
Code
Meaning
Action
100
Unknown error
Retry once
101
Bad request
Check parameters
102
No such API
Package not installed
103
No such method
Check API version
104
Version not supported
Use lower version
105
No permission
Check user privileges
106
Session timeout
Re-authenticate
107
Session interrupted
Re-authenticate
Auth-specific error codes
Code
Meaning
400
Incorrect password
401
Account disabled
402
Permission denied
406
2FA code required
| Code | Meaning | Action |
|---|---|---|
| 100 | Unknown error | Retry once |
| 101 | Bad request | Check parameters |
| 102 | No such API | Package not installed |
| 103 | No such method | Check API version |
| 104 | Version not supported | Use lower version |
| 105 | No permission | Check user privileges |
| 106 | Session timeout | Re-authenticate |
| 107 | Session interrupted | Re-authenticate |
| Code | Meaning |
|---|---|
| 400 | Incorrect password |
| 401 | Account disabled |
| 402 | Permission denied |
| 406 | 2FA code required |
For full error code reference, see references/error-codes.md.
Workflow Example
A typical session:
- Login and capture SID
- Perform operations (list files, add downloads, etc.)
- Logout when done
Always check "success": true in responses before proceeding. On error 106/107, re-login automatically.
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。