Skip to main content

Python API for communication with Synology DSM

Project description

https://travis-ci.org/ProtoThis/python-synology.svg?branch=master Library version Supported versions Downloads Formated with Black

Installation

[sudo] pip install python-synology

Usage

You can import the module as synology_dsm.

Constructor

SynologyDSM(
    dsm_ip,
    dsm_port,
    username,
    password,
    use_https=False,
    device_token=None,
    debugmode=False,
)

device_token should be added when using a two-step authentication account, otherwise DSM will ask to login with a One Time Password (OTP) and requests will fail (see the login section for more details).

Login

The library automatically login at first request, but you better use the login() function separately to authenticate.

It will return a boolean if it successed or faild to authenticate to DSM.

If your account need a two-step authentication (2SA), login() will raise SynologyDSMLogin2SARequiredException. Call the function again with a One Time Password (OTP) as parameter, like login("123456") (better to be a string to handle first zero). Store the device_token property so that you do not need to reconnect with password the next time you open a new SynologyDSM session.

Code exemple

from synology_dsm import SynologyDSM

print("Creating Valid API")
api = SynologyDSM("<SynologyIp>", "<SynologyPort>", "<Username>", "<Password>")

print("=== Information ===")
print("Model:           " + str(api.information.model))
print("RAM:             " + str(api.information.ram) + " MB")
print("Serial number:   " + str(api.information.serial))
print("Temperature:     " + str(api.information.temperature) + " °C")
print("Temp. warning:   " + str(api.information.temperature_warn))
print("Uptime:          " + str(api.information.uptime))
print("Full DSM version:" + str(api.information.version_string))

print("=== Utilisation ===")
print("CPU Load:        " + str(api.utilisation.cpu_total_load) + " %")
print("Memory Use:      " + str(api.utilisation.memory_real_usage) + " %")
print("Net Up:          " + str(api.utilisation.network_up()))
print("Net Down:        " + str(api.utilisation.network_down()))

print("=== Storage ===")
for volume_id in api.storage.volumes_ids:
    print("ID:          " + str(volume_id))
    print("Status:      " + str(api.storage.volume_status(volume_id)))
    print("% Used:      " + str(api.storage.volume_percentage_used(volume_id)) + " %")

for disk_id in api.storage.disks_ids:
    print("ID:          " + str(disk_id))
    print("Name:        " + str(api.storage.disk_name(disk_id)))
    print("S-Status:    " + str(api.storage.disk_smart_status(disk_id)))
    print("Status:      " + str(api.storage.disk_status(disk_id)))
    print("Temp:        " + str(api.storage.disk_temp(disk_id)))

Credits / Special Thanks

Found Synology API “documentation” on this repo : https://github.com/kwent/syno/tree/master/definitions

Official references

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-synology-0.7.1.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

python_synology-0.7.1-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file python-synology-0.7.1.tar.gz.

File metadata

  • Download URL: python-synology-0.7.1.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for python-synology-0.7.1.tar.gz
Algorithm Hash digest
SHA256 164deac270987c63b03cd1e24655d6bbffcbf478ad0ec3bfd7e65a3d1fe64549
MD5 1924037264a2bed02ec256249104e974
BLAKE2b-256 ad4a24ac985c7d83e4686519485f99e392b929b92fed01cfc4963394ec59e170

See more details on using hashes here.

Provenance

File details

Details for the file python_synology-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: python_synology-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for python_synology-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7ce64f3a37ead3c4a5dc7d32e5280f1d19482dcfc26e3b91d8be24832d883b0e
MD5 bcbb6d5d74c9fcb18ae10c4bb379d7d6
BLAKE2b-256 e2cd18750d3a8ab0724937d8e6f04f7207a750f329c08d2b983d718c954e2058

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page