Git Product home page Git Product logo

syno's Introduction

Syno

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

Built with Grunt Build Status npm version Dependency Status devDependency Status Synology Development Tool

See Synology Development Tool.

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 the CLI 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 Tool page.

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

Javascript wrapper

var Syno = require('syno');
var syno = new Syno({
    // 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 the syno 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)

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

Both the params and callback are optional, so you can call any method these ways :

// Both params and callback
syno.api.method(params, callback);
// Only params parameter
syno.api.method(params);
// Only callback parameter
syno.api.method(callback);
// No parameter
syno.api.method();

N.B : If the params parameter is not passed, but the method expects required parameters, an Error will be thrown.

Examples

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

CLI

$ syno --help
Usage: 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=user
export SYNO_PASSWORD=password
export SYNO_PROTOCOL=https
export SYNO_HOST=localhost
export 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.yaml

url:
  protocol: https
  host: localhost
  port: 5001
  account: admin
  passwd: password
$ syno fs getInfo --pretty

More usage examples in the wiki.

Browser

Note

Be sure to disable same-origin policy in your browser.

Example

<html>
  <head>
  <script src="syno-6.x.min.js"></script>
  <script type="text/javascript">
  var Syno = require('syno.Syno');
  var syno = new Syno({
      // 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 available online or in the test/browser folder.

Migrating from 1.0.x to 2.x

Breaking changes

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

Tips & Tricks

If you meet this error when using an https connection:

[ERROR] : Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE

You will need to tell request to ignore certificate errors:

CLI:

syno as getInfo --ignore-certificate-errors

or

export SYNO_IGNORE_CERTIFICATE_ERRORS=0

Code:

var syno = new Syno({
    ignoreCertificateErrors: false
    // Other options
    // ...
});

History

View the changelog

Authors

License

Copyright (c) 2016 Quentin Rousseau <[email protected]>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included 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 WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

syno's People

Contributors

1deadpixl avatar celevra avatar dependabot[bot] avatar kwent avatar noplanman avatar shir avatar weshouman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

syno's Issues

[ERROR] : Error: Unknown error

Hi. Thanks for tool. But have some Unknown error when trying to get list of tasks from download station:

$ ./node_modules/.bin/syno --url http://USER:[email protected]:5000 --debug dl getTaskList
[DEBUG] : Params URL detected : http://USER:[email protected]:5000.
[DEBUG] : DSM Connection URL configured : http://USER:[email protected]:5000
[DEBUG] : Account: USER
[DEBUG] : Password: PASSWORD
[DEBUG] : Host: 192.168.0.37
[DEBUG] : Port: 5000
[DEBUG] : API: 6.0
[DEBUG] : Ignore certificate errors: false
[DEBUG] : DSM Download Station API command selected
[DEBUG] : Method name configured : getTaskList
REQUEST { rejectUnauthorized: true,
  jar: true,
  json: true,
  url: 'http://192.168.0.37:5000/webapi/auth.cgi',
  qs: 
   { api: 'SYNO.API.Auth',
     version: 3,
     method: 'login',
     account: 'USER',
     passwd: 'PASSWORD',
     session: 'SYNO_SESSION_1478032259136' },
  callback: [Function] }
REQUEST make request http://192.168.0.37:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account= USER&passwd= PASSWORD&session=SYNO_SESSION_1478032259136
REQUEST onRequestResponse http://192.168.0.37:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account= USER&passwd= PASSWORD&session=SYNO_SESSION_1478032259136 200 { server: 'nginx',
  date: 'Tue, 01 Nov 2016 20:20:37 GMT',
  'content-type': 'text/plain; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
  'set-cookie': [ 'id=wO12pG8X3GfQQ1470M4N227000;expires=Tue, 08-Nov-2016 20:20:37 GMT;path=/' ] }
REQUEST reading response's body
REQUEST finish init function http://192.168.0.37:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account= USER&passwd= PASSWORD&session=SYNO_SESSION_1478032259136
REQUEST response end http://192.168.0.37:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account= USER&passwd= PASSWORD&session=SYNO_SESSION_1478032259136 200 { server: 'nginx',
  date: 'Tue, 01 Nov 2016 20:20:37 GMT',
  'content-type': 'text/plain; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
  'set-cookie': [ 'id=wO12pG8X3GfQQ1470M4N227000;expires=Tue, 08-Nov-2016 20:20:37 GMT;path=/' ] }
REQUEST end event http://192.168.0.37:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account= USER&passwd= PASSWORD&session=SYNO_SESSION_1478032259136
REQUEST has body http://192.168.0.37:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account= USER&passwd= PASSWORD&session=SYNO_SESSION_1478032259136 61
REQUEST emitting complete http://192.168.0.37:5000/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account= USER&passwd= PASSWORD&session=SYNO_SESSION_1478032259136
REQUEST { rejectUnauthorized: true,
  jar: true,
  json: true,
  url: 'http://192.168.0.37:5000/webapi/entry.cgi',
  qs: 
   { api: 'SYNO.DownloadStation2.Task.List',
     version: '1',
     method: 'get' },
  callback: [Function] }
REQUEST make request http://192.168.0.37:5000/webapi/entry.cgi?api=SYNO.DownloadStation2.Task.List&version=1&method=get
REQUEST onRequestResponse http://192.168.0.37:5000/webapi/entry.cgi?api=SYNO.DownloadStation2.Task.List&version=1&method=get 200 { server: 'nginx',
  date: 'Tue, 01 Nov 2016 20:20:38 GMT',
  'content-type': 'application/json; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
  pragma: 'no-cache',
  expires: '0' }
REQUEST reading response's body
REQUEST finish init function http://192.168.0.37:5000/webapi/entry.cgi?api=SYNO.DownloadStation2.Task.List&version=1&method=get
REQUEST response end http://192.168.0.37:5000/webapi/entry.cgi?api=SYNO.DownloadStation2.Task.List&version=1&method=get 200 { server: 'nginx',
  date: 'Tue, 01 Nov 2016 20:20:38 GMT',
  'content-type': 'application/json; charset="UTF-8"',
  'transfer-encoding': 'chunked',
  connection: 'close',
  vary: 'Accept-Encoding',
  'x-content-type-options': 'nosniff',
  'x-xss-protection': '1; mode=block',
  'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
  pragma: 'no-cache',
  expires: '0' }
