Echonest gem

Installation

Add the gem to your Gemfile

    gem "echonest_resource"

Obtain an API key from echonest and create a file called 'echonest.yml' in your /config directory

    api_key = "YOUR_API_KEY"

Usage

Right now the gem supports two Echonest resources: Artist and Song

Artist

class Artist < ActiveResource::Base
    include EchonestResource::Base
    echonest_resource :artist
end
class Artist < ActiveResource::Base
    include EchonestResource::Base
    echonest_resource :song
end

Now you can search for an artist:

artists = Artist.search("Macklemore")

The search method also accepts an options hash where you can specify things like: results, bucket, sort

artists = Artist.search("Macklemore", {:results => 20, :sort => "hotttnesss-desc"})

Song

You can search for songs for an artist name

songs = Song.find_by_artist_name("Macklemore")

The find_by_artist_name method also accepts an options hash

songs = Song.find_by_artist_name("Macklemore", :sort => "song_hotttnesss")

You can retrieve additional information by specifying a bucket like so:

songs = Song.find_by_artist_name("Macklemore", :bucket => "audio_summary", :results => 20)

All the attributes on the songs use the same name as the Echonest API (http://developer.echonest.com/docs/v4)