Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Apple App IDs from given bundle ID?

Tags:

ios

app-store

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?

like image 999
pixelphantom Avatar asked Oct 07 '22 13:10

pixelphantom


2 Answers

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,

like image 86
David Richardson Avatar answered Oct 12 '22 02:10

David Richardson


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
like image 33
luckman212 Avatar answered Oct 12 '22 03:10

luckman212