question: how to get "up-to-date" state via REST interface

I would like to run a daily cron job that will reassure me that Syncthing is still running on all three of my machines and that it is Up-to-date in the three places that I now see in the web GUI: local folders, remote device 1, and remote device 2. Currently I do this visually by looking at the web GUI on my primary machine and confirming “Up-to-date” for folders and remote devices.

I succeeded in using the REST interface to read various status information, but I was not clever enough to figure out (not quickly, anyway) how to get the basic summary information that most interests me: is it running, and is it up-to-date.

Is there in fact a straightforward way to get this information either via the REST interface or by reading the contents of a log file?

In /rest/system/connections I see who is connected and whether paused, but not the up-to-date status. (Also the mnemonic names are not there that appear in the GUI.)

In /rest/db/status I’m not sure which combination of fields indicates “up-to-date” since nearly every field’s value is zero.

I apologize in advance that I did not read through the GUI code before asking this question. I did read through the REST API documentation.

The endpoint was provided on the github issue you raised. If you have a more specific question, ask.

GET /rest/db/status returns the following (below). Perhaps I am looking at a null response rather than the true state?

{ “globalBytes”: 0, “globalDeleted”: 0, “globalDirectories”: 0, “globalFiles”: 0, “globalSymlinks”: 0, “ignorePatterns”: false, “inSyncBytes”: 0, “inSyncFiles”: 0, “invalid”: “”, “localBytes”: 0, “localDeleted”: 0, “localDirectories”: 0, “localFiles”: 0, “localSymlinks”: 0, “needBytes”: 0, “needDeletes”: 0, “needDirectories”: 0, “needFiles”: 0, “needSymlinks”: 0, “sequence”: 0, “state”: “”, “stateChanged”: “0001-01-01T00:00:00Z”, “version”: 0 }

curl -X GET -H “X-API-Key: (censored)” http://localhost:8384/rest/db/status

OK, got it: I had neglected to include the ‘folder’ parameter. This works now, and I guess, from skimming through the GUI code, that “idle” means “up-to-date”.

curl -X GET -H “X-API-Key: (censored)” http://localhost:8384/rest/db/status?folder=(folderid)

{ “globalBytes”: 40216725531, “globalDeleted”: 116015, “globalDirectories”: 22478, “globalFiles”: 189805, “globalSymlinks”: 1467, “ignorePatterns”: false, “inSyncBytes”: 40216725531, “inSyncFiles”: 189805, “invalid”: “”, “localBytes”: 40216725531, “localDeleted”: 108468, “localDirectories”: 22478, “localFiles”: 189805, “localSymlinks”: 1467, “needBytes”: 0, “needDeletes”: 0, “needDirectories”: 0, “needFiles”: 0, “needSymlinks”: 0, “sequence”: 2211964, “state”: “idle”, “stateChanged”: “2019-07-30T17:51:46.996390015-04:00”, “version”: 2211964 }

When omitting the folder parameter you should get an error, not a null response, so that’s weird.

And in the actual data what you want to look at is the need... items. They are non-zero if anything is out of sync. In between sync attempts it may still be idle, even if it’s out of sync.

Many thanks. I’m impressed by how quickly you all responded, even to a somewhat RTFM question. Since I have only one synced folder, I was slow to notice the folder-name parameter. I think I now have what I need to reassure/alert myself with a daily cron job.

1 Like