Examples of LazyTune API's clients

All the following examples are distributed under the very liberal BSD licence so that you will be able to use and modify it freely.

A Python client

This is a very simple Python example around the LazyTune REST API as documented on http://lazytune.com/api/
This example uses the XML format offered by the API.
Usage examples :

LTClient = LazyTuneClient('YOUR_API_KEY')
print LTClient.call('artist', 'search', 'pete rock', ['pict','mbid'])
print LTClient.call('song', 'search', 'green day', [], 1)
print LTClient.call('album', 'id', 'LDQMzS')

See Python source code

A PHP5 client

This is a very simple PHP5 example around the LazyTune REST API as documented on http://lazytune.com/api/
This example uses the Serialized PHP format offered by the API.
Usage examples :

$LTClient = new LazyTuneClient ('YOUR_API_KEY') ;
print_r ($LTClient->call ('artist', 'search', 'pete rock', array('pict', 'mbid'))) ;
print_r ($LTClient->call ('song', 'search', 'green day', array(), 1)) ;
print_r ($LTClient->call ('album', 'id', 'LDQMzS')) ;

See PHP5 source code

A Perl client

This is a very simple Perl example around the LazyTune REST API as documented on http://lazytune.com/api/
This example uses the XML format offered by the API, so you will have to install the XML::Simple module :

$ perl -MCPAN -e shell
cpan> install XML::Simple

Usage examples :

$LTClient = new LazyTuneClient ('YOUR_API_KEY') ;
print Dumper($LTClient->call('artist', 'search', 'pete rock', 'pict,mbid', 0)) ;
print Dumper($LTClient->call('song', 'search', 'green day', '', 1)) ;
print Dumper($LTClient->call('album', 'id', 'LDQMzS', '', 0)) ;

To run this example use the following command line :

$ perl -MXML::Simple -MLWP::Simple LazyTuneClient.pl

See Perl source code

A Java client

This is a very simple Java example around the LazyTune REST API as documented on http://lazytune.com/api/
This example uses the JSON format offered by the API through the JSON Java library that could be found on http://www.json.org/java/
To use this example you will have to install it.
Usage examples :

public static void main ( String[] args ) throws IOException, JSONException
{
    JSONObject json ;
    String [] options = {"mbid", "pict"} ;
    LazyTuneClient LTClient = new LazyTuneClient ("YOUR_API_KEY") ;
    json = LTClient.call("artist", "search", "pete rock", options, 1) ;
    if (json == null)
        return ;

    System.out.println(json.get("artist")) ;
}

See Java source code