To my understanding it should be legal, since you are accessing a public URL and parsing the results to get some info from a known position (however, just in case I'd search for this topic in the Apple publishing guidelines). The 'danger' with this specific URL is that, since it is not itself an API but an HTML page, if one day they happen to change the response format, you'll not be able to extract the info or even, whats worse, get incorrect results.
HERE they use this SWIFT code. I think it can be easily 'translated' using HttpJob and then parsing the JSON result. Only the app BundleID and country code are needed to build the URL string.
Spoiler
guard let bundleId = Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String else { return }
guard let url = URL(string: "https://itunes.apple.com/lookup?bundleId=\(bundleId)&country=br") else { return }
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
if let data = data {
do {
let jsonObject = try JSONSerialization.jsonObject(with: data)
guard let json = jsonObject as? [String: Any] else {
print("The received that is not a Dictionary")
return
}
let results = json["results"] as? [[String: Any]]
let firstResult = results?.first
let currentVersion = firstResult?["version"] as? String
print("currentVersion: ", currentVersion)
} catch let serializationError {
print("Serialization Error: ", serializationError)
}
} else if let error = error {
print("Error: ", error)
} else if let response = response {
print("Response: ", response)
} else {
print("Unknown error")
}
}
task.resume()