The BTSync
class is a light wrapper around the Bittorrent Sync API.
For now, this code assumes a btsync instance is running with a working API key.
(See the Notes section for more info on how to get this set up.)
$ git clone https://github.com/jminardi/python-btsync.git
$ cd python-btsync
$ python setup.py install
You will also need a recent version of the [Bittorrent Sync Application][0] [0]: http://www.bittorrent.com/sync/downloads
>>> # this code assumes a btsync instance is running
>>> from btsync import BTSync
>>> btsync = BTSync()
>>> btsync.get_folders()
[{u'dir': u'/Users/jack/sync/notes',
u'error': 0,
u'files': 13,
u'indexing': 0,
u'secret': u'NOPE',
u'size': 70867,
u'type': u'read_write'}]
At this time, not all API calls are implemented. However, you can still
make any API call manually using the request()
method like so:
btsync.request({'method': 'get_folder_peers', 'secret': '<yoursecret>'})
- Get folders
- Add folder
- Remove folder
- Get files
- Set file preferences
- Get folder peers
- Get secrets
- Get folder preferences
- Set folder preferences
- Get folder hosts
- Set folder hosts
- Get preferences
- Set preferences
- Get OS name
- Get version
- Get speed
- Shutdown
To use the API you will need to apply for a key. You can find out how to do that, and learn more about the btsync API here:
http://www.bittorrent.com/sync/developers/
Once you receive your key, you need to enter it into the config file.
See config.json
for a sample config file.
Then quit BTSync if it is running, and start it from the command line with the --config flag:
$ /Applications/BitTorrent\ Sync.app/Contents/MacOS/BitTorrent\ Sync --config path/to/config.json