REQUEST end event http://192.168.0.37:5000/webapi/entry.cgi?api=SYNO.DownloadStation2.Task.List&version=1&method=get
REQUEST has body http://192.168.0.37:5000/webapi/entry.cgi?api=SYNO.DownloadStation2.Task.List&version=1&method=get 86
REQUEST emitting complete http://192.168.0.37:5000/webapi/entry.cgi?api=SYNO.DownloadStation2.Task.List&version=1&method=get
[ERROR] : Error: Unknown error
REQUEST { rejectUnauthorized: true,
  jar: true,
  json: true,
  url: 'http://192.168.0.37:5000/webapi/auth.cgi',
  qs: 
   { api: 'SYNO.API.Auth',
     version: 3,
     method: 'logout',
     session: 'SYNO_SESSION_1478032259136' },
  callback: [Function] }

I have same error if try to make listFiles. The only method I get to work is getInfo.

Just have an idea: could it be related to node.js 7?

Unexpected token ' in JSON at position 0

Ran into this problem when creating a bash script.
#!/bin/sh
echo --- Getting link ---
link=123
echo --- Link aquired ---

SURI="'{"'"uri"'":"'"'"$link"'"'"}'"
echo PhasedURI "$SURI"

syno dl createTask --payload "$SURI"

[ERROR] : JSON Exception : SyntaxError: Unexpected token ' in JSON at position 0
at JSON.parse ()
at execute (/usr/local/lib/node_modules/syno/bin/syno.js:49:20)
at Command. (/usr/local/lib/node_modules/syno/bin/syno.js:292:10)
at Command.listener (/usr/local/lib/node_modules/syno/node_modules/commander/index.js:370:29)
at Command.emit (node:events:513:28)
at Command.parseArgs (/usr/local/lib/node_modules/syno/node_modules/commander/index.js:892:12)
at Command.parse (/usr/local/lib/node_modules/syno/node_modules/commander/index.js:642:21)
at Object. (/usr/local/lib/node_modules/syno/bin/syno.js:353:9)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)

