Yahoo! Developer Network Blog
« Previous | Main | Next »
August 8, 2008
Y! Music Battle of the APIs in the Key of Ruby
Earlier this week, Yahoo! Music announced the release of their API. Jim Bumgardner, a front-end engineer from the team, gave a nice introduction, which included some examples of what you could do with it. In fact, his post inspired me to dive into the docs to see what else was in there.
Truth be told, the Yahoo! Music API is a substantial entry into the music-related APIs. It offers a powerful and elegant interface to one of the largest music catalogs in the world, including hands-down the largest volume of music videos out there. As a Yahoo! property, it serves a massive user base, whose listening habits power a comprehensive graph of for finding similar artists. Through its corporate partners, Yahoo! Music also enjoys the benefits of direct access to artists and labels from around the world.
The Yahoo! Music API is impressive, but the question remains:
How does it stack up to the reigning champion of music APIs?
How does Yahoo! Music compare to Last.fm?
As you might expect, there's no quick answer. Both offer features that are about on parity, and each have their own advantages and shortcomings, which is to be expected. What's interesting is what those differences are, to see what's truly novel about what Yahoo! Music has to offer.
If you already hip to the whole Last.fm thing, you can skip down to the next section for the gritty details.
A Brief History of Last.fm
Last.fm was one of the first and most notable music APIs, launching right as the Web 2.0 thing was hitting its stride in late 2005. It's greatest strength is its ability to track its user's listening habits real-time, through a process called "Scrobbling". Over a just a few weeks, a user's personal listening habits are matched against everyone else's to see what else you might be interested in. Back in June, Last.fm announced the second iteration of their APIs, which further beefed up its offerings with support for tagging and user sessions. As a long-time Last.fm user, I can vouch for their recommendation engine: no matter how obscure or indie my musical tastes get, it always has great recommendations.
Enough about that, on with the gritty details:
The Gritty Details
![]() |
| |
|---|---|---|
| Protocols | REST, XML-RPC | REST |
| Formats | Plaintext, XML, XSPF, RSS | XML, JSON, RSS |
| API Groups | Album, Artist, Event, Group, Library, Tag, Track, User | Artist, Category, Image, Rating, Release, Station, Track, Video |
| Example Request | http://ws.audioscrobbler.com/2.0/?method=album.getinfo&artist=Jamiroquai&album=Dynamite | http://us.music.yahooapis.com/release/v1/list/artist/252859 |
| Dev Key Required? | Yes (v2.0 only) | Yes |
| Usage Limit | 5 reqs / sec / IP Address | 5,000 reqs / day / App ID |
| Documentation | http://www.last.fm/api/intro | http://developer.yahoo.com/music/api_guide/ |
As far as functionality goes, there's a lot of overlap between these two APIs. Both offer search APIs for Artists, Albums, Tracks, and Users--the bread an butter of any respectable music catalog. Last.fm, being mostly user-generated, categorizes its music using a tag-based folksonomy, whereas Yahoo! takes a top-down approach by using categories, which include genres, eras, and themes.
In terms of unique features, the Last.fm API exposes its database of upcoming performances by artists and other events. It also has supports a wider range of user interactions, including the ability to submit listening information ala "Scrobbling".
On the other hand, Yahoo! Music, is unrivaled in its offering of music videos, and the ability to embed videos directly into web pages is a killer feature. Although less flashy, Yahoo! Music supports spelling recommendations to disambiguate results, which in practice, make it a lot more usable.
Both APIs offer a means of getting and manipulating user data. Last.fm uses session-based authentication tokens, and Y! Music does in its own way, via BBAUTH.
Logistically, there are quite a few differences in how developers can use either of the APIs.
Although the previous version of the Last.fm allowed use without an API key, the new version requires it. Fortunately, their terms of use remain fairly liberal, providing API keys for both commercial and non-commercial use. As far as usage caps, applications can make up to 5 requests per IP address per second.
The terms of use for Y! Music are just like any other Yahoo! API, with the big exception being that use of the Music API is limited to non-commercial use. Requests require an App ID, with which up to 5,000 queries per day can be made.
Lastly, although for the most part a matter of taste, each has their own way of formatting REST requests.
The REST architecture for Last.fm resembles a familiar, object-oriented approach:
http://ws.audioscrobbler.com/2.0/?method=album.getinfo&artist=Jamiroquai&album=Dynamite
By contrast, the relative cryptic nature of the Y! Music API takes a little getting used to, with a typical request looking like:
http://us.music.yahooapis.com/release/v1/list/artist/252859
Rock out with Ruby
Lucky for you, over the course of researching the Y! Music API, I wrote a pretty flexible Ruby library, which will be available as a gem in the next couple of days. You can get the latest version at the project's Github page.
To give you an idea of what it's like, here's a simple example:
require 'yahoo-music'
include Yahoo::Music
Yahoo::Music.app_id = "..." # Put Your App ID Here
artist = Artist.new("Beirut") # Searches by name and uses first result
album = artist.releases.detect{|r| r.title == "Flying Club Cup"}
puts album.title
puts album.artist
puts "Release Date:" + album.released_on.strftime("%m/%d/%Y")
puts
puts "Tracks"
artist.tracks.each_with_index do |track, i|
puts "\t%d %s \t%2d:%2d" % [i, track.title, track.duration / 60, track.duration % 60]
end
Pretty awesome, right? Although the library's still in early development, and doesn't completely cover all of the functionality of the full API yet, feel free to check it out for yourself and tell me what you think.
D.S. al Coda
Actually, talking about libraries is less of a digression than a good stopping-off point for this article. Like I said before, both Last.fm and Y! Music are both excellent music APIs that are definitely worth a look. The best place to start is to just dive into some code and write something.1 I hope that this deeper dive not only gives you a context for what they can do, but also inspire you to get out there and make something awesome.
♪ Happy Hacking,
Mattt Thompson
YDN Tech Evangelist
1 If you're looking for a good Ruby library for Last.fm, be sure to check out John Nunemaker's Scrobbler gem. It has served me well in the past, and was a great source of inspiration when I made my Y! Music library.
Posted at August 8, 2008 8:05 AM | Permalink
Comments
Thanks, it's great to see an evenhanded comparison of both APIs.
Posted by: Anirvan Chatterjee at August 9, 2008 5:01 PM
Post a comment
Comment Policy: We encourage comments and look forward to hearing from you. Please note that Yahoo! may, in our sole discretion, remove comments if they are off topic, inappropriate, or otherwise violate our Terms of Service. Fields marked with asterisk '*' are required.
Subscribe
Recent Blog Articles
view all
YQL Open Table for Google Buzz now live
Tue, 09 Feb 2010
INSERT INTO twitter.status ...
Mon, 08 Feb 2010
Announcing the Yahoo! Brasil Open Hack Day 2010, 20-21 March
Mon, 08 Feb 2010
Marketing hacks, linchpins, and tech women of valor
Sun, 07 Feb 2010
Yahoo! India invites you to join the first India Hadoop Summit
Thu, 04 Feb 2010
Recent Links
Appcelerator Titanium + Yahoo YQL on Vimeo
Mon, 08 Feb 2010
Tue, 02 Feb 2010
PhoneGap | Cross platform mobile framework
Sat, 30 Jan 2010
Web developers can rule the iPad - O'Reilly Radar
Sat, 30 Jan 2010
rc3.org - Is the iPad the harbinger of doom for personal computing?
Thu, 28 Jan 2010
Archives
2010
2009
2008
2007
2006
2005
Recent Readers


