Archives

Tags

Showing articles written in July 2009. Show all articles

A Ruby wrapper for the Discogs.com API

I recently noticed that Discogs.com, a huge discographies database, had released their API in the public domain. I think this is a really nice offering, especially considering effective use of the Ebay API can cost in excess of $50,000 per year...

Unfortunately, I couldn't really think of anything useful to do with the information. So instead I've spent the last few weeks writing a 100% Ruby wrapper for version 1.0 of the API. It abstracts all of the tedious work of handling requests/responses, parsing the XML, etc. This way, if someone else has a good idea (or I have one in the future), most of the work will already be done!

Anyway, enough of that. The specifics:

Support

The library currently supports everything in version 1.0 of the API as documented (sort of) on the Discogs website. Namely:

  • Artists
  • Releases
  • Labels
  • Searching (all of the above

Installation

I've setup the library as a gem so installation is as easy as:

$ gem sources -a http://gems.github.com
$ sudo gem install buntine-discogs

Usage

Here is a small taste of what you can do:

require 'rubygems'
require 'discogs'

wrapper = Discogs::Wrapper.new("my_api_key")
artist = wrapper.get_artist("Master's Hammer")
release = wrapper.get_release("611973") # Supply an ID.

artist.name                        # => Master's Hammer
artist.releases[0].title           # => Finished
artist.releases[1].year            # => 1989
artist.releases[4].extraartists    # => [ "Arakain", "Debustrol" ]

release.title                      # => "Ritual"
release.labels[0].name             # => "Osmose Productions"
release.formats[0].descriptions[0] # => "LP"
release.styles                     # => [ "Black Metal", "Death Metal" ]
release.tracklist[1].title         # => "Pad modly"

Finding out more

I have setup the repository at github. Please let me know of any bugs/problems you find. I'm open to suggestions for improvement, also. Fork me!

On the wiki at github, I have setup a bunch of examples and some documentation for each resource.