Strict Standards: Declaration of base_page::setOutput() should be compatible with base::setOutput() in /data/premium-dev/application/controllers/base/base_page.php on line 8

Strict Standards: Declaration of base_page::printErrorAndExit() should be compatible with base::printErrorAndExit() in /data/premium-dev/application/controllers/base/base_page.php on line 8
Musicshake API for developers - songlist

songlist

Get the list of song metadata along with pagination and URL information; search and filter the song library using the parameters for this method.

Parameters

  • api_key - developer key
  • genre_id - the genre ID obtained from the categories method or the genres method
  • tempo - the genre ID obtained from the categories method or the tempos method
  • mood_id - the genre ID obtained from the categories method or the moods method
  • keyword (optional) - song title search string
  • page (optional) - used to specify the page number
  • size (optional, max. 50) - used to specify the number of songs to list per page
  • callback (optional) - callback function name for a JSONP request

Request Example

There are various ways to combine the parameters to get a useful song list.

Genre/Tempo/Mood: use one or more of these parameters to narrow down the song list

http://developers.musicshake.com/api/songlist?api_key=YOUR_API_KEY&genre_id=8,11&tempo=90,140&mood_id=5,13

Song title search: use the keyword parameter to filter through the song titles ; this can be combined with the genre, tempo, and mood parameters

http://developers.localhost/api/songlist?api_key=YOUR_API_KEY&keyword=dirty

Page: although this parameter is optional, it is necessary for the response to include the total_songs ,total_pages, and current_page - which are necessary to create a song list pagination. When the total pages is unknown, use page=1 to find out how many pages exist.

http://developers.musicshake.com/api/songlist?api_key=YOUR_API_KEY&genre_id=8,11&tempo=90,140&mood_id=5,13&size=3&page=1

Song list sorted randomly: when the page parameter is not specified, the song list is returned with a random sort, and without the number of total songs, total pages and current page number.

http://developers.musicshake.com/api/songlist?api_key=YOUR_API_KEY&genre_id=8,11&tempo=90,140&mood_id=5,13&size=3

Response Example

  • total_songs - number of songs (only when page and size paramter is specified)
  • total_pages - number of pages (only when page and size paramter is specified
  • current_page - current page number (only when page and size paramter is specified
  • song_id - song ID
  • genre_id - genre ID
  • tempo - tempo in Beats Per Minute
  • mood_id - mood ID
  • song_title - song title
  • song_length - song length in seconds
  • download_count - number of times the song has been downloaded
  • mp3 - the HTTP song download URL
  • rmtp - the RTMP song streaming URL for Flash players

{"total_pages": "30",
"current_page": "1",
"total_songs": "90",
"list": [
{
	"song_id": "661",
	"genre_id": "11",
	"tempo": "90",
	"mood_id": "4",
	"song_title": "Brilliantly Chattering",
	"song_length": "134",
	"download_count": "0",
	"mp3": "http:\/\/s208ox97i0l791.cloudfront.net\/audioswap\/490\/948\/8d0cb38f-7e9d-43a0-b47a-06be793f8d34.mp3",
	"rtmp": "http:\/\/d21fekboy1ymzq.cloudfront.net\/audioswap\/490\/948\/8d0cb38f-7e9d-43a0-b47a-06be793f8d34.mp3"
},
{
	"song_id": "662",
	"genre_id": "11",
	"tempo": "90",
	"mood_id": "4",
	"song_title": "Screaming Rage",
	"song_length": "134",
	"download_count": "0",
	"mp3": "http:\/\/s208ox97i0l791.cloudfront.net\/audioswap\/601\/345\/deaef2eb-f213-4c38-aed4-b06f4fdf8d8c.mp3",
	"rtmp": "http:\/\/d21fekboy1ymzq.cloudfront.net\/audioswap\/601\/345\/deaef2eb-f213-4c38-aed4-b06f4fdf8d8c.mp3"
},
{
	"song_id": "663",
	"genre_id": "11",
	"tempo": "90",
	"mood_id": "4",
	"song_title": "Exploding Culture",
	"song_length": "134",
	"download_count": "1",
	"mp3": "http:\/\/s208ox97i0l791.cloudfront.net\/audioswap\/865\/751\/234436e1-9e17-4917-8312-cb2c9ebb45dc.mp3",
	"rtmp": "http:\/\/d21fekboy1ymzq.cloudfront.net\/audioswap\/865\/751\/234436e1-9e17-4917-8312-cb2c9ebb45dc.mp3"
}
]}

ActionScript Example

import com.adobe.serialization.json.JSON;
import flash.net.URLLoader;
import flash.events.Event;
import flash.events.IOErrorEvent;

private function loadCategories():void
{
	var requestURL:String = "http://developers-staging.musicshake.com/api/songlist?api_key=YOUR_API_KEY&genre_id=8,11&tempo=90,140&mood_id=5,13&size=3";
	
	var ul:URLLoader = new URLLoader();
	ul.addEventListener(IOErrorEvent.IO_ERROR, onURLLoaderError);
	ul.addEventListener(Event.COMPLETE, onURLLoaderComplete);
	
	try {
		ul.load(new URLRequest(requestURL));
	} catch (error:SecurityError) {
	}
}

private function onURLLoaderError(error:Error):void
{
}

private function onURLLoaderComplete(event:Event):void
{
	trace("total_pages: "+o.total_pages);
	
	for each (var song:Object in o.list) {
		var song_id:Number = song.song_id;
		var genre_id:Number = song.genre_id;
		var tempo:Number = song.tempo;
		var song_title:String = song.song_title;
		var song_length:Number = song.song_length;
		var mp3:String = song.mp3;
		var rtmp:String = song.rtmp;
		
		trace("song_id="+song_id + ", genre_id="+genre_id + ", tempo="+tempo + ", song_title="+song_title + ", song_length="+song_length + ", mp3=" + mp3 + ", rtmp=" + rtmp);
	}
}