Unable to get storage using [list_share]

I tried to retrive volume status using this command, but I got empty output:

syno.dsm.listShares({
     additional : "volume_status"
   }, function(error, data) {
    console.log(data)  ;
  });

{ shares: [], total: 0 }

Using the listShares without parameter I got this output:
{ shares: [ { desc: '', is_usb_share: false, name: 'Backup', uuid: 'bd2be816-11f7-4c70-a78f-239bd8971239', vol_path: '/volume1' }, { desc: 'user home', is_usb_share: false, name: 'homes', uuid: '62e4370c-cf28-4320-8076-1430a8d5d97e', vol_path: '/volume1' }, { desc: '', is_usb_share: false, name: 'Moreno', uuid: '7b10e336-1f52-4256-bc6b-2f54650da33f', vol_path: '/volume1' }, { desc: 'NAKIVO Repository', is_usb_share: false, name: 'NAKIVO_Repository', uuid: 'a4f76933-0aec-4221-82c1-78cf0f609af5', vol_path: '/volume1' }, { desc: 'System default shared folder', is_usb_share: false, name: 'web', uuid: '16fe6bd7-1610-477b-b4de-8bbf607228d8', vol_path: '/volume1' } ], total: 5 }

From the API documentation:

additional parameter is optional and when additional option is requested, responded objects will be provided in the specified addiontal option.

So what is the problem?

Support for Quickconnect; Wait for redirect

It would be awesome if the library supports quickconnect (QC). The problem mainly is that quickconnect first attempts to redirect to the "correct" url.

When making a request e.g. via CLI, the "Connecting..." page gets parsed by syno.js instead of the actual JSON data. Thus, there will be several exceptions while parsing the response.

Maybe it could wait for redirects before parsing the final response data? (https://stackoverflow.com/questions/7323932/how-do-you-follow-an-http-redirect-in-node-js)

[Q] CLI JSON Payload

When i run:

syno dsm --ignore-certificate-errors --pretty getUser

From where i know what payload i must add?

error

I get this error:

syno fs getFileStationInfo --pretty
/usr/lib/node_modules/syno/dist/syno.js:78
                        code = body.error ? body.error.code : body.data[0].error;
                                                                       ^

TypeError: Cannot read property '0' of undefined
    at Request._callback (/usr/lib/node_modules/syno/dist/syno.js:78:72)
    at Request.self.callback (/usr/lib/node_modules/syno/node_modules/request/request.js:199:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/lib/node_modules/syno/node_modules/request/request.js:1036:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/lib/node_modules/syno/node_modules/request/request.js:963:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)

The password is correct with above message. I tested by trying with a wrong password and got:
syno fs getFileStationInfo --pretty [ERROR] : Error: Permission denied

I am running DSM 6.0-7307 / this is the current release candidate of DSM 6.0.

Video station api documentation seems outdated for new video station version

I'm using the latest video station version.

  • In listMovies, library_id is now a required parameter.
  • getMovieInfo does not exist anymore, it should be getInfoMovie, which I can't get to work (can't figure out which parameters are needed besides id because it simply returns null).
  • the callback function seems to need 2 parameters, only the second is filled with data, the first is unclear what it is for?

how to call surveillance Station Face Result API

Hi,

how to run this API Call:

GET /webapi/entry.cgi?
api="SYNO.SurveillanceStation.Face.Result"&version="1"&method="List"&blIncludeSnapshot=false&blInclu
deRegisteredFace=false&filter={"start_date_ts":1593446400000,
"end_date_ts":1594051200000,"ignore_bad_quality":true}&limit=1&&slaveDsParam={"0":
{"max_id":88731, "start":0}}

described here on Page 540 https://global.download.synology.com/download/Document/Software/DeveloperGuide/Package/SurveillanceStation/All/enu/Surveillance_Station_Web_API.pdf

