Skip to main content

Synology Drive Web API integration for wcpan.drive

Project description

wcpan.drive.synology

Synology Drive integration for the wcpan.drive framework.

This repository contains:

  • a client-side FileService implementation that talks to a running server
  • a server that mirrors Synology Drive metadata into a local SQLite database
  • a Synology API adapter for the server-side mirror

Installation

pip install wcpan-drive-synology

For the server component:

pip install "wcpan-drive-synology[server]"

Usage

Client

The client connects to a running wcpan.drive.synology server instance and implements the wcpan.drive.core FileService interface.

from wcpan.drive.synology import create_service

async with create_service(server_url="http://localhost:8080") as file_service:
    root = await file_service.get_root()
    print(f"Root: {root}")

Server

The server mirrors a Synology Drive instance locally via a REST API and webhook-driven update pipeline. Configure it with a YAML file (see server.example.yaml):

# Copy and edit the example config
cp server.example.yaml server.yaml

# Start the server
wcpan.drive.synology --config server.yaml serve

# Other subcommands
wcpan.drive.synology --config server.yaml gc
wcpan.drive.synology --config server.yaml backfill /
wcpan.drive.synology --config server.yaml squash

At startup, the server:

  • connects to Synology Drive through DSM's WebStation API
  • registers a webhook at CALLBACK_URL/api/v1/synology-webhook
  • serves a local HTTP API for the client integration
  • keeps a SQLite-backed mirror in sync through scans, webhook events, and explicit backfill commands

backfill PATH operates on the server's virtual mirror paths. / is the server root; mounted Synology paths appear underneath it by mount label.

Config file

version: 2
host: "0.0.0.0"
port: 8080
database_url: "sqlite:////data/mirror.db"
synology:
  url: "https://nas.example.com:5001"
  username: "your-drive-user"
  password: "your-password"
  webhook:
    callback_url: "https://my-server.example.com"
mounts:
  photos: "/volume1/photos"
local_paths: {}

version is the config schema version and must match the version supported by the current binary. The current binary accepts only version 2. local_paths is currently required by the config schema; use {} when local media probing is not needed. synology.webhook.app_id defaults to wcpan-drive-synology. See server.example.yaml for the full set of options.

Important fields:

  • database_url: SQLite database location for the local mirror
  • synology.url: DSM / Synology Drive base URL
  • mounts: virtual mount label to Synology path mapping
  • local_paths: optional Synology-path to local-filesystem mapping for media probing; required by the current schema, so use {} if unused
  • synology.webhook.callback_url: externally reachable base URL used for webhook registration
  • synology.otp_code: optional 2FA code when the Synology account requires it

For multipart uploads in particular, this project intentionally sends Content-Type only on the file part and not on scalar form fields. That behavior is confirmed against a real Synology server and should be preserved as a project compatibility requirement to avoid regressions, even though Synology's public docs do not appear to spell it out explicitly.

Requirements

  • Python >= 3.13
  • aiohttp >= 3.13.0
  • pycryptodome >= 3.0
  • wcpan-drive-core >= 5.0.6

Server extras additionally require: dacite, pyyaml, pymediainfo, wcpan-logging.

Development

Code style rule for function signatures:

  • Keep semantic inputs positional when they are the subject of the operation.
  • Make infrastructure and wiring parameters keyword-only when they act as facilities for the function or object, such as storage, drive_api, network, node_sync, off_main, or similar service/session dependencies.

Example:

await copy_node(src, dst, node_sync=node_sync)

Useful commands:

make test
make lint
make format
make coverage

License

MIT

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

wcpan_drive_synology-3.2.0a1.tar.gz (146.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wcpan_drive_synology-3.2.0a1-py3-none-any.whl (66.4 kB view details)

Uploaded Python 3

File details

Details for the file wcpan_drive_synology-3.2.0a1.tar.gz.

File metadata

  • Download URL: wcpan_drive_synology-3.2.0a1.tar.gz
  • Upload date:
  • Size: 146.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for wcpan_drive_synology-3.2.0a1.tar.gz
Algorithm Hash digest
SHA256 c1c0e8b1b4328eb4bb6def674e3c2c0fbf33077cf1920f58ae42d116dcee9f28
MD5 cfead6834516ab2a49b4e46cdc234939
BLAKE2b-256 128b0c99ed4046286b72bf632a85441e2a24b2f9a59c0d3a4f103d8fe2ee2948

See more details on using hashes here.

File details

Details for the file wcpan_drive_synology-3.2.0a1-py3-none-any.whl.

File metadata

  • Download URL: wcpan_drive_synology-3.2.0a1-py3-none-any.whl
  • Upload date:
  • Size: 66.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for wcpan_drive_synology-3.2.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 eb8f6ebadbfb3291cb9699f4741678c03b143f99b273c6829d4efe8307c02447
MD5 f639d34bf9d95dc0c64c46458b537a18
BLAKE2b-256 e4298e204b3eebf7e9cc35f176bee446a11186cbc16d3cbe8abafc72da81a6fc

See more details on using hashes here.

Supported by

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