unofficial API library
Pull request Compare This branch is 99 commits behind sosedoff:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Grooveshark API

Unofficial grooveshark API ruby library gives your ability to search and stream songs, manage playlists, media library and favorites. API was discovered using http proxy and does not pretend to be always valid due to website API changes.


gem install grooveshark

Getting Started

Lets first create a session. Grooveshark session is a regular PHP session with expiration date of 7 days.

require 'rubygems'
require 'grooveshark'

client =

To get session key just call

session = client.session

You can store this key for 7 days after creation and use it like this:

client =

Now we can find some songs:

songs = client.search_songs('Nirvana')

songs.each do |s|          # Song ID        # Song name
  s.artist      # Song artist name
  s.album       # Song album name
  s.duration    # Song duration in seconds (not always present, 0 by default)

We got collection of songs. Check Song object for additional attributes. In order to stream song we need to get the authorization

song = songs.first
url = client.get_song_url(song)

Given url is valid only for current session and cannot be shared or stored permanently. Also, it probably violates terms of service.

User Authentication

To get your user account you need to provide username and password. If username or password is not valid InvalidAuthentication exception will be raised.

client =

  user = client.login('username', 'password')
rescue InvalidAuthentication
  puts "Oooops! Wrong username or password"

Playlists and favorites

Get all user playlists

user.playlists.each do |p|          # Playlist ID        # Playlist name
  p.about       # Playlist description (empty by default)

Get user playlist

playlist = user.get_playlist(PLAYLIST_ID)

Get all playlist songs

playlist = user.get_playlist(ID)
songs = playlist.songs

Rename existing playlist

playlist = user.get_playlist(ID)
playlist.rename('NEW NAME', 'NEW DESCRIPTION')

Delete existing user playlist

playlist = user.get_playlist(ID)

Create a new playlist. First parameter is mandatory, description and songs are optional. For songs you can provide array of Song objects or array of IDs.

songs = client.search_songs('Joe Satriani')
p = user.create_playlist('NAME', 'DESCRIPTION', songs)

Get user favorite songs

songs = user.favorites

Add song to favorites

user.add_favorite(song) # Song object or song ID

Remove song from favorites

user.remove_favorite(song) # Song object or song ID

User library

Get all songs from library as a collection of Song objects

songs = user.library

Add songs to library

songs = client.search_songs('The Beatles')

Remove selected songs from library. Unfortunately mass-deletion is not supported by Grooveshark API. You will have to delete each song via separate method call.

song = user.library.first # Lest pick a first song in the library

Explore community

Get all recently active users


Find user by ID


Find user by username


Fetch recent user activity

user = client.get_user_by_username('user')

Known issues

  • Communication token gets rejected after some time. This timeframe is always different. Additional research didnt show any results.


  • Testing

  • Library management coverage

  • More methods