Streaming

The following is documentation for streaming songs using Grooveshark's API. You must have an API key and secret with streaming privileges. API Endpoint: http://api.grooveshark.com/ws3.php?sig={signature}

Payment Options for Streaming

If you would like to include streaming in your application, you must be prepared to pay or make your site available to only Grooveshark Anywhere users. The first option would be to host an ad for us on your site. Grooveshark would collect all the revenues for that ad, it would have to be positioned on the same page as the one where you will be streaming songs and shown so that one impression equals one stream. The second option would be to pay per stream, Grooveshark offers a very low rate per stream and if you do not want ads or cannot place ads, this would be the option. Finally, as stated earlier, you can choose to make your service available to only Grooveshark Anywhere users and thus would not need to pay or host an ad.

If you are looking to integrate streaming into a portable device, then you are required to take the Grooveshark Anywhere route and provide access only to Grooveshark Anywhere users.

Streaming API Process

If you are streaming to any user:

You must send a SessionID with all stream requests.

Before asking for a stream, make sure you have a sessionID. You will send that to our API for every request of which you do not have a user's SessionID. If you can generate a sessionID because you asked for a user's login information, then you should send that with the stream instead, otherwise use a standard sessionID for all non-auth'd streams.

Do not generate a new sessionID for each stream! You should be able to cache your sessionID infinitely and only on an error, should you need to generate a new one via startSession.

If you are only streaming to Grooveshark Anywhere users:

If you are using Grooveshark's API: Start a session using startSession and then use authenticate to authenticate your user.

Verify that they are an Anywhere user and then proceed. Be sure to keep the sessionID generated from startSession and send it along with all stream requests.

Request StreamKey

Make a request to getStreamKeyStreamServer or getSubscriberStreamKey with your sessionID, songID and country. You can use lowBitrate=1 to get a low bitrate file, otherwise send lowBitrate=0.

Sample Request

{"method":"getStreamKeyStreamServer","header":{"wsKey":"key","sessionID":"df8fec35811a6b240808563d9f72fa2"},"parameters":{"songID":27838296,"country":""ID":"223","CC1":"0","CC2":"0","CC3":"0","CC4":"1073741824","IPR":"82"}"}}

Sample Result

{"header":{"hostname":"RHL072"},"result":{"StreamKey":"49f96f87d901402998409bcc616cffec802e8c819_4dc072cd_1a8c758_1d2b5ce_19f7ebe3_8","url":"http://stream57-he.grooveshark.com/stream.php?streamKey=49f96f87d901402998409bcc616cffec802e8c819_4dc072cd_1a8c758_1d2b5ce_19f7ebe3_8", "StreamServerID":32768, "uSecs":220000000}}

Be sure to keep the StreamKey and StreamServerID. The URL can be easily used to send to your player for an mp3.

After 30 Seconds

After the song has been played for 30 seconds, you must call markStreamKeyOver30Secs with your streamkey, serverID and sessionID.

If the song finished and it was played for >= 30 seconds then you must call markSongComplete with the sessionID, songID, streamKey, and serverID.