Skip to content
(perl6) Webservice::Lastfm - interact with the API
Perl 6
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


WebService::Lastfm - interact with's API


my $lastfm =<1234>, :api-secret<music>);

# Read request
say $lastfm.request('user.getInfo', :user<avuserow>);

# Update now playing
say $lastfm.write('track.updateNowPlaying',
    :sk<SECRET KEY>,
    :artist("Alan Parsons Project"),


Bindings for's API using the JSON format (instead of their default XML). You must register for their API to get an API key and API secret.


new($api-key, $api-secret)

Standard new method. All parameters are optional, but the API key is needed for all known requests, and the secret is needed for write methods.

request($method, *%params)

Make an unsigned GET request, used for read-only operations.

write($method, *%params)

Make a signed POST request, used for writing operations, the most famous of which is "scrobbling" (track.scrobble).


X::WebService::Lastfm is thrown on any error responses, with the decoded error message from Check the method's documentation (or the API documentation overall) for the meaning of the code.


  • No packaged tests -- testing things that require API keys is nontrivial
  • The assumption about requests being either GET/unsigned or POST/signed may not be true, in which case more methods may be needed.
  • Undertested in general


  • Switch to HTTP::UserAgent, which needs work to implement this
  • Add tests somehow
  • Example scripts. Ideas include a history exporter and a CLI scrobbler
  • Optional caching mode
  • Some sort of pagination helper for some API calls


  • Rakudo Perl 6
  • LWP::Simple
  • JSON::Tiny
  • URI::Encode
  • Digest::MD5

SEE ALSO's API documentation

You can’t perform that action at this time.