Clone wiki

arendee-btsynclib / Home


This is a C# implementation of the Bittorrent Sync API

Please note that the BTSync API is currently a moving target,
so you can expect things to break or not to work entirely as expected.


This library is now available through NuGet

PM> Install-Package arendee-btsynclib

##Usage Examples Below you'll find a few examples to get you started.
All other API methods have been implemented as well. ###Creating a client instance

var client = new BTSyncClient("localhost", 8888, "username", "password", "BTSync Example");

Of course you have to replace the values to match your configuration.

###Getting a list of the folders and print out active peers

var folders = await client.GetFolders();
foreach (var folder in folders)
    var peers = await client.GetFolderPeers(folder.Secret);

    foreach (var peer in peers)
                           peer.Name, peer.Connection, peer.Download / 1024, peer.Upload / 1024);

###Setting the preferences for a folder

var folderPreferences = new SyncFolderPreferences()
    SearchLan = true,
    UseDht = true,
    UseHosts = false,
    UseRelayServer = true,
    UseSyncTrash = true,
    UseTracker = true

await client.SetFolderPreferences(folder.Secret, folderPreferences);

###Generating secrets

var secrets = await client.GenerateSecrets();

###Adding a sync folder

var secrets = await client.GenerateSecrets();
var documentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var path = Path.Combine(documentsFolder, "examplefolder");

if (!Directory.Exists(path))

await client.AddFolder(path, secrets.ReadWrite);

###Setting the preferences for BTSync

var preferences = new SyncPreferences()
    DeviceName = "Arendee Box",
    FolderRescanInterval = 600,
    DiskLowPriority = true,
    LanEncryptData = true,
    ListeningPort = 10888,
    UseUPNP = true,

await client.SetPreferences(preferences);