Skip to main content

Python bindings to the Syncthing REST interface, targeting v0.11.6

Project description

# python-syncthing

Python bindings to the Syncthing REST interface. Supports Python 2 and Python 3 (via [six](http://pythonhosted.org//six/)).

[Syncthing](https://syncthing.net/)

[Syncthing REST Documentation](https://github.com/syncthing/syncthing/wiki/REST-Interface)

```bash
pip install syncthing
```

These bindings use Meta classes to create dynamic bindings based on the latest documentation of the Synthing REST API on their github repository.

`GET` methods are returned as a Bunch dot-dictionary, and are bound to the `Syncthing` object as properties. `POST` calls are bound as methods to `Syncthing`,
beginning with the word `set_`, and allow arguments to be passed similarly as they would in the HTTP header.


**WARNING:** python-syncthing uses an offline cache to story the REST API that it retrieves from the parent github. If the python process does not have write privledges
the first time the cache is synced it will fail with a permission error. To remedy this, before running `import syncthing` for the first time, run `sudo python -c "import syncthing"`
from the commandline to pre-cache the api. The REST API version for the targetting Syncthing version will be included by default, however. (v0.11.6)

## Quickstart

```python
from syncthing.interface import get_latest_documentation
from syncthing import Interface, Syncthing

# this will download the REST API markdown from github
# and store it in a cache folder located in syncthing/docs.
# when called explicitly it will update to the newest version
# of the REST API, overwriting the old binding documentation.
# otherwise, the Syncthing meta class will download the latest
# documentation on first run, and use that as its bound version
# until it's explicitly updated.
get_latest_documentation()

sync_interface = Interface(
'my api key',
host = 'localhost',
port = 'syncthing port',
timeout = 5.0, # seconds
is_https = False
)

sync = Syncthing(sync_interface)

print(sync.methods) # prints out the available REST methods

print(sync.warning_methods) # REST methods that require force=True to perform

print(sync.help('db_browse')) # returns the documentation for a given method

```

### syncthing.Interface

#### Interface(api_key, host='localhost', port=8080, timeout=3.0, is_https=False, ssl_cert_file=None, **kwargs)

#### Interface.root
Returns the connection string given the initialization parameters, ie: `http://localhost:5324`

#### Interface.is_connected
Returns `True` if the Interface can communicate with the Syncthing server, `False` otherwise.

#### Interface.from_dict(d)
Returns an Interface from a dictionary config.

#### Interface.from_json(json_str)
Returns an Interface from a JSON string.

#### Interface.to_json()
Exports Interface configuration as JSON string.

### syncthing.Syncthing

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

syncthing-0.1.4.tar.gz (12.2 kB view details)

Uploaded Source

File details

Details for the file syncthing-0.1.4.tar.gz.

File metadata

  • Download URL: syncthing-0.1.4.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for syncthing-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c913a38a9d4882ad3d339af7d77d8b60976903cc4d0cb363a0dfdec6b4af14ce
MD5 2ecc3251bb0a143b9e6a1e556cd0a894
BLAKE2b-256 5ffe0ec46f7e63f3bbc3aeaf0f25552d240fbe2418ef62e4747a5fc05522208a

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