thried this:

syno.ss.Face.Result({'method':'List','blIncludeSnapshot': true, 'blIncludeRegisteredFace': true}, function(err,res){
    console.log(res)
});

with this result:

/node/faces.js:22
syno.ss.Face.Result({'method':'List','blIncludeSnapshot': true, 'blIncludeRegisteredFace': true}, function(err,res){
             ^

TypeError: Cannot read property 'Result' of undefined
    at Object.<anonymous> (/node/faces.js:22:14)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

How to control the version in the request?

First of all - thanks for implementing - that saved me a lot of work and its usage is really straight forward.

But I do have a question about the control of the request version (not that of the API). I am trying to enable/disable a camera based on an event. I know that the surveillance api has the possibility to since v3 (based on your _full.json)

By default it looks to me that it is always using v1 - because of this:
version = 'minVersion' in definitions[api] ? definitions[api].minVersion : 1;

So I changed the min version to 8, which actually helps me with this problem but opens up another one :) getInfoCamera changed its response data between those versions 1 and 8.

So what I am trying is to control the version on each request. So that I can go with v1 on getInfoCamera and with v8 on enableCamera/disableCamera.

Is that possible?
And what is the recommended way to enable a specific version - I don't think changing the minor version in the _full.json is the recommended one ;-)

Thanks and have a happy new year!
m.

Audiostation Play Song

Is it possible to play a song through AudioStation selecting a specified RemotePlayer?

I can correctly view the remote player via syno as listRemotePlayers, but i can't find a way to play a selected song on the remotePlayer.

Thanks in advance.

Any example for file upload?

I'm trying to use DownloadStation createTask method but can't manage how to send file. Do you have any example? Is it supported?

Error: The requested API does not exist

I'm on dsm 5.2 and this is what I got after installing this module and trying a sample command:

DiskStation> syno -d fs getInfo --pretty
[DEBUG] : DSM Connection URL configured : http://USERNAME:PASSWORD@localhost:5000
[DEBUG] : Account: USERNAME
[DEBUG] : Password: PASSWORD
[DEBUG] : Host: localhost
[DEBUG] : Port: 5000
[DEBUG] : API: 6.0
[DEBUG] : Ignore certificate errors: false
[DEBUG] : DSM File Station API command selected
[DEBUG] : Method name configured : getInfo
[DEBUG] : Prettify output detected
REQUEST { rejectUnauthorized: true,
jar: true,
json: true,
url: 'http://localhost:5000/webapi/auth.cgi',
qs:
{ api: 'SYNO.API.Auth',
version: 3,
method: 'login',
account: 'USERNAME',
passwd: 'PASSWORD',
session: 'SYNO_SESSION_1471955298784' },
callback: [Function] }
REQUEST make request http://localhost:5000/webapi/auth.cgi?a ... 1955298784
REQUEST onRequestResponse http://localhost:5000/webapi/auth.cgi?a ... 1955298784 200 { date: 'Tue, 23 Aug 2016 12:28:19 GMT',
server: 'Apache',
p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
'set-cookie': [ 'id=UJm9Wo9HHDOX61490LAN880506;expires=Thu, 22-Sep-2016 12:28:20 GMT;path=/' ],
vary: 'Accept-Encoding',
connection: 'close',
'transfer-encoding': 'chunked',
'content-type': 'text/plain; charset="UTF-8"' }
REQUEST reading response's body
REQUEST finish init function http://localhost:5000/webapi/auth.cgi?a ... 1955298784
REQUEST response end http://localhost:5000/webapi/auth.cgi?a ... 1955298784 200 { date: 'Tue, 23 Aug 2016 12:28:19 GMT',
server: 'Apache',
p3p: 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"',
'set-cookie': [ 'id=UJm9Wo9HHDOX61490LAN880506;expires=Thu, 22-Sep-2016 12:28:20 GMT;path=/' ],
vary: 'Accept-Encoding',
connection: 'close',
'transfer-encoding': 'chunked',
'content-type': 'text/plain; charset="UTF-8"' }
REQUEST end event http://localhost:5000/webapi/auth.cgi?a ... 1955298784
REQUEST has body http://localhost:5000/webapi/auth.cgi?a ... 1955298784 61
REQUEST emitting complete http://localhost:5000/webapi/auth.cgi?a ... 1955298784
REQUEST { rejectUnauthorized: true,
jar: true,
json: true,
url: 'http://localhost:5000/webapi/entry.cgi',
qs: { api: 'SYNO.FileStation.Info', version: '1', method: 'get' },
callback: [Function] }
REQUEST make request http://localhost:5000/webapi/entry.cgi? ... method=get
REQUEST onRequestResponse http://localhost:5000/webapi/entry.cgi? ... method=get 200 { date: 'Tue, 23 Aug 2016 12:28:20 GMT',
server: 'Apache',
'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
pragma: 'no-cache',
expires: '0',
connection: 'close',
'transfer-encoding': 'chunked',
'content-type': 'application/json; charset="UTF-8"' }
REQUEST reading response's body
REQUEST finish init function http://localhost:5000/webapi/entry.cgi? ... method=get
REQUEST response end http://localhost:5000/webapi/entry.cgi? ... method=get 200 { date: 'Tue, 23 Aug 2016 12:28:20 GMT',
server: 'Apache',
'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
pragma: 'no-cache',
expires: '0',
connection: 'close',
'transfer-encoding': 'chunked',
'content-type': 'application/json; charset="UTF-8"' }
REQUEST end event http://localhost:5000/webapi/entry.cgi? ... method=get
REQUEST has body http://localhost:5000/webapi/entry.cgi? ... method=get 38
REQUEST emitting complete http://localhost:5000/webapi/entry.cgi? ... method=get
[ERROR] : Error: The requested API does not exist
REQUEST { rejectUnauthorized: true,
jar: true,
json: true,
url: 'http://localhost:5000/webapi/auth.cgi',
qs:
{ api: 'SYNO.API.Auth',
version: 3,
method: 'logout',
session: 'SYNO_SESSION_1471955298784' },
callback: [Function] }

