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

Purpose

JimRobs developped a cool Node.js wrapper for the Synology DSM REST API but no Command Line Tool was available.

So i decided to develop my first Node.js CLI on top of this wrapper.

It’s now available with 1.0.2 version and below some examples how to use it.

CLI

Installation

BASH
$ npm install -g syno
Click to expand and view more

Usage

PLAINTEXT
$ syno --help
Usage: syno [options]

  Synology Rest API Command Line

  Options:

    -h, --help           output usage information
    -V, --version        output the version number

  Commands:

    filestation|fs [options] <method>  DSM File Station API
    downloadstation|dl [options] <method>  DSM Download Station API

  Examples:

    $ syno filestation|fs getFileStationInfo
    $ syno downloadstation|dl getDownloadStationInfo
Click to expand and view more
PLAINTEXT
$ syno fs --help
Usage: filestation|fs [options] <method>

  DSM File Station API

  Options:

    -h, --help               output usage information
    -c, --config <path>      DSM configuration file. Default to ~/.syno/auth.yaml
    -u, --url <url>          DSM URL. Default to https://admin:password@localhost:5001
    -p, --payload <payload>  JSON Payload
    -P, --pretty             Prettyprint JSON Output
    -d, --debug              Enabling Debugging Output

  Examples:

    $ syno filestation|fs listSharedFolders
    $ syno filestation|fs listFiles --pretty --payload '{"folder_path":"/path/to/folder"}'
Click to expand and view more
PLAINTEXT
$ syno dl --help
Usage: downloadstation|dl [options] <method>

  DSM Download Station API

  Options:

    -h, --help               output usage information
    -c, --config <path>      DSM configuration file. Default to ~/.syno/auth.yaml
    -u, --url <url>          DSM URL. Default to https://admin:password@localhost:5001
    -p, --payload <payload>  JSON Payload
    -P, --pretty             Prettyprint JSON Output
    -d, --debug              Enabling Debugging Output

  Examples:

    $ syno downloadstation|dl createTask --payload '{"uri":"magnet|ed2k|ftp(s)|http(s)://link"}'
    $ syno downloadstation|dl listTasks
    $ syno downloadstation|dl listTasks --payload '{"limit":10}'
    $ syno downloadstation|dl getTasksInfo --pretty --payload '{"id":"task_id"}'
Click to expand and view more

Examples

Without a configuration file

BASH
$ syno fs getFileStationInfo --url https://admin:[email protected]:5001 --pretty
Click to expand and view more

With a configuration file

YAML
# Example config file, by default it should be located at:
# ~/.syno/config.conf

url:
  protocol: https
  host: localhost
  port: 5001
  account: admin
  passwd: password
Click to expand and view more
BASH
$ syno fs getFileStationInfo --pretty
Click to expand and view more

In real life ?

List Files via File Station

BASH
$ syno fs listFiles --payload '{"folder_path":"/photo"}' --pretty
Click to expand and view more

List Tasks via Download Station

BASH
$ syno dl listTasks --payload '{"limit":1}' --pretty
Click to expand and view more

Add Task HTTP file via Download Station

BASH
$ syno dl createTask --payload '{"uri":"https://download.thinkbroadband.com/5MB.zip"}'
Click to expand and view more
BASH
$ syno dl createTask --payload '{"uri":"magnet:?xt=urn:ed2k:31D6CFE0D16AE931B73C59D7E0C089C0&xl=0&dn=zero_len.fil&xt=urn:bitprint:3I42H3S6NNFQ2MSVX7XZKYAYSCX5QBYJ.LWPNACQDBZRYXW3VHJVCJ64QBZNGHOHHHZWCLNQ&xt=urn:md5:D41D8CD98F00B204E9800998ECF8427E"}'
Click to expand and view more

More…

Quentin Rousseau

Quentin Rousseau

CTO & Co-founder at Rootly (YC S21)

San Francisco, CA

Former Instacart SRE. Rock climber & wine enthusiast.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut