A simple but fully featured API wrapper, with Guzzle 6 support

dev-master / 1.0.x-dev 2016-03-24 14:36 UTC

This package is auto-updated.

Last update: 2021-06-11 20:41:22 UTC


Build Status Test Coverage Code Climate Buy me a beer

A dead simple wrapper class for the API. After using a couple of existing wrapper classes, it became obvious that most were either a) Incomplete, b) Seemingly abandoned, or c) Poorly unit tested. After the August 2015 redesign, the library I'd settled with started throwing unexepected errors. At this point, I decided it might be simpler to just write my own.

This library aims to address these issues, providing a simple, centralised way of calling any method on the API, meaning it should support all future API additions out of the box. It also includes an full set of unit tests.


For composer based projects:

composer require chrismou/lastfm


First you need an API key and secret from Last.FM. You can obtain one by signing up here:

To set up the API client:

$lastfm = new \Chrismou\LastFm\LastFm(
    new GuzzleHttp\Client(),

The format for calls is: $lastfm->get($method, $parameters);, where method is the api method name.

So, if you wanted to get info on an artist, you could run:

$lastfm->get('artist.getInfo', 'cher');

This makes a request and returns all info on the Artist 'Cher'.

Please refer to the api documentation for a full list of available methods and required parameters.


To run the unit test suite:

curl -s | php
php composer.phar install

If you use docker, you can also run the test suite against all supported PHP versions:



Released under the MIT License. See LICENSE.

Thanks to

dandelionmood/php-lastfm, the original inspiration for the library.