๐Ÿณ synology-api-recipes

May 30, 2026 ยท View on GitHub

Production-ready Python recipes for Synology NAS automation โ€” disk health, Docker, media, security. Powered by synology-api.

Your NAS runs 24/7. Might as well make it do something useful besides eating electricity.

Stop copy-pasting scripts from socials and forums threads from 2019. synology-api-recipes is the cookbook for Synology NAS automation โ€” ready-to-run Python scripts that solve actual problems. Each recipe is tested against real API methods, won't crash on import, and doesn't require a PhD in DSM internals.

License: GPL v3 Python 3.9+ synology-api PRs Welcome


๐Ÿ˜ซ The Problem

Your Synology NAS is the most reliable device in your house. It has never crashed. It has never complained. It just... sits there. Meanwhile:

  • Disks accumulate SMART errors in total silence until one day โ€” click click click โ€” and your Plex library is gone
  • Docker containers run images from 2022 because "if it ain't broke" (it's broke, you just don't know it yet)
  • Someone in Belarus is trying admin/admin 300 times a day and DSM is like "this is fine"
  • SSL certificates expire and suddenly your entire family group chat is asking why Nextcloud is down
  • That 4TB "Misc" shared folder has permissions set to "Everyone: Read/Write" because you were tired that one Tuesday in 2023

You don't need to become a sysadmin. You just need a few good scripts.


๐Ÿ• The Solution

26 recipes. 9 categories. One .env file. Zero excuses.

Each recipe is:

  • Actually tested โ€” every method call verified against the real synology-api
  • Plug & play โ€” one config file, one command, go touch grass
  • Telegram-native โ€” alerts land in your pocket, not in a log file you'll never read
  • Cron-friendly โ€” built for crontab -e, not for interactive tinkering

Powered by synology-api โ€” 50+ DSM API endpoints, one pip install.


๐Ÿ“ฆ The Full Menu

๐Ÿฉบ Monitoring (4 recipes)

RecipePitch
disk_health_alert.pySMART, temperature, bad sectors. Alerts BEFORE the click of death.
storage_usage_alert.pyVolume usage alerts. "95% full" is not a good surprise at 2 AM.
container_monitor.pyWatches Docker containers, restarts crash victims, judges your uptime.
package_update_checker.pyLists pending DSM package updates you've been ignoring since 2023.

๐Ÿณ Docker (2 recipes)

RecipePitch
auto_update_containers.pyChecks registry for newer images, restarts containers. Manual pull still required โ€” DSM Docker, am I right?
container_updater.pyExports container configs, checks resource usage, generates update reports.

๐Ÿ“ Storage (3 recipes)

RecipePitch
disk_health_monitor.pyTracks every disk, alerts on warning signs. Your data deserves better than hope.
smart_recycle_bin.pyPer-folder retention. Downloads: 7 days. Documents: forever (you hoarder).
orphaned_files_finder.pyFinds files belonging to deleted users, in folders that shouldn't exist. Digital archaeology.

๐ŸŽฌ Media (3 recipes)

RecipePitch
media_library_sync.pyDetects Movies vs TV, creates Plex folder structure, moves files. Stop manually renaming Show.Name.S01E05.1080p.AMZN.WEB-DL.DDP5.1.H264-NTb.mkv.
download_organizer.pyWatches completed downloads, renames, sorts. Your Downloads folder will finally know peace.
photo_organizer.pySorts photos by date into folders. Your 4,712 cat photos will be beautifully organized.

๐Ÿ” Security (4 recipes)

RecipePitch
login_monitor.pyFailed login monitoring with GeoIP. Knows when Belarus is knocking.
security_audit_report.pyWeekly security report. Because audits sound professional and make you feel important.
shared_folder_audit.pyFinds folders open to "Everyone". Spots the Tuesday 2023 mistakes.
user_inactivity_report.pyFinds accounts that haven't logged in since the Before Times. Time for a cleanup.

๐Ÿ“ธ Surveillance (2 recipes)

RecipePitch
camera_health_check.pyChecks all cameras are connected and recording. Because the one day you skip is the day something happens.
camera_snapshot_backup.pyTakes snapshots from all cameras. Prove to your neighbor their cat IS on your roof.

๐Ÿ”’ Certificate (1 recipe)

