Official PHP library for the Grooveshark Public API
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Grooveshark Public API PHP Library

Officially maintained by James Hartig (@jameshartig). If you run into any problems, file a bug or contact

Documentation about the API can be found at

Version 2 was released on 7/15/13. For changes (including breaking ones), see RELEASE_NOTES.


  • You must have an official public API key/secret. If you do not have one, fill out the request form.
  • Must be running PHP 5.2+

Getting Started

Keep in mind some of the methods below are access controlled and not everyone has access by default to them.

 * Here's an example file that shows how to authenticate to the API and get a list of the user's playlists
 * A live demo can be found at:
$gs = new gsAPI("example", "1a79a4d60de6718e8e5b326e338ae533"); //note: you can also change the default key/secret in gsAPI.php
$user = null;
if (!empty($_SESSION['gsSessionID'])) {
    //since we already have the gsSessionID lets restore that and see if were logged in already to Grooveshark
    if (!empty($_GET['token'])) {
        //we must've gotten back from Grooveshark after the user authenticated
        $user = $gs->authenticateToken($_GET['token']);
        //the logged in user is saved in gsSessionID and you don't need to store anything else on your end
        //when the user refreshes we will restore the gsSessionID and get the user again
    } else { 
        $user = $gs->getUserInfo();
    if (empty($user['UserID'])) {
        //not logged in
        $user = null;
} else {
    //since we didn't already have a gsSessionID, start one with Grooveshark and store it  
    $sessionID = $gs->startSession();
    if (empty($sessionID)) {
        //something failed
    $_SESSION['gsSessionID'] = $sessionID;

//if were already logged in then $user would not be null, and so don't authenticate
if (is_null($user)) {
    //user is not logged in so we must redirect to Grooveshark to get a token to authenticate the user
    //the auth page will ask for the user to approve your app and give permission, upon approval, it'll redirect back
    header("Location:", true, 307);

$playlists = $gs->getUserPlaylists();
if (!is_array($playlists)) {
    //something failed.
foreach ($playlists as $playlist) {
    echo "<p>Playlist: " . htmlentities($playlist['PlaylistName']) . "</p>";

Need help? Something broken?

If you have found a bug file it using Github Issues. Feel free to ping James on Twitter as well.

If you're running into problems with your key, if you're hitting rate limits, or if you're confused, contact They'll be more than happy to help! Sometimes you'll even get a response from James.