Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/synoPublic

Simple Node.js wrapper and CLI for Synology DSM REST API 5.x and 6.x.

License

NotificationsYou must be signed in to change notification settings

kwent/syno

Repository files navigation

Simple Node.js wrapper (browser included) and CLI for Synology DSM REST API 5.x and 6.x.

Built with GruntBuild Statusnpm versionDependency StatusdevDependency StatusSynology Development Tool

SeeSynology Development Tool.

Maintainers wanted

  • [2024-08-11] Some priorities shifted in my life and i'm now looking for new maintainers.

Installation

Just install the module using npm.

$ npm install syno

If you want to save it as a dependency, just add the--save option.

$ npm install syno --save

If you want to install with theCLI executable, just add the--global option.

$ npm install syno --global

Syno API

This is a simple presentation of the syno API and its methods.To get more information (parameters, response data, ...) refer to the Synology Developer Toolpage.

  • DSM API
  • File Station API
  • Download Station API
  • Audio Station API
  • Video Station API
  • Video Station DTV API
  • Surveillance Station API

Javascript wrapper

varSyno=require('syno');varsyno=newSyno({// Requests protocol : 'http' or 'https' (default: http)protocol:'https',// DSM host : ip, domain name (default: localhost)host:'localhost',// DSM port : port number (default: 5000)port:'5001',// DSM User account (required)account:'my_username',// DSM User password (required)passwd:'my_password',// DSM API version (optional, default: 6.0.2)apiVersion:'6.0.2'});

This is how to use an API on thesyno object

syno.api.method(params,callback);

All arguments are optional by default :

  • params : object hash with request parameters
  • callback : function called with 2 arguments (error,data)

Thedata arguments passed to the callback is an object hash, holding the response data. (see API documents)

Both theparams andcallback are optional, so you can call any method these ways :

// Both params and callbacksyno.api.method(params,callback);// Only params parametersyno.api.method(params);// Only callback parametersyno.api.method(callback);// No parametersyno.api.method();

N.B : If theparams parameter is not passed, but the method expectsrequired parameters, anError will bethrown.

Examples

// DSM API - Provide DSM informationsyno.dsm.getInfo(callback);// File Station API - Provide File Station informationsyno.fs.getInfo(callback);// File Station API - Enumerate files in a given foldersyno.fs.list({'folder_path':'/path/to/folder'},callback);// Download Station API - List download taskssyno.dl.listFiles({'limit':5,'offset':10},callback);// Download Station API - Create a download tasksyno.dl.createTask({'uri':'https://link'},callback);// Audio Station API - Search a songsyno.as.searchSong({'title':'my_title_song'},callback);// Video Station API - List moviessyno.vs.listMovies({'limit':5},callback);// Video Station DTV API - List channelssyno.dtv.listChannels({'limit':5},callback);// Surveillance Station API - Get camera informationsyno.ss.getInfoCamera({'cameraIds':4},callback);

CLI

$ syno --helpUsage: syno [options]  Synology Rest API Command Line  Options:    -h, --help                       output usage information    -V, --version                    output the version number    -c, --config <path>              DSM Configuration file. Default to ~/.syno/config.yaml    -u, --url <url>                  DSM URL. Default to https://admin:password@localhost:5001    -d, --debug                      Enabling Debugging Output    -a, --api <version>              DSM API Version. Default to 6.0.2    -i, --ignore-certificate-errors  Ignore certificate errors  Commands:    diskstationmanager|dsm [options] <method> DSM API    filestation|fs [options] <method> DSM File Station API    downloadstation|dl [options] <method> DSM Download Station API    audiostation|as [options] <method> DSM Audio Station API    videostation|vs [options] <method> DSM Video Station API    videostationdtv|dtv [options] <method> DSM Video Station DTV API    surveillancestation|ss [options] <method> DSM Surveillance Station API  Examples:    $ syno diskstationmanager|dsm getInfo    $ syno filestation|fs getInfo    $ syno downloadstation|dl getInfo    $ syno audiostation|as getInfo    $ syno videostation|vs getInfo    $ syno videostationdtv|dtv listChannels --payload '{"limit":5}' --pretty    $ syno surveillancestation|ss getInfo

Examples

# DSM API - Provide DSM information$ syno dsm getInfo --pretty# File Station API - Provide File Station information$ syno fs getInfo --pretty# File Station API - Enumerate files in a given folder$ syno fs listFiles --payload'{"folder_path":"/path/to/folder"}' --pretty# Download Station API - List download tasks$ syno dl listTasks --payload'{"limit":5, "offset":10}' --pretty# Download Station API - Create a download task$ syno dl createTask --payload'{"uri":"https://link"}'# Audio Station API - Search a song$ syno as searchSong --payload'{"title":"my_title_song"}' --pretty# Video Station API - List movies$ syno vs listMovies --payload'{"limit":5}' --pretty# Video Station DTV API - List channels$ syno dtv listChannels --payload'{"limit":5}' --pretty# Surveillance Station API - Get camera information$ syno ss getInfoCamera --payload'{"cameraIds":4}' --pretty

CLI Authentication

Via environment variables

export SYNO_ACCOUNT=userexport SYNO_PASSWORD=passwordexport SYNO_PROTOCOL=httpsexport SYNO_HOST=localhostexport SYNO_PORT=5001

Without a configuration file

$ syno fs getInfo --url https://user:password@localhost:5001 --pretty

With a configuration file

# Example config file, by default it should be located at:# ~/.syno/config.yamlurl:protocol:httpshost:localhostport:5001account:adminpasswd:password
$ syno fs getInfo --pretty

More usageexamples in thewiki.

Browser

Note

Be sure to disablesame-origin policy in your browser.

Example

<html><head><scriptsrc="syno-6.x.min.js"></script><scripttype="text/javascript">varSyno=require('syno.Syno');varsyno=newSyno({// Requests protocol : 'http' or 'https' (default: http)protocol:'https',// DSM host : ip, domain name (default: localhost)host:'localhost',// DSM port : port number (default: 5000)port:'5001',// DSM User account (required)account:'my_username',// DSM User password (required)passwd:'my_password'});syno.fs.getInfo(function(error,data){console.log(data)});</script></head><html>

Demo

A demo is availableonline or in thetest/browser folder.

Migrating from 1.0.x to 2.x

Breaking changes

  • Some method names might have change. For example (getFileStationInfo togetInfo)
  • Optional and required parameters are not checked before sending the request anymore.

Tips & Tricks

If you meet this error when using anhttps connection:

[ERROR]: Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE

You will need to tellrequest to ignore certificate errors:

CLI:

syno as getInfo --ignore-certificate-errors

or

export SYNO_IGNORE_CERTIFICATE_ERRORS=0

Code:

varsyno=newSyno({ignoreCertificateErrors:false// Other options// ...});

History

View thechangelog

Authors

License

Copyright (c) 2016 Quentin Rousseau <contact@quent.in>Permission is hereby granted, free of charge, to any personobtaining a copy of this software and associated documentationfiles (the "Software"), to deal in the Software withoutrestriction, including without limitation the rights to use,copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom theSoftware is furnished to do so, subject to the followingconditions:The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIESOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE ANDNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHTHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OROTHER DEALINGS IN THE SOFTWARE.

[8]ページ先頭

©2009-2025 Movatter.jp