pixelphantom
pixelphantom

Reputation: 551

How to get Apple App IDs from given bundle ID?

I have a list of Apple app bundleIds (e.g. com.facebook.Facebook). What I am ultimately trying to achieve is to enrich this data with iTunes metadata, which is available via the iTunes Search API: http://www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.html

I can get the specific information for a specific app if I know the app id (technically, the "trackId"), like so: http://itunes.apple.com/lookup?id=284882215 (284882215 being the trackId for the Facebook app)

However, I cannot use the bundleId in the same way. How can I systematically retrieve the app id (aka trackId) given the bundleId?

Upvotes: 6

Views: 8238

Answers (2)

luckman212
luckman212

Reputation: 804

Based on David Richardson's answer, here's my slightly modified version that uses jq to parse the JSON and extract just the App ID:

$ myApp=WireGuard
$ bID=$(mdls -name kMDItemCFBundleIdentifier -r "/Applications/${myApp}.app")
$ curl -s "https://itunes.apple.com/lookup?bundleId=${bID}" | jq -r '.results[0].trackId'
1451685025

Upvotes: 1

David Richardson
David Richardson

Reputation: 323

This should work:

curl https://itunes.apple.com/lookup\?bundleId\=com.facebook.Facebook

In the results you should see things like:

  "trackViewUrl": "https:\/\/itunes.apple.com\/us\/app\/facebook\/id284882215?mt=8&uo=4",

"bundleId": "com.facebook.Facebook",

"trackId": 284882215,

Upvotes: 6

Related Questions