返回顶部
s

synology-dsm群晖DSM

>

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
328
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

synology-dsm

Synology DSM 技能

通过 curl 使用 DSM Web API 与 Synology NAS 交互。

前提条件

用户必须设置以下环境变量(或内联提供):

  • - SYNOLOGYHOST — NAS 主机名或 IP(例如 192.168.1.100)
  • SYNOLOGYPORT — DSM 端口(HTTP 使用 5000,HTTPS 使用 5001)
  • SYNOLOGYUSER — DSM 用户名
  • SYNOLOGYPASS — DSM 密码

基础 URL:http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi

安全:始终优先使用 HTTPS(端口 5001)。切勿在向用户展示的命令中硬编码凭据——应使用 $SYNOLOGY_PASS 引用。如果用户未设置环境变量,请要求他们提供连接详情。

步骤 1:身份验证

每个会话都从登录开始。使用 format=sid 获取会话 ID。

登录

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.API.Auth&version=6&method=login\
&account=$SYNOLOGYUSER&passwd=$SYNOLOGYPASS\
&session=FileStation&format=sid | jq .

响应:
json
{data: {sid: YOURSESSIONID}, success: true}

保存 sid 用于所有后续请求:SID=<响应中的值>

登出

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.API.Auth&version=6&method=logout\
&session=FileStation&_sid=$SID

双因素认证处理

如果登录返回错误代码 406,则表示账户已启用双因素认证。请询问用户其 OTP 验证码,然后在登录请求中包含 &otp_code=

会话说明

  • - 会话在约 15 分钟无活动后超时
  • 如果收到错误代码 106(会话超时),请重新进行身份验证
  • 操作完成后务必登出以清理会话

步骤 2:API 发现(可选)

查询 NAS 上所有可用的 API:

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/query.cgi?\
api=SYNO.API.Info&version=1&method=query | jq .

这将返回每个 API 的名称、路径和支持的版本范围。可用于检查已安装的软件包。

步骤 3:FileStation — 文件管理

所有 FileStation 调用均使用 _sid=$SID 进行身份验证。

列出共享文件夹(根目录)

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=listshare&sid=$SID | jq .

列出文件夹中的文件

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=list\
&folderpath=/volume1/homes&additional=size,time&sid=$SID | jq .

参数:folderpath(必填)、offset、limit、sortby(name|size|mtime)、sort_direction(asc|desc)、additional(size,time,perm,type)

创建文件夹

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.FileStation.CreateFolder&version=2&method=create\
&folderpath=/volume1/homes&name=newfolder&_sid=$SID | jq .

重命名文件或文件夹

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.FileStation.Rename&version=2&method=rename\
&path=/volume1/homes/oldname&name=newname&_sid=$SID | jq .

删除文件或文件夹

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.FileStation.Delete&version=2&method=delete\
&path=/volume1/homes/unwantedfile&sid=$SID | jq .

对于大量删除,使用 method=start 获取任务 ID,然后使用 method=status&taskid= 轮询。

上传文件

bash
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://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi

下载文件

bash
curl -s -o output_file.txt \
http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.FileStation.Download&version=2&method=download\
&path=/volume1/homes/file.txt&mode=download&_sid=$SID

搜索文件

bash

开始搜索


curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.FileStation.Search&version=2&method=start\
&folderpath=/volume1&pattern=*.pdf&sid=$SID | jq .

返回 taskid

获取结果

curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\ api=SYNO.FileStation.Search&version=2&method=list\ &taskid=ID>&sid=$SID | jq .

获取文件/文件夹信息

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.FileStation.List&version=2&method=getinfo\
&path=/volume1/homes/file.txt&additional=size,time&_sid=$SID | jq .

有关完整的 FileStation API 参考,请参阅 references/filestation-api.md

步骤 4:DownloadStation — 下载管理

获取 DownloadStation 信息

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Info&version=1&method=getinfo&_sid=$SID | jq .

列出所有下载任务

bash
curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=list\
&additional=transfer&_sid=$SID | jq .

additional=transfer 参数包含下载/上传速度和进度。

添加下载任务(URL)

bash
curl -s -X POST \
-d api=SYNO.DownloadStation.Task&version=1&method=create\
&uri=https://example.com/file.zip&_sid=$SID \
http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi

添加下载任务(种子文件)

bash
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://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi

暂停/恢复/删除任务

bash

暂停


curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\
api=SYNO.DownloadStation.Task&version=1&method=pause\
&id=ID>&sid=$SID

恢复

curl -s http://$SYNOLOGYHOST:$SYNOLOGYPORT/webapi/entry.cgi?\ api=SYNO.DownloadStation.Task&version=1&method=resume\ &id=ID>&sid=$SID

删除(force_complete=false 保留已下载的文件)

curl -

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 synology-dsm-1776206736 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 synology-dsm-1776206736 技能

通过命令行安装

skillhub install synology-dsm-1776206736

下载

⬇ 下载 synology-dsm v1.0.0(免费)

文件大小: 7.4 KB | 发布时间: 2026-4-15 13:37

v1.0.0 最新 2026-4-15 13:37
Initial release of the Synology DSM skill.

- Enables management of Synology NAS devices via DSM Web API.
- Supports authentication (including 2FA), file browsing and management through FileStation, and download task control via DownloadStation.
- Allows querying of system, storage, and network info.
- Provides guidance for common error handling and session management.
- Usage requires user-supplied DSM credentials and environment variables.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部