10

AirTags seem to be an incredibly useful way of creating a de-facto globally available location tracker, by taking advantage of the sheer number of iOS devices around.

I'd love to be able to obtain an AirTag and get location data from it (or more precisely from the Apple 'Find My' network) programmatically or in machine-readable form, though. Currently as I understand it the location is only available through the 'Find My' tool (digression: see this fascinating recent article illustrating that), which in effect means it's limited to what's plotted on a map. Can I get lat/long co-ordinates from this? Can I programmatically trigger the request for location? This would be a great way to (for example) plot everywhere I travel, by popping one in my bag and having a central server somewhere request my location periodically and log it. Real-time would be ideal, but even a history of locations would be good.

(Note: I wasn't sure if this question was better suited for here or StackOverflow. Happy if the community wants to move it).

2 Answers 2

10

Yes, it is possible to do so via a private API - however it is a bit of a "hack" as this is not officially supported by Apple.

You can find an open source implementation of using the private API here:

https://github.com/seemoo-lab/openhaystack/tree/main/OpenHaystack/OpenHaystackMail

Note that in order to use the private API, you'll need a specific entitlement for your app that is not available to third parties. This can be worked around by disabling GateKeeper, installing the program linked above as a plugin for Mail, enabling the plugin in Mail, and then re-enabling GateKeeper.

1
  • Fascinating! I wasn't expecting much when I posted this question so thanks for your response. This definitely looks like the beginnings of a solution... Commented May 24, 2021 at 17:39
6

You can also have the FindMy app running, and periodically grab the position from the cache from the command-line:

$ jq -r '.[] | select(.name == "Storm") | .location | "\(.latitude) \(.longitude) \(.timeStamp/1000 | todate)"' ~/Library/Caches/com.apple.findmy.fmipcore/Items.data

61.84794671778637 11.892693370033092 2022-03-18T09:00:26Z

Just append that output to a file using a cron job or a looping script. ("Storm" is the name of the tag)

If Items.data is empty, use Devices.data instead.

macOS Monterey is needed for AirTag support in FindMy.app.

Disclaimer: You need macOS 14.3.1 or earlier for this to work. Items.data is encrypted in 14.4 and later.

6
  • I get a Operation not permitted error even if using sudo. Permission look normal, so this looks like some special protection (Mac OS Ventura)
    – hoeni
    Commented Oct 16, 2023 at 13:59
  • @hoeni Works fine in Ventura here. You probably need to give Terminal some more access (system prefs --> privacy & security --> full disk access --> Terminal)
    – neu242
    Commented Oct 18, 2023 at 12:23
  • Perfect, thanks (had a new Laptop and forgot about this setting :-) )
    – hoeni
    Commented Oct 19, 2023 at 14:49
  • @neu242 Does the location refresh automatically as long as Find My is open, or do I need to manually press any buttons to make Find My refresh? I want to log the coordinate data over time in a SQL table, so I can construct a track log.
    – Felix An
    Commented Oct 25, 2023 at 6:54
  • 1
    @FelixAn It refreshes automatically. I'm doing the exact same thing: gist.github.com/henrik242/1da3a252ca66fb7d17bca5509a67937f plus gist.github.com/henrik242/84ad80dd2170385fe819df1d40224cc4
    – neu242
    Commented Oct 25, 2023 at 11:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .