API to check if a device is currently connected(bool)


Is device connection(current) status available as a bool in any of the API’s?

The closest I can find is the lastSeen field in /api/v2/device/:deviceID, which will create a couple of extra steps in order to decide if one should consider it online or not, maybe even needing considering timezones?
In the admin UI connected or a datetimestamp is shown in the Last seen column.



I’d suggest trying to use tailscale status --json in a script and look for the device you want that way. If you look in the Peer key, you can iterate over the key->value pairs and find information for any machine you want.

Take a look at this thread for some example Python code to read from tailscale status.

Converted to using the new online field: