6

I need to get an info about the app/song/video by item id from iTunes Store.

I've found this

But it doesn't work with apps.

Is there any public API?

UPD: I can get info using this link , but this is not a structured data it's just a markup for iTunes to display stuff. I can't rely on that - it can be changed anytime and is hard to parse because it has no consistent structure...

Janak Nirmal
  • 22,706
  • 18
  • 63
  • 99
quark
  • 386
  • 3
  • 9

5 Answers5

7

Apple now seems to offer a friendlier search service returning JSON. NB: the documentation does stipulate that the API is for use in connection with promoting the search results (i.e. it's designed for affiliate links).

Example, fetching info about an app if you know its Apple ID:

http://itunes.apple.com/lookup?id=[appleID]

General keyword search

http://itunes.apple.com/search?term=[query]
Jaysen Marais
  • 3,956
  • 28
  • 44
  • I've been using this but after as I launch my game to Canada https://itunes.apple.com/lookup/id12334555 is returning empty result. If I do https://itunes.apple.com/ca/lookup/id12334555 it works fine! I'm not sure why its like this!! Any idea – Imran Apr 09 '14 at 03:53
4

As far as I know (and I've done a lot of looking), there isn't a public API.

You're right that the HTML isn't semantically structured, so parsing it won't be very robust. But I think it's your only option. Here are a few links which might help :-

A Python script which parses reviews.

An Ars Technica article: Linking to the stars: hacking iTunes to solicit reviews.

An Inside iPhone article: Scraping AppStore Reviews.

James Mead
  • 3,472
  • 19
  • 17
2

There is a public API into iTunes called "iTunes Store Web Service Search API" that returns quite a bit of information. Some of it is documented here but that documentation is incomplete.

You can use the API to get information about everything for sale in iTunes Store and App Store including urls for the artwork, links directly into iTunes, all the apps by a developer, and so on. It's very robust and I'd love to find updated documentation.

I'm currently writing an article at the iPhone Dev FAQ to show how a few things are done and extend the available documentation.

John Fricker
  • 3,304
  • 21
  • 21
  • I've read that document already and mentioned it in "UPD" part. There is possibility to search by itemId but not every item in the store can be found. As example, try to use that and get info about any random Albums or Songs you'll see that some of them returns a result and some - not. – quark Oct 22 '09 at 13:25
  • In my experience the Search API is completely reliable and accurate. Perhaps you are using the wrong id. And the search you reference in UPD is not at all what is documented in the Search API. – John Fricker Oct 27 '09 at 00:00
  • Sorry, my fault, I mentioned it in main part of the question. Nevertheless the wsLookup works for some IDs and doesn't work for other. And I still don't get why... – quark Nov 02 '09 at 14:50
  • quark, can you give an example of what doesn't work? My experience of the api is quite good. FYI, retrieving album data is easy try this http://ax.phobos.apple.com.edgesuite.net/WebObjects/MZStoreServices.woa/wa/wsSearch?limit=500&offset=0&term=crowded%20house&attribute=artistTerm&entity=album&country=GB – pms1969 Mar 14 '10 at 16:21
1

That link you have there is JSON! You've got the solution right here. You just need JSON.framework

slf
  • 22,595
  • 11
  • 77
  • 101
  • hmm... I was wrong saying that this doesn't work with Apps. It works for most of them but not for every. I still don't get why it's working for some apps and don't for other... And it doesn't work with albums – quark Sep 28 '09 at 10:11
1

I wrote this script for myself. It's not optimized or future-proof, but it's working for me in the meantime...

<?php
ini_set('display_errors', false);

if(isset($_GET['appID']) && isset($_GET['format']))
{
    $appID = (int)stripslashes($_GET['appID']);
    $format = stripslashes($_GET['format']);

    $url = "http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=$appID&mt=8";
    $useragent = "iTunes/4.2 (Macintosh; U; PPC Mac OS X 10.2";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url); 
    curl_setopt($ch, CURLOPT_FAILONERROR, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

    $result = curl_exec($ch); 
    curl_close($ch); 

    $temp = str_replace("&#189;","",strip_tags(substr($result,
                    strpos($result,"Average rating for the current version:"),
                    strpos($result,"Rate this application:")-strpos($result,"Average rating for the current version:"))));

    $temp1 = explode("ratings",$temp);

    if(strpos($temp1[2], "Average rating for all versions:"))
            $temp1[2] = substr($temp1[2],0,stripos($temp1[2],"Average rating for all versions:"));

    $temp1[2] = preg_replace('/\s\s+/', ' ', $temp1[2]);
    $temp2 = explode(" ",$temp1[2]);

    $ratings[0] = $temp2[1];
    $ratings[1] = $temp2[2];
    $ratings[2] = $temp2[3];
    $ratings[3] = $temp2[4];
    $ratings[4] = $temp2[5];

    if($format == "prettyPrint")
        printRatings($ratings);
    else if($format == "XML");
        getXML($ratings);
}
else
{
    echo "Enter the app id and format (http://iblackjackbuddy.com/getAppRatings.php?appID=###&format=###";  
}

function printRatings($ratings)
{
    echo "Five stars: " . $ratings[0];
    echo "<br>Four stars: " . $ratings[1];
    echo "<br>Three stars: " . $ratings[2];
    echo "<br>Two stars: " . $ratings[3];
    echo "<br>One star: " . $ratings[4];

    echo "<hr>Total ratings: " . getTotalRatings($ratings);

    echo "<br>Average rating: " . getAverageRating($ratings);
}

function getTotalRatings($ratings)
{
    $temp = 1;

    for($i=0; $i < count($ratings); ++$i) 
        $temp+=$ratings[$i];

    return $temp;
}

function getAverageRating($ratings)
{
    $totalRatings = getTotalRatings($ratings);
    return round(5*($ratings[0]/$totalRatings) 
                                + 4*($ratings[1]/$totalRatings) 
                                    + 3*($ratings[2]/$totalRatings)
                                        + 2*($ratings[3]/$totalRatings) 
                                            + 1*($ratings[4]/$totalRatings),2);
}

function getXML($ratings)
{   
    header('Content-type: text/xml');
    header('Pragma: public');        
    header('Cache-control: private');
    header('Expires: -1');
    echo '<?xml version="1.0" encoding="utf-8"?>';
    echo '<Rating>';
    echo '<FiveStars>'.$ratings[0].'</FiveStars>';
    echo '<FourStars>'.$ratings[1].'</FourStars>';
    echo '<ThreeStars>'.$ratings[2].'</ThreeStars>';
    echo '<TwoStars>'.$ratings[3].'</TwoStars>';
    echo '<OneStar>'.$ratings[4].'</OneStar>';
    echo '<TotalRatings>'.getTotalRatings($ratings).'</TotalRatings>';
    echo '<AverageRating>'.getAverageRating($ratings).'</AverageRating>';
    echo '</Rating>';
}

?>
john
  • 1,189
  • 2
  • 15
  • 20
  • Read my "UPD: ..." part of the question and floehopper's answer. – quark Sep 30 '09 at 12:18
  • how did you know that the web service you use is available? is there documentation or a WSDL or a reference list of services somewhere for reference? – stifin Apr 01 '13 at 15:32