API: Get Local DeviceID

Can someone please advise if I’m making the right decision here?

Using only the API, I’m looking for (the best) approach in getting the default deviceID of a given Syncthing instance. In other words, I’m looking for the deviceID assigned to the Syncthing instance at start. I need this deviceID to PATCH configuration changes against the device assigned to this local instance.

At this point I’ve decided this is probably the best means, but I’m second guessing because this is against folders, and not specifically devices. I’m assuming there will always be only a single element in this array, and that this be the assigned defaultID:


curl -s -X GET -H "X-API-Key: asdf" localhost:8384/rest/config/defaults/folder

devices[0]

I’ve also looked at the /rest/config endpoint. This returns several arrays which (may?) include the default deviceID. However, in using this I’d have to find a predictable means of identifying the default (assuming more than 1 array element). The only attribute that might work would be ‘name:’ yet I can’t trust this will be predictable given many different configurations.

curl -s -X GET -H "X-API-Key: asdf" localhost:8384/rest/config

folders[].devices[]
devices[]
defaults.folder.devices[]

Thanks for any insight you can offer.

How about this:

https://docs.syncthing.net/dev/http-services.html#get-meta-js

1 Like

Any response will have the X-Syncthing-Id header set as well.

3 Likes

Fantastic. Both great options. Thank you!