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?
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,
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With