All Projects → kwent → Syno

kwent / Syno

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

Programming Languages

javascript
184084 projects - #8 most used programming language
coffeescript
4710 projects

Projects that are alternatives of or similar to Syno

Httpcat
httpcat is a simple utility for constructing raw HTTP requests on the command line.
Stars: ✭ 109 (-57.25%)
Mutual labels:  api, cli
Trino
Trino: Master your translations with command line!
Stars: ✭ 118 (-53.73%)
Mutual labels:  api, cli
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (-56.08%)
Mutual labels:  api, cli
N26
API and CLI to get information of your N26 account
Stars: ✭ 107 (-58.04%)
Mutual labels:  api, cli
Emuto
manipulate JSON files
Stars: ✭ 180 (-29.41%)
Mutual labels:  api, cli
Cjstoesm
A tool that can transform CommonJS to ESM
Stars: ✭ 109 (-57.25%)
Mutual labels:  api, cli
Freenom Dns Updater
A tool to update freenom's dns records
Stars: ✭ 117 (-54.12%)
Mutual labels:  api, cli
Run
⚡The resource runtime
Stars: ✭ 90 (-64.71%)
Mutual labels:  api, cli
Youtubeshop
Youtube autolike and autosubs script
Stars: ✭ 177 (-30.59%)
Mutual labels:  api, cli
Mojo Webqq
【重要通知:WebQQ将在2019年1月1日停止服务,此项目目前已停止维护,感谢大家四年来的一路陪伴】使用Perl语言(不会没关系)编写的smartqq/webqq客户端框架(非GUI),可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Stars: ✭ 1,755 (+588.24%)
Mutual labels:  api, cli
Schema Registry
A CLI and Go client for Kafka Schema Registry
Stars: ✭ 105 (-58.82%)
Mutual labels:  api, cli
Contentful Cli
The official Contentful command line interface. Use Contentful features straight from the command line!
Stars: ✭ 200 (-21.57%)
Mutual labels:  api, cli
Cryptocurrency Cli
💰 Cryptocurrency Portfolio On The Command Line 💰
Stars: ✭ 99 (-61.18%)
Mutual labels:  api, cli
Src Cli
Sourcegraph CLI
Stars: ✭ 108 (-57.65%)
Mutual labels:  api, cli
Rundeck Cli
CLI tool for Rundeck
Stars: ✭ 98 (-61.57%)
Mutual labels:  api, cli
Python N26
💵 Unofficial Python client for n26 (Number 26) - https://n26.com/
Stars: ✭ 116 (-54.51%)
Mutual labels:  api, cli
Mojo Weixin
使用Perl语言(不会没关系)编写的个人账号微信/weixin/wechat客户端框架(非GUI),可通过插件提供基于HTTP协议的api接口供其他语言或系统调用
Stars: ✭ 1,181 (+363.14%)
Mutual labels:  api, cli
Pypistats
Command-line interface to PyPI Stats API to get download stats for Python packages
Stars: ✭ 86 (-66.27%)
Mutual labels:  api, cli
Loophole
Polar devices Python API and CLI.
Stars: ✭ 136 (-46.67%)
Mutual labels:  api, cli
Autoserver
Create a full-featured REST/GraphQL API from a configuration file
Stars: ✭ 188 (-26.27%)
Mutual labels:  api, cli

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:[email protected]: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:[email protected]: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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].