iTunes Search API Around the Corner?

Could the Apple iTunes Store soon have a fully public API? On Apple's iTunes page, they have a search widget featured in the sidebar. What's interesting is that this AJAX-powered widget is returning a JSON object. How very API friendly!

The iTunes API widget from the Apple site.

The script located at http://www.apple.com/itunes/scripts/itmsSearch.php currently accepts two parameters, searchTerm and searchType where the type is one of album, allTrack, musicVideo, movie, tvSeason, audiobookLockup or podcast. Here's a quick example that searches all podcasts for 'web standards':

http://www.apple.com/itunes/scripts/itmsSearch.php?searchTerm=web%20standards&searchType=podcast

A quick attempt to hacking the URL didn't seem to reveal any callback function feature, which means client-side cross-domain calls are still out of the question. In the meantime, however, a service proxy could be easily implemented to pass the information from the API to your application.

Published September 13, 2006 · Updated September 14, 2006
Categorized as JavaScript
Short URL: https://snook.ca/s/668

Conversation

10 Comments · RSS feed
Andrew said on September 13, 2006

The error message dumps the entire schema out for you; it looks like there is a callback parameter. Take for instance this invalid search (sorry for the length):

{
    "errorMessage":"Invalid key-value pair(s) in request: {entity = "all"; }",
    "queryParameters":
    {
        "output":"json",
        "offset":"The result index at which to start returning results",
        "media":
        {
            "movie":
            {
                "entity":
                [
                    "movieArtist",
                    "movie",
                    "movie"
                ],
                "attribute":
                [
                    "actorTerm",
                    "genreIndex",
                    "artistTerm",
                    "shortFilmTerm",
                    "producerTerm",
                    "ratingTerm",
                    "directorTerm",
                    "releaseYearTerm",
                    "featureFilmTerm",
                    "movieArtistTerm",
                    "movieTerm",
                    "ratingIndex",
                    "descriptionTerm"
                ]
            },
            "all":
            {
                "entity":
                [
                    "allArtist",
                    "allTrack",
                    "album",
                    "movie",
                    "musicVideo",
                    "tvSeason",
                    "audiobook",
                    "podcast"
                ],
                "attribute":
                [
                    "actorTerm",
                    "allArtistTerm",
                    "authorTerm",
                    "genreIndex",
                    "artistTerm",
                    "allTrackTerm",
                    "tvEpisodeTerm",
                    "composerTerm",
                    "tvSeasonTerm",
                    "shortFilmTerm",
                    "producerTerm",
                    "ratingTerm",
                    "songTerm",
                    "directorTerm",
                    "releaseYearTerm",
                    "titleTerm",
                    "featureFilmTerm",
                    "movieArtistTerm",
                    "showTerm",
                    "movieTerm",
                    "albumTerm",
                    "ratingIndex",
                    "keywordsTerm",
                    "descriptionTerm
                    "
                ]
            },
            "podcast":
            {
                "entity":
                [
                    "podcastAuthor",
                    "podcast",
                    "podcast"
                ],
                "attribute":
                [
                    "titleTerm",
                    "authorTerm",
                    "genreIndex",
                    "ratingIndex",
                    "keywordsTerm",
                    "descriptionTerm"
                ]
            },
            "music":
            {
                "entity":
                [
                    "musicArtist",
                    "musicTrack",
                    "album",
                    "musicVideo"
                ],
                "attribute":
                [
                    "genreIndex",
                    "artistTerm",
                    "composerTerm",
                    "albumTerm",
                    "ratingIndex",
                    "songTerm",
                    "musicTrackTerm"
                ]
            },
            "audiobook":
            {
                "entity":
                [
                    "audiobookAuthor",
                    "audiobook",
                    "audiobook"
                ],
                "attribute":
                [
                    "titleTerm",
                    "authorTerm",
                    "genreIndex",
                    "ratingIndex"
                ]
            },
            "shortFilm":
            {
                "entity":
                [
                    "shortFilmArtist",
                    "shortFilm",
                    "shortFilm"
                ],
                "attribute":
                [
                    "genreIndex",
                    "artistTerm",
                    "shortFilmTerm",
                    "ratingIndex",
                    "descriptionTerm"
                ]
            },
            "tvShow":
            {
                "entity":
                [
                    "tvEpisode",
                    "tvSeason"
                ],
                "attribute":
                [
                    "genreIndex",
                    "tvEpisodeTerm",
                    "tvSeasonTerm",
                    "showTerm",
                    "ratingIndex",
                    "descriptionTerm"
                ]
            }
        },
        "callback":"A javascript function to handle your search results",
        "country":"ISO-2A country code",
        "limit":"The number of search results to return",
        "term":"A search string",
        "lang":"ISO-2A language code"
    }
}
Jonathan Snook said on September 13, 2006

Good catch. Unfortunately, the schema doesn't seem to match what you can pass through the URL. Which leads me to believe it's merely a proxy for the actual web service. Whereever this web service is located, a callback function might be available.

James said on September 13, 2006

I really hope an API is coming.

Elliot Swan said on September 14, 2006

That could definitely open up some interesting opportunities.

Matthew Keefe said on September 19, 2006

I would love to see an API, that would offer some 3rd party promotional tools or maybe even a 3D enviroment to search the library similar to what is found in iTunes 7.

Robert said on October 01, 2006

If you're interested in taking this further, check out JSON.org and take a look at the languages its avaliable in!

I haven't gotten very far with reading the iTunes data in the article... BUT I believe it has potential!!

(I've tried with Json.NET)

Nels said on October 06, 2006

There's some special code that you can use to search the iTunes album art image library. It's pretty cool. It's available in Java, C#, PERL, PHP, Ruby, etc.

http://jroller.com/page/rummage?entry=i7awf_for_java

Kosso said on March 29, 2007

This seems to have been moved now - unfortunately. The url has changed on the site too. Shame. I just tried to 'curl' it to see what it threw back. Nada.

Rowan Walker said on March 29, 2007

It seems they've moved it to http://www.apple.com/global/scripts/ajax_proxy.php

There is some nify code on that page. There is a bizare script and a heap of images just to "jiggle" the iPod Shuffle cliped on to the side of the page (hurry up on APNG I say). Apple is getting some super-cool JS ideas on their website now. The store is so much more usable because of it. Good for them!

joost said on October 10, 2008

Hmm.. all gone by now?

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.

Want to learn about scaling CSS for large projects?

I'm available for full and half-day workshops on scalable CSS architecture. I can provide on-site training for your team. Interested?
Get in touch.