RecipePitch
certificate_monitor.pyWarns 30/14/7 days before SSL certs expire. Avoids the 3 AM panic.

โ˜๏ธ Cloud & Drive (2 recipes)

RecipePitch
cloud_sync_monitor.pyChecks Cloud Sync connections. Because "it's syncing" is tech's greatest lie.
drive_admin_report.pySynology Drive usage stats. See who actually uses it (spoiler: one person).

๐Ÿ–ฅ๏ธ Virtualization & VPN (2 recipes)

RecipePitch
vm_status_monitor.pyChecks VMM guests. VMs crash at 3 AM Saturday โ€” at least now you'll know.
vpn_client_monitor.pyLists VPN connections. Find out who gave cousin Mario access.

๐ŸŽต Audio & More (3 recipes)

RecipePitch
audio_playlist_backup.pyLists Audio Station playlists. One day you WILL click Delete on the wrong one.
photo_album_stats.pySynology Photos stats. Exactly 4,712 cat photos. You're welcome.
auto_usb_backup.pyDetects USB drives, creates backup folders. Because you WILL forget to copy those photos from your camera.

๐Ÿ“ฅ Downloads (2 recipes)

RecipePitch
download_notifier.pyAlerts when downloads complete. So you can watch that Linux ISO immediately.
cleanup_old_downloads.pyRemoves old completed downloads. Your NAS has feelings too.

โšก 60-Second Quick Start

# 1. Clone
git clone https://github.com/N4S4/synology-api-recipes.git
cd synology-api-recipes

# 2. Install
pip install -r requirements.txt

# 3. Configure (set your NAS password + optional Telegram)
cp .env.example .env
nano .env

# 4. Run your first recipe (dry run โ€” totally safe)
python recipes/monitoring/disk_health_alert.py --dry-run

# 5. Add to cron
crontab -e
# Every morning at 8:
0 8 * * * cd /opt/synology-api-recipes && python recipes/monitoring/disk_health_alert.py

โš™๏ธ Configuration

One file. Five minutes. Done forever.

# Required โ€” your NAS
NAS_IP=192.168.1.2
NAS_PORT=5001
NAS_USERNAME=your_admin_user
NAS_PASSWORD=your_actual_password_no_really

# Optional โ€” Telegram alerts (create a bot with @BotFather in 2 min)
TELEGRAM_BOT_TOKEN=123456:ABC-DEF1234ghikl
TELEGRAM_CHAT_ID=159718277

# Optional โ€” Recipe customization
RECYCLE_POLICY=downloads:7,documents:30,media:14
DOCKER_SKIP_CONTAINERS=portainer,watchtower

Security note: Your .env file is gitignored. Don't commit it. Don't share it. Don't screenshot it. We've all been there.


๐Ÿ“ Project Layout

