Skip to main content

aiosyncthing

Continuous Integration

Asynchronous Python client for the Syncthing REST API.

Inspired by python-syncthing, some snippets were copied from python-fumis

NOTE: The package is in active development. Not all features of the API are implemented.

Installation

pip install aiosyncthing

Usage

import asyncio

from aiosyncthing import Syncthing

async def main():

  async with Syncthing("API Key") as client:
    # interact with the client here
    pass

if __name__ == "__main__":
  asyncio.run(main())

Syncthing

Syncthing is the entrypoint class, it acts as an async context manager and provides access to endpoint namespaces.

Initialization

    def __init__(
        self,
        api_key, # your API Key
        url="http://127.0.0.1:8384", # A base URL of the server, https://syncthing.example.com:443/something is also possible
        timeout=DEFAULT_TIMEOUT, # Timeout in seconds
        verify_ssl=True, # Perform SSL verification
        loop=None, # event loop
        session=None # client session,
    )...

In case if the api_key is invalid, aiosyncthing.exceptions.SyncthingError will be raised on attempt to perform any request except client.system.ping(), this one only raises aiosyncthing.exceptions.PingError.

System namespace

Provides access to the System Endpoints

ping

Returns none if ping is successful or raises syncthing.exceptions.PingError

await client.system.ping()

config (Deprecated, use Config namespace instead)

Returns a dict with the server config or raises syncthing.exceptions.SyncthingError

await client.system.config()

status

Returns a dict with the server status or raises syncthing.exceptions.SyncthingError

await client.system.status()

version

Returns a dict with the server version or raises syncthing.exceptions.SyncthingError

await client.system.version()

pause

Pauses synchronization with all devices or with the selected device or raises syncthing.exceptions.SyncthingError, in case if passed devices is unknown to the server, syncthing.exceptions.UnknownDeviceError will be raised. Always returns None

await client.system.pause() # pause all
await client.system.pause(device_id) # eg: 'MTLMICV-YE72URC-NF4LBO3-2LVPTFZ-LLCZHEZ-2F3OEJS-R6CWZVE-7VXHFQA"

resume

Resumes synchronization with all devices or with a selected device or raises syncthing.exceptions.SyncthingError, in case if passed devices is unknown to the server, syncthing.exceptions.UnknownDeviceError will be raised. Always returns None

await client.system.resume() # resume all
await client.system.resume(device_id) # eg: 'MTLMICV-YE72URC-NF4LBO3-2LVPTFZ-LLCZHEZ-2F3OEJS-R6CWZVE-7VXHFQA'

Config namespace

Provides access to the Config Endpoints

folders

Returns a dict with the folder config or raises syncthing.exceptions.SyncthingError

await client.config.folders() # get all folders in config
await client.config.folders(folder_id) # eg: 'GXWxf-3zgnU'

devices

Returns a dict with the device config or raises syncthing.exceptions.SyncthingError

await client.config.devices() # get all folders in config
await client.config.devices(device_id) # eg: 'MTLMICV-YE72URC-NF4LBO3-2LVPTFZ-LLCZHEZ-2F3OEJS-R6CWZVE-7VXHFQA'

Database namespace

Provides access to the Database Endpoints

status

Returns a dict with the folder status or raises syncthing.exceptions.SyncthingError. If the folder id is unknown to the server, syncthing.exceptions.UnknownFolderError will be raised.

await client.database.status(folder_id) # eg: 'GXWxf-3zgnU'

Events namespace

Provides access to the Events Endpoints

listen

Is an async generator function that listens to the Event API, yields events one by one and hides the complexity of long polling. Raises syncthing.exceptions.SyncthingError in case of error, handles timeouts internally and reconnects to the endpoint.

async for event in client.events.listen():
  print(event)

last_seen_id

Returns the id of the last received event of the previous batch.

async for event in client.events.listen():
  if events.last_seen_id == 0:
    continue # skip first batch because it's historical data

License

MIT License

Copyright (c) 2020 Gleb Sinyavskiy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for aiosyncthing 0.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiosyncthing 0.7.1
File Size Uploaded
aiosyncthing-0.7.1.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiosyncthing 0.7.1
File Interpreter ABI Platform
aiosyncthing-0.7.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.4 kB

Release files / aiosyncthing-0.7.1.tar.gz

Download URL aiosyncthing-0.7.1.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a2de41bb53038f9c8342c0dabb59d22a638d6355cea8bf6914edd0f2627f5200
BLAKE2b-256 checksum
How to use checksums
4a979eab184b5058a5b88e66fc8d03922118003d518a1561887b06767f7ba495
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / aiosyncthing-0.7.1-py3-none-any.whl

Download URL aiosyncthing-0.7.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ab76e4bfcd565cf5dd38211dfa2c61268955a0a37a3003294771250605c4e0f
BLAKE2b-256 checksum
How to use checksums
761bcf218810afb9a2c84b5ac250b7a570ccc4cc8a1dd31dee241914b670a01a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.7.1 This release

2 release files

0.7.0

2 release files

0.6.3

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page