Upgrade Plan

Are you planing on upgrading the package to fix the api-changes that where made with dsm 6 release?

Typings?

I was wondering whether there are any Typescript typings for syno.

Some command incompatible with DSM 6.1.1

$ syno dsm listStorageDisks result to Error: No parameter of API, method or version

All related to storage APIs will result to the same error message.

With listStorageDisks command and also turn on --debug flag, it's appears to use api=SYNO.Core.Storage.Disk&method=list&version=1 to query data, but DSM 6.1.1 changed to use api=SYNO.Storage.CGI.Storage&method=load_info&version=1 and combine all of storages information, aka. iSCSI LUN, Volumes, etc..

Skip authentication if not needed

Hello!
I was wondering if it's possible to prevent users to type their usernames and passwords each time.
Is it possible, for example, to use the session cookies or sessionId set by the DSM to automatically sign in the last user?

Thank you!

Auth API returns `Error: Permission denied` for non-administrator accounts

The following applies to DSM 6.0.2-8451 Update 4, I don't have any other versions to test.

The authentication API returns {"error":{"code":402},"success":false} for non-administrator accounts.

To authenticate a non-administrator account, the session parameter must be set to the desired application's name.
However, I can log with one application, then use another one without having to reauthenticate.
Even better, I can log with an application for which I don't have permission, then use an application for which I do.

For example, even if the user is explicitely denied access to AudioStation, I can log with
/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=login&account=user&passwd=password&session=AudioStation

Then list the files in my home folder:
syno.fs.list({'folder_path':'/home'}, callback);

But trying use AudioStation's API, which I don't have access to, gets you a Error 115: The logged in session does not have permission.

Possible fix

For now, I changed session = 'SYNO_SESSION_' + Date.now() to session = 'FileStation' in Auth.login since the FileStation application can't seems to be turned off or removed (easily).

Not pretty but seems to be the simplest solution.

HTTP Code 402

Hello,

