๐ณ 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.
๐ซ 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/admin300 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)
| Recipe | Pitch |
|---|---|
disk_health_alert.py | SMART, temperature, bad sectors. Alerts BEFORE the click of death. |
storage_usage_alert.py | Volume usage alerts. "95% full" is not a good surprise at 2 AM. |
container_monitor.py | Watches Docker containers, restarts crash victims, judges your uptime. |
package_update_checker.py | Lists pending DSM package updates you've been ignoring since 2023. |
๐ณ Docker (2 recipes)
| Recipe | Pitch |
|---|---|
auto_update_containers.py | Checks registry for newer images, restarts containers. Manual pull still required โ DSM Docker, am I right? |
container_updater.py | Exports container configs, checks resource usage, generates update reports. |
๐ Storage (3 recipes)
| Recipe | Pitch |
|---|---|
disk_health_monitor.py | Tracks every disk, alerts on warning signs. Your data deserves better than hope. |
smart_recycle_bin.py | Per-folder retention. Downloads: 7 days. Documents: forever (you hoarder). |
orphaned_files_finder.py | Finds files belonging to deleted users, in folders that shouldn't exist. Digital archaeology. |
๐ฌ Media (3 recipes)
| Recipe | Pitch |
|---|---|
media_library_sync.py | Detects 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.py | Watches completed downloads, renames, sorts. Your Downloads folder will finally know peace. |
photo_organizer.py | Sorts photos by date into folders. Your 4,712 cat photos will be beautifully organized. |
๐ Security (4 recipes)
| Recipe | Pitch |
|---|---|
login_monitor.py | Failed login monitoring with GeoIP. Knows when Belarus is knocking. |
security_audit_report.py | Weekly security report. Because audits sound professional and make you feel important. |
shared_folder_audit.py | Finds folders open to "Everyone". Spots the Tuesday 2023 mistakes. |
user_inactivity_report.py | Finds accounts that haven't logged in since the Before Times. Time for a cleanup. |
๐ธ Surveillance (2 recipes)
| Recipe | Pitch |
|---|---|
camera_health_check.py | Checks all cameras are connected and recording. Because the one day you skip is the day something happens. |
camera_snapshot_backup.py | Takes snapshots from all cameras. Prove to your neighbor their cat IS on your roof. |
๐ Certificate (1 recipe)
| Recipe | Pitch |
|---|---|
certificate_monitor.py | Warns 30/14/7 days before SSL certs expire. Avoids the 3 AM panic. |
โ๏ธ Cloud & Drive (2 recipes)
| Recipe | Pitch |
|---|---|
cloud_sync_monitor.py | Checks Cloud Sync connections. Because "it's syncing" is tech's greatest lie. |
drive_admin_report.py | Synology Drive usage stats. See who actually uses it (spoiler: one person). |
๐ฅ๏ธ Virtualization & VPN (2 recipes)
| Recipe | Pitch |
|---|---|
vm_status_monitor.py | Checks VMM guests. VMs crash at 3 AM Saturday โ at least now you'll know. |
vpn_client_monitor.py | Lists VPN connections. Find out who gave cousin Mario access. |
๐ต Audio & More (3 recipes)
| Recipe | Pitch |
|---|---|
audio_playlist_backup.py | Lists Audio Station playlists. One day you WILL click Delete on the wrong one. |
photo_album_stats.py | Synology Photos stats. Exactly 4,712 cat photos. You're welcome. |
auto_usb_backup.py | Detects USB drives, creates backup folders. Because you WILL forget to copy those photos from your camera. |
๐ฅ Downloads (2 recipes)
| Recipe | Pitch |
|---|---|
download_notifier.py | Alerts when downloads complete. So you can watch that Linux ISO immediately. |
cleanup_old_downloads.py | Removes 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
.envfile 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:
- Fork โ Create recipe in the right
recipes/category/folder - Use
common.pyfor NAS connection โ don't reinvent the auth wheel - Add
--dry-runsupport, because trust is earned - 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 โ
.envfiles 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