REST API Questions

Hi,

  • I installed Syncthing v0.11 on my windows desktop
  • installed in a windows VM
  • created a shared folder on desktop (as master folder), call it “testfiles”
  • got it all connected
  • added a file
  • it synced the file, no problems there.

I want to, using the REST API, know if all files inside the “testfiles” folder have been synced to the VM instance or if there are files outstanding (so I can create some sort of alert/email if it hasn’t been synced for x days).

I tried the following:

  • I shutdown the VM instance
  • copied new files into “testfiles”
  • waited for the descktop instance of “testfiles” to pickup the new files
  • immediately the status changed to “Up to date” in green?
  • Remember the VM is disconnected, and says so in desktop instance of Syncthing.

I thought maybe the /rest/db/status would be my saviour:

# which part of what we have locally should be fetched from the cluster:
  "needBytes": 0,
  "needFiles": 0,

I used Fiddler to call “/rest/db/status?folder=testfiles” but those values were always 0. All the other values looked correct.

How do you query a folder to see what is outstanding? I saw “Out of Synch: 0 Files” see in some screenshots on Github but my Syncthing doesn’t display that.

What am I doing wrong?

1 Like

You cannot check what others are missing unless they are connected to you.

Hmm, ok so I have to check if there are devices connected first using:

/rest/stats/device

Then if there are devices connected, use /rest/db/status:

# what we have locally:
  "localBytes": 13173473780,
  "localDeleted": 1847,
  "localFiles": 42106,
  # which part of what we have locally is the latest cluster verision:
  "inSyncBytes": 13173473780,
  "inSyncFiles": 42106,

I need to compare localFiles to inSyncFiles?

I think you can just check /rest/system/connections and /rest/db/completion

2 Likes