I've make a quick try of the library but get a 402 error:

var Syno = require('./dist/syno');
var syno = new Syno({
    // Requests protocol : 'http' or 'https' (default: http)
    protocol: 'http',
    // DSM host : ip, domain name (default: localhost)
    host: 'my_synology',
    // DSM port : port number (default: 5000)
    port: '5000',
    // DSM User account (required)
    account: 'yyy',
    // DSM User password (required)
    passwd: 'xxx'
});

syno.as.listAlbums(function(data){
    console.log(data);
});

The result is:

/usr/local/Cellar/node/0.10.22/bin/node test_syno.js
{ [Error: Permission denied] code: 402 }

[Error: The logged in session does not have permission] code: 105

Receiving 105 error code even when using the admin account.

var Syno = require('syno');

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

var syno = new Syno({
    // Requests protocol : 'http' or 'https' (default: http)
    protocol: 'https',
    // DSM host : ip, domain name (default: localhost)
    host: '192.168.119.203',
    // DSM port : port number (default: 5000)
    port: '5001',
    // DSM User account (required)
    account: 'admin',
    // DSM User password (required)
    passwd: 'password'
});

function callback() {
    console.log(arguments);
}

// File Station API - Provide File Station information
syno.fs.getFileStationInfo(callback);

// The above API call returns:
//{ '0': null,
//      '1':
//  { hostname: 'DiskStation',
//          is_manager: true,
//          support_sharing: true,
//          support_vfs: true,
//          support_virtual: 'cifs,iso' } }

// File Station API - Enumerate files in a given folder
syno.fs.listFiles({'folder_path':'/volume1/photo/'}, callback);

// The above API call returns:
// { '0': { [Error: The logged in session does not have permission] code: 105 } }

Found a similar issue at http://forum.synology.com/enu/viewtopic.php?f=223&t=76514 where the user said "I wasn't passing the Session ID by using GET".

Shutdown the DiskStation via Node

Hi,

I'm looking for a way to shutdown the disk station as found here: https://github.com/kwent/syno/blob/master/definitions/DSM/6.0/7321/SYNO.Core.System.lib#L1
How can I invoke this method? syno.dsm.shutdown() does not work and the cli doesn't recognize syno dsm shutdown either:

node_modules/syno/bin/syno.js:55
return syno[api][cmd](payload, function(err, data) {
^

TypeError: syno[api][cmd] is not a function
at execute (node_modules/syno/bin/syno.js:55:24)
at Command. (node_modules/syno/bin/syno.js:256:10)
at Command.listener (node_modules/syno/node_modules/commander/index.js:301:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:191:7)
at Command.parseArgs (node_modules/syno/node_modules/commander/index.js:615:12)
at Command.parse (node_modules/syno/node_modules/commander/index.js:458:21)
at Object. (node_modules/syno/bin/syno.js:347:9)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)

Any help is greatly appreciated.

Use with React

Hi there,

Thanks for providing this package, it's really handy and will save me quite a lot of time... if I can get it to work :)

I'm trying to use the package in a React app. I've installed it using npm, no problem.
I loaded it import Syno from 'syno';, just like I do for every other package.
But when I build the Syno object const syno = new Syno({...}), it's throwing a TypeError: fs.readFileSync is not a function. I believe that's because the package doesn't know it's currently loaded in a browser and so doesn't have access to the file system, correct ?

I also tried const syno = new Syno.Syno({...}) but I get a TypeError: _syno2.default.Syno is not a constructor

When I use var Syno = require('syno.Syno');, I get a compilation fail Module not found: 'syno.Syno'.

I'm a bit stumped right now. Am I just missing something simple ?

How to check DSM info?

https://github.com/yannickcr/node-synology/blob/master/lib/dsm.js

Can you add DSM info?

module.exports = function(syno) {
  return {
    info            : info.bind(syno),
    application     : application.bind(syno),
    autoBlock       : autoBlock.bind(syno),
    connection      : connection.bind(syno),
    encryptShare    : encryptShare.bind(syno),
    findMe          : findMe.bind(syno),
    group           : group.bind(syno),
    logViewer       : logViewer.bind(syno),
    network         : network.bind(syno),
    package         : pkg.bind(syno),
    pushNotification: pushNotification.bind(syno),
    service         : service.bind(syno),
    share           : share.bind(syno),
    system          : system.bind(syno),
    systemLoading   : systemLoading.bind(syno),
    user            : user.bind(syno),
    volume          : volume.bind(syno),
    iSCSI           : iSCSI.bind(syno)
  };
};

Nodejs: syno.vs.listTVShows is not a function

This causes a TypeError: syno.vs.listTVShows is not a function. What am I doing wrong? The documentation is not clear.

var Syno = require('syno');
    var syno = new Syno({
        protocol: 'https',
        host: 'server',
        port: '5001',
        account: 'Me',
        passwd: 'Password',
        apiVersion: '6.0.2'
    });
   syno.vs.listTVShows({}, function(data){
        console.log(data);
        return res.json({
            message: "Running Fine!"
        });
    });

How Call additional ?

Hello,

I follow the synology documentation to call additional like that:

syno.fs.list({
        folder_path: path,
        additional: "real_path,owner,time"
      }, (error, architecture) => {
        if (error) {
          res.status(400);
          return res.send(error);
        }
        return res.json(architecture);
      });

That not working ..
But only one aditionnal working.. like that

syno.fs.list({
        folder_path: path,
        additional: "real_path"
      }, (error, architecture) => {
        if (error) {
          res.status(400);
          return res.send(error);
        }
        return res.json(architecture);
      });

Thanks for help

Query: Are there any plans to officially support DSM 7.x.x ?

Hi,
Are there any plans to officially support DMS 7.x.x?
And if yes, is there a timeframe?

Thanks for any feedback.

P.S: I do do not yet have a concrete issue, but befor I start really using syno.js I would like to know whther it is still maintained (last dpendecy commit 1 year ago, last bugfix / feature commit seems o be much longer ago)

Quickconnect

Hi,
Is it possible to use api through quickconnect?

Regards,
Vit3k

Error 500 on fs getMethods

Hello,

getting 500, don't know why :

 GET /nas/fs/getMethods 500 6.580 ms - 4591
[watch:server] TypeError: done is not a function
[watch:server]     at FileStation.getMethods (/Users/alexyfondeville/Desktop/Afondevi-All-Project/nasaf-webresources-api/node_modules/syno/dist/syno.js:489:26)
...

running that :

static getMethodsFs(req, res){
      syno.fs.getMethods((error, methods) => {
        if (error) {
          return res.json(error);
        }
        return res.json(methods);
      });
    }

Different behaviour between Ubuntu and Raspbian

Hi, i am currently working on a project to create an smart mirror based on https://github.com/MichMich/MagicMirror.
I want to develop an module which displays the live streams of my cams configured in the Surveillance Station.
The plan is to use your lib to access the DSM but i do not get it work.
To make sure the electron browser is not the problem i installed the lib with command line tool and tried the basic command of the readme.
The curious thing is that the command "syno -u http://USER:PASS@IP:5000 dsm getInfo" works perfectly on my Ubuntu but not on the Raspbian system.

Raspbian:

[ERROR] : Error: No such account or incorrect password
    at Request._callback (/usr/local/lib/node_modules/syno/dist/syno.js:79:33)
    at Request.self.callback (/usr/local/lib/node_modules/syno/node_modules/request/request.js:185:22)
    at Request.emit (events.js:310:20)
    at Request.<anonymous> (/usr/local/lib/node_modules/syno/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:310:20)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/syno/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:416:28)
    at IncomingMessage.emit (events.js:322:22)
    at endReadableNT (_stream_readable.js:1187:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  code: 400
}

Ubuntu:

{"codepage":"ger","model":"DS216","ram":512,"serial":"XXX","temperature":40,"temperature_warn":false,"time":"Tue Apr 14 11:42:14 2020","uptime":13181841,"version":"24922","version_string":"DSM 6.2.2-24922 Update 4"}

Both systems use Node version: v12.16.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.