rynop
rynop

Reputation: 53499

iTunes api, lookup by bundle ID?

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.

Upvotes: 29

Views: 47233

Answers (5)

Gurjinder Singh
Gurjinder Singh

Reputation: 10299

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)
    }

Upvotes: 2

Adam
Adam

Reputation: 26907

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

Upvotes: 8

Roman Blachman
Roman Blachman

Reputation: 257

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.

Upvotes: 64

rynop
rynop

Reputation: 53499

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.

Upvotes: 9

Scott Bossak
Scott Bossak

Reputation: 2501

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

Upvotes: 3

Related Questions