群晖 PhotoStation API 资料和代码

群晖的NAS一直口碑都不错,主要是安全性和功能都比较完善,可玩性比较高。最近在学Python,就想着拿PhotoStation的API来练练手,看看能不能捣鼓出一些新的功能来。

结果上网这么一查,没想到群晖竟然没有提供官方的API文档(倒是提供了File Station API Guide)真是让人大跌眼镜,是担心被玩坏呢还是怎么想。好不容易从其他地方找到了一些资料,这里给大家做下分享,也是抛砖引玉,如果有人找到官方的API,也请留言,多谢。

1、API接口

接口API主要由以下5个基本要素组成

  • API name: Name of the API requested
  • version: Version of the API requested
  • path: path of the API. The path information can be retrieved by requesting SYNO.API.Info
  • method: Method of the API requested
  • _sid: Authorized session ID. Each API request should pass it, which is retrieved from the
    response of /webapi/auth.cgi, via either HTTP/HTTPS GET/POST method with “_sid”
    argument. Otherwise, if you pass it within “id” value of cookie of HTTP/HTTPS header, this
    parameter can be ignored.

语法

GET /webapi/?api=&version=&method=[&][&_sid=]

例子

http://myds.com:port/webapi/query.cgi?api=SYNO.API.Info&version=1&method=query&query=all

API name: SYNO.API.Info
version: 1
path: query.cgi
method: query
params: query=all

调用步骤


API Workflow

PhotoStation API 列表

{
        "SYNO.PhotoStation.Auth": {
                "path": "auth.php",
                "minVersion": 1,
                "maxVersion": 1,
                "methods": {
                        "1": ["login", "logout", "checkauth"]
                }
        },
        "SYNO.PhotoStation.Info": {
                "path": "info.php",
                "minVersion": 1,
                "maxVersion": 1,
                "methods": {
                        "1": ["getinfo"]
                }
        },
        "SYNO.PhotoStation.Album": {
                "path": "album.php",
                "minVersion": 1,
                "maxVersion": 1,
                "methods": {
                        "1": ["list", "getinfo", "create", "edit", "delete", "arrangeitem", "move", "cleararrangeitem", "cancel"]
                }
        },
        "SYNO.PhotoStation.Permission": {
                "path": "permission.php",
                "minVersion": 1,
                "maxVersion": 1,
                "methods": {
                        "1": ["getalbum", "editalbum", "editgroup", "list_public_share", "edit_public_share"]
                }
        },
    "SYNO.PhotoStation.Photo": {
        "path": "photo.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "listexif", "listfeatureditem", "listgpsgroup", "listgpsgroupeditem", "getinfo", "getexif", "edit", "delete", "copy", "cancel"]
        }
    },
    "SYNO.PhotoStation.Thumb": {
        "path": "thumb.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["get", "get_dsm_thumb"]
        }
    },
        "SYNO.PhotoStation.Cover": {
        "path": "cover.php",
        "minVersion": 1,
        "maxVersion": 2,
        "methods": {
            "1": ["set"],
            "2": ["set","setsmart"]
        }
    },
        "SYNO.PhotoStation.SmartAlbum": {
        "path": "smart_album.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "getinfo", "create", "edit", "delete"]
        }
    },
    "SYNO.PhotoStation.File": {
        "path": "file.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["uploadphoto", "uploadvideo"]
        }
    },
    "SYNO.PhotoStation.Download": {
        "path": "download.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["getphoto", "getvideo", "getitem"]
        }
    },
        "SYNO.PhotoStation.Category": {
                "path": "category.php",
                "minVersion": 1,
                "maxVersion": 1,
                "methods": {
                        "1": ["list", "getinfo", "create", "edit", "delete", "arrangecategory", "listitem", "additem", "removeitem", "arrangeitem"]
                }
        },
    "SYNO.PhotoStation.About": {
        "path": "about.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["get", "set", "set_visibility"]
        }
    },
    "SYNO.PhotoStation.Tag": {
        "path": "tag.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "getinfo", "create", "edit", "delete", "searchplace", "delete_unconfirmed_tag"]
        }
    },
    "SYNO.PhotoStation.PhotoTag": {
        "path": "photo_tag.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "people_tag", "geo_tag", "desc_tag", "delete", "people_tag_confirm"]
        }
    },
    "SYNO.PhotoStation.Comment": {
        "path": "comment.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "create", "delete"]
        }
    },
    "SYNO.PhotoStation.Timeline": {
        "path": "timeline.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["getindex"]
        }
    },
    "SYNO.PhotoStation.Group": {
        "path": "group.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "get", "get_dsm_group", "getmember", "create", "edit", "editmember", "delete"]
        }
    },
        "SYNO.PhotoStation.Rotate": {
                "path": "rotate.php",
                "minVersion": 1,
                "maxVersion": 1,
                "methods": {
                        "1": ["set"]
                }
        },
    "SYNO.PhotoStation.SlideshowMusic": {
        "path": "slideshow_music.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "get", "add", "edit", "delete"]
        }
    },
    "SYNO.PhotoStation.DsmShare": {
        "path": "dsm_share.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "copy", "copymusic"]
        }
    },
    "SYNO.PhotoStation.SharedAlbum": {
        "path": "shared_album.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "getinfo", "getinfo_public", "create", "edit", "delete", "add_items", "remove_items", "edit_public_share", "get_single_item", "set_single_item"]
        }
    },
    "SYNO.PhotoStation.PhotoLog": {
        "path": "log.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list", "clear", "export"]
        }
    },
    "SYNO.PhotoStation.Path": {
        "path": "path.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["getpath", "checkpath"]
        }
    },
    "SYNO.PhotoStation.Watermark": {
        "path": "watermark.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["getshare", "listshare", "upload", "copy", "delete", "remove"]
        }
    },
    "SYNO.PhotoStation.Public": {
        "path": "public.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["list"]
        }
    },
    "SYNO.PhotoStation.Migration": {
        "path": "migration.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["export_blog"]
        }
    },
    "SYNO.PhotoStation.ACL": {
        "path": "acl.php",
        "minVersion": 1,
        "maxVersion": 1,
        "methods": {
            "1": ["get", "set"]
        }
    }
}
2、开源Python 项目(一个芬兰人写的)

https://github.com/skarppi/python-photostation
https://pypi.org/project/photostation/
用法也很简单,不过作者实现的功能也不多,主要就是对照片的元数据进行修改之类。
具体就不多说了,大家可以上github上下代码看看

3、API 可以用来做什么
  • 给照片或者视频批量打标签、评分、修改日期等等
  • 批量上传图片和视频
  • 其他还可以做什么,需要开下脑洞
4、参考资料

论坛
官方文档下载地址

你可能感兴趣的:(群晖 PhotoStation API 资料和代码)