PHPackages                             sourceout/lastfm-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sourceout/lastfm-php-sdk

ActiveLibrary[API Development](/categories/api)

sourceout/lastfm-php-sdk
========================

LastFM SDK for PHP

1.0.0(7y ago)14MITPHPPHP ^7.1

Since Jul 2Pushed 7y ago2 watchersCompare

[ Source](https://github.com/sourceout/lastfm-php-sdk)[ Packagist](https://packagist.org/packages/sourceout/lastfm-php-sdk)[ RSS](/packages/sourceout-lastfm-php-sdk/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (12)Versions (3)Used By (0)

Last.fm SDK for PHP
===================

[](#lastfm-sdk-for-php)

[![Latest Version](https://camo.githubusercontent.com/19b3bb98e7fc1aa4769b55a62995038634a9ce75fd3cbd361af28690b85c7cf2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f736f757263656f75742f6c617374666d2d7068702d73646b2e737667)](https://github.com/sourceout/lastfm-php-sdk/releases)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE.md) [![Build Status](https://camo.githubusercontent.com/9cc4f4a4e6fb8d50c755207e869cbeea6f7a78ccccc16cc39684d407b0243af7/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f757263656f75742f6c617374666d2d7068702d73646b2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sourceout/lastfm-php-sdk/build-status/master) [![Code Coverage](https://camo.githubusercontent.com/67f2876e259728e054e6c055036d59a4b59e5ac6b5ab6278e134374b50dfed23/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f757263656f75742f6c617374666d2d7068702d73646b2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sourceout/lastfm-php-sdk/) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/83a26ca5b84717a276b5cd99ca79187cf9fa7382888b319402e8baf9f0b00a90/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736f757263656f75742f6c617374666d2d7068702d73646b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sourceout/lastfm-php-sdk/?branch=master)

This repository contains library the allows you to access Last.fm platform from your PHP application.

For details into how authenticate and obtain API Keys read `Getting Started` under [API Introduction](https://www.last.fm/api)

Read the official API Documents at  for more information.

Features
--------

[](#features)

Undermentioned is a list of feature this library provides:

- Support for custom implementations (providers)
- Choice of library used to for sending HTTP Requests
- Framework Agnostic
- Flexible &amp; easy to extend

Installation
------------

[](#installation)

You can install this package via composer using this command:

```
composer require php-http/guzzle6-adapter guzzlehttp/psr7 php-http/message sourceout/lastfm-php-sdk
```

Although, the default installation instruction recommends Guzzle Http client it is not the only client that can be used. Refer the following list [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation) for choices of clients.

For more information on this approach refer this [documentation](http://docs.php-http.org/en/latest/httplug/users.html).

Usage
-----

[](#usage)

```
use Sourceout\LastFm\ProviderInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Sourceout\LastFm\Provider\LastFm\LastFm;

/** @var ProviderInterface $provider */
$provider = new LastFm(['api_key' => 'your_api_key_here']);

/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient();

/** @var Collection $topArtists */
$topArtists = $lastFmClient
    ->getServiceFactory($provider)
    ->getGeoService()
    ->getTopArtists(
        'united states',    // location
        1,                  // page number
        50                  // results per page
    );
```

You can also register your own custom provider instead of using the default, for e.g.

```
use Sourceout\LastFm\Client as LastFmClient;

$lastFmClient = new LastFmClient();

$lastFmClient->registerCustomProviders(
    [
        \path\to\custom\provider::class
        ...
        ...
    ]
);
```

Additionally, although the package features auto-discovery of http package/client, you can also set your own Http Client as well, below are examples where you provide Guzzle6 instance.

#### Method 1

[](#method-1)

```
use Sourceout\LastFm\Http\Http;
use Sourceout\LastFm\Http\HttpInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Http\Adapter\Guzzle6\Client as GuzzleClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;

/** @var HttpInterface $http */
$http = new Http();

$http->setHttpClient(new GuzzleClient());
$http->setMessageFactory(new GuzzleMessageFactory());

/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient($http);
```

#### Method 2

[](#method-2)

```
use Sourceout\LastFm\Http\Http;
use Sourceout\LastFm\Http\HttpInterface;
use Sourceout\LastFm\Client as LastFmClient;
use Http\Adapter\Guzzle6\Client as GuzzleClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;

/** @var HttpInterface $http */
$http = new Http();

$http->setHttpClient(new GuzzleClient());
$http->setMessageFactory(new GuzzleMessageFactory());

/** @var LastFmClient $lastFmClient */
$lastFmClient = new LastFmClient();
$lastFmClient->setHttpClient($http);
```

Supported Methods
-----------------

[](#supported-methods)

There is a long list of API(s) provided by LastFm (ref.: ), undermentioned is the list of methods currently supported by this library:

GeoGeo.getTopArtistsGet the most popular artists on Last.fm by countryGeo.getTopTracksGet the most popular tracks on Last.fm last week by countryTests
-----

[](#tests)

You can run the tests with:

```
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING) for details.

Security
--------

[](#security)

In case, you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

Please see [License File](LICENSE) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2873d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3095b840e70583bcdea3815c4621c196075c292845e1798944d0052a3be8ffaf?d=identicon)[pulkitswarup](/maintainers/pulkitswarup)

---

Top Contributors

[![pulkitswarup](https://avatars.githubusercontent.com/u/1309346?v=4)](https://github.com/pulkitswarup "pulkitswarup (5 commits)")

---

Tags

clientphp-sdklast.fmlastfm-sdk-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sourceout-lastfm-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/sourceout-lastfm-php-sdk/health.svg)](https://phpackages.com/packages/sourceout-lastfm-php-sdk)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[dhope0000/lxd

PHP-based API wrapper for LXD REST API.

136.2k](/packages/dhope0000-lxd)[brd6/notion-sdk-php

Notion SDK for PHP

5918.0k](/packages/brd6-notion-sdk-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
