28

Is there any way to use the iTunes API to lookup information based on the unique app bundleId? I have an iphone app, I want to use the API to check to see if the user has the newest version. Using the search sucks, cuz its fuzzy (can return lots of results). I'd prefer not to have to iterate over the result set looking for my bundleId..

I'm not looking for a way to do this on the device side (not objective c). I'd like to make server side code on my server that hides when/if apple makes API change.

rynop
  • 50,086
  • 26
  • 101
  • 112

5 Answers5

61

Apple has changed their API, and removed the language code from the URL, so you should only the bundleId for the app you are looking for. For example:

http://itunes.apple.com/lookup?bundleId=com.yelp.yelpiphone

In addition, you can add the country parameter to the query, to get results for a specific country App Store.

For example:

http://itunes.apple.com/lookup?bundleId=com.yelp.yelpiphone&country=de

The description, user rating and other fields might change between different App Store countries.

Roman Blachman
  • 227
  • 6
  • 13
  • 2
    Even though you don't have to specify a country code as a parameter, I think the search does not search all country codes..e.g.see the difference between http://itunes.apple.com/lookup?bundleId=uk.musicMagpie and http://itunes.apple.com/lookup?bundleId=uk.musicMagpie&country=gb – ch3rryc0ke Oct 21 '14 at 00:42
  • That was exactly what I was looking for! – Pedro Góes Aug 27 '15 at 14:47
  • Unfortunately the 'bundleId' param is not case-sensitive so it cannot differentiate between media kinds software (i.e. iOS apps) and mac-software (mac app store apps) in the case of where the developer opted to use the same bundle ID but different case for their iOS and Mac app. e.g. the iOS app com.palasoftware.MathBoard and the Mac app com.palasoftware.mathboard. Furthermore adding any other param to specify media type or entity type has no effect for this issue. – malhal Nov 01 '16 at 12:11
  • why this URL has scheme http and not https? Is it not secure URL? Does this require to allow arbitrary loads? – Hitesh Apr 28 '22 at 07:17
9

Turns out you can use the 'Apple ID' instead of the bundle ID as it is also unique per app. The 'Apple ID' maps to 'trackId' in http://itunes.apple.com/lookup service.

rynop
  • 50,086
  • 26
  • 101
  • 112
7

You can use a bundle id with Search API. Just replace id with bundleId, like following:

http://itunes.apple.com/lookup?bundleId=com.facebook.Facebook

EDIT: As @Roman Blachman stated, the country code logic has changed. If you want to limit your results to a specific country, use the following example.

http://itunes.apple.com/lookup?bundleId=com.facebook.Facebook&country=us

Adam
  • 26,549
  • 8
  • 62
  • 79
3

You can use the library, iVersion, to see if the user has the latest version of the app from within the app.

iVersion

Library for dynamically checking for updates to Mac/iPhone App Store apps from within the application and notifying users about the new release. Can also notify users about new features in the app the first time they launch after an upgrade.

https://github.com/nicklockwood/iVersion

Scott Bossak
  • 2,471
  • 20
  • 17
  • Sorry I should have said I'd like some way to do it server side (not objective c). I'd like to make server side code on my server that hides when/if apple makes API changes. I'll update my question as well. Turns out he does have some server side code (https://github.com/nicklockwood/iVersion/blob/master/Web%20Service/iversion.php) however he iterates over a result array. So must not b e a way to lookup by bundle ID – rynop Jan 13 '12 at 14:21
  • Are you looking for a way to tell when Apple upgrades from 5.0 to 5.1? – Scott Bossak Jan 13 '12 at 15:00
  • Nope. Lets say I have 10 apps in the market. All apps are currently v 1.0. I release a version 2.0 for App 1, other apps are still 1.0. I want to be able to leverage the web service to lookup what the most recent version of App 1 exists in the store, so i can notify users to upgrade. I'm not an iOS developer, turns out I can just use the apple id (aka 'trackId' in the itunes lookup api). All answer q below. – rynop Jan 13 '12 at 19:57
  • iVersion can work by hitting the Apple services directly from the device, or you can point it at your own web service instead and do the lookup on the server side. You can look at the source code to see what it's doing, it's basically making a query to the http://itunes.apple.com/lookup service, which returns JSON data. – Nick Lockwood Jun 08 '12 at 16:16
2

Thanks to all above answers. Here is code in swift 4.2

guard let info = Bundle.main.infoDictionary,
            let identifier = info["CFBundleIdentifier"] as? String,
      let url = URL(string: "http://itunes.apple.com/lookup?bundleId=\(identifier)") else { return }
    do {
      let data = try Data(contentsOf: url)
      guard let json = try JSONSerialization.jsonObject(with: data, options: [.allowFragments]) as? [String: Any] else {
        return
      }
      if let result = (json["results"] as? [Any])?.first as? [String: Any],
        let version = result["version"] as? String {
        print("version in app store", version)
      }
    } catch let erro as NSError {
      print(erro.description)
    }
Gurjinder Singh
  • 9,221
  • 1
  • 66
  • 58