synology-api-recipes/
โ”œโ”€โ”€ recipes/
โ”‚   โ”œโ”€โ”€ common.py                 # NAS connection, Telegram, utilities
โ”‚   โ”œโ”€โ”€ monitoring/               # 4 recipes
โ”‚   โ”‚   โ”œโ”€โ”€ disk_health_alert.py
โ”‚   โ”‚   โ”œโ”€โ”€ storage_usage_alert.py
โ”‚   โ”‚   โ”œโ”€โ”€ container_monitor.py
โ”‚   โ”‚   โ””โ”€โ”€ package_update_checker.py
โ”‚   โ”œโ”€โ”€ docker/                   # 2 recipes
โ”‚   โ”‚   โ”œโ”€โ”€ auto_update_containers.py
โ”‚   โ”‚   โ””โ”€โ”€ container_updater.py
โ”‚   โ”œโ”€โ”€ storage/                  # 3 recipes
โ”‚   โ”‚   โ”œโ”€โ”€ disk_health_monitor.py
โ”‚   โ”‚   โ”œโ”€โ”€ recycle_bin_cleaner.py
โ”‚   โ”‚   โ””โ”€โ”€ storage_usage_alert.py
โ”‚   โ”œโ”€โ”€ media/                    # 3 recipes
โ”‚   โ”‚   โ”œโ”€โ”€ download_organizer.py
โ”‚   โ”‚   โ”œโ”€โ”€ media_library_sync.py
โ”‚   โ”‚   โ”œโ”€โ”€ photo_organizer.py
โ”‚   โ”‚   โ””โ”€โ”€ photo_album_stats.py
โ”‚   โ”œโ”€โ”€ security/                 # 4 recipes
โ”‚   โ”‚   โ”œโ”€โ”€ login_monitor.py
โ”‚   โ”‚   โ”œโ”€โ”€ security_audit_report.py
โ”‚   โ”‚   โ”œโ”€โ”€ shared_folder_audit.py
โ”‚   โ”‚   โ””โ”€โ”€ user_inactivity_report.py
โ”‚   โ”œโ”€โ”€ surveillance/             # 2 recipes
โ”‚   โ”‚   โ”œโ”€โ”€ camera_health_check.py
โ”‚   โ”‚   โ””โ”€โ”€ camera_snapshot_backup.py
โ”‚   โ”œโ”€โ”€ certificate/              # 1 recipe
โ”‚   โ”‚   โ””โ”€โ”€ certificate_monitor.py
โ”‚   โ”œโ”€โ”€ downloads/                # 2 recipes
โ”‚   โ”‚   โ”œโ”€โ”€ download_notifier.py
โ”‚   โ”‚   โ””โ”€โ”€ cleanup_old_downloads.py
โ”‚   โ”œโ”€โ”€ backup/                   # 2 recipes
โ”‚   โ”‚   โ”œโ”€โ”€ auto_usb_backup.py
โ”‚   โ”‚   โ””โ”€โ”€ snapshot_scheduler.py
โ”‚   โ”œโ”€โ”€ cloud/                    # 1 recipe
โ”‚   โ”‚   โ””โ”€โ”€ cloud_sync_monitor.py
โ”‚   โ”œโ”€โ”€ drive/                    # 1 recipe
โ”‚   โ”‚   โ””โ”€โ”€ drive_admin_report.py
โ”‚   โ”œโ”€โ”€ virtualization/           # 1 recipe
โ”‚   โ”‚   โ””โ”€โ”€ vm_status_monitor.py
โ”‚   โ”œโ”€โ”€ vpn/                      # 1 recipe
โ”‚   โ”‚   โ””โ”€โ”€ vpn_client_monitor.py
โ”‚   โ”œโ”€โ”€ audio/                    # 1 recipe
โ”‚   โ”‚   โ””โ”€โ”€ audio_playlist_backup.py
โ”‚   โ””โ”€โ”€ orphaned/                 # 1 recipe
โ”‚       โ””โ”€โ”€ orphaned_files_finder.py
โ”œโ”€โ”€ .env.example
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ CONTRIBUTING.md
โ””โ”€โ”€ README.md                     # You are here. Hi.

๐Ÿค Contributing

Got a script that saved your weekend? Share it. This cookbook runs on community contributions and mild procrastination.

The short version:

  1. Fork โ†’ Create recipe in the right recipes/category/ folder
  2. Use common.py for NAS connection โ€” don't reinvent the auth wheel
  3. Add --dry-run support, because trust is earned
  4. Open a PR โ†’ We'll review, maybe laugh at your variable names, merge

See CONTRIBUTING.md for the full guide. Yes, there's a guide. We're that kind of project.


๐Ÿงฑ Built On

  • synology-api โ€” 50+ DSM API modules, one wrapper
  • python-dotenv โ€” .env files for people who don't want to hardcode passwords
  • requests โ€” HTTP for humans, also used by the Telegram webhook fallback

โš ๏ธ Known Limitations (a.k.a. "It's not a bug, it's DSM")

Some recipes require specific DSM packages installed on your NAS. If a recipe fails:

  • Docker recipes โ†’ Docker package must be installed
  • Surveillance recipes โ†’ Surveillance Station package required
  • Cloud Sync / Drive โ†’ Cloud Sync or Synology Drive package required
  • Security Advisor / Log Center โ†’ Those packages must be active
  • Some System APIs โ†’ Require admin-level privileges (not all work with limited accounts)

The scripts handle missing packages gracefully โ€” they'll tell you what's missing instead of crashing. Mostly.


๐Ÿ“„ License

GPL-3.0-or-later โ€” Copyright ยฉ 2025 Renato Visaggio.

Free as in freedom. Use it, modify it, share it. Just keep it open.


Built with โ˜• and mild sleep deprivation
by @N4S4 and contributors who also have NAS devices they probably should check on more often