6

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?

NobodyNada
  • 7,529
  • 6
  • 44
  • 51
pixelphantom
  • 531
  • 1
  • 5
  • 16

2 Answers2

5

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,

1

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
luckman212
  • 473
  • 1
  • 7
  • 15