PHPackages                             iuliandobrea/lastfm-php - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. iuliandobrea/lastfm-php

ActiveLibrary[HTTP &amp; Networking](/categories/http)

iuliandobrea/lastfm-php
=======================

Last.fm webservice client for php.

00PHP

Since Nov 6Pushed 6mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Last.fm PHP library
===================

[](#lastfm-php-library)

[![Latest Stable Version](https://camo.githubusercontent.com/80ed2597efe47d2f18c0ddc65cc3236c85a40d2c11f00344edcc3f87d9fbf939/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f6c617374666d2f762f737461626c65)](https://packagist.org/packages/nucleos/lastfm)[![Latest Unstable Version](https://camo.githubusercontent.com/675dd827175a18c13f019bf80d6ad9a7e725ac548c6f634d1c45d1c5259b0a0d/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f6c617374666d2f762f756e737461626c65)](https://packagist.org/packages/nucleos/lastfm)[![License](https://camo.githubusercontent.com/007c6780dcad3687a2de87770d63dfa963af698da544fae1dbb75e88b28d368f/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f6c617374666d2f6c6963656e7365)](LICENSE.md)

[![Total Downloads](https://camo.githubusercontent.com/70217d21a695153cc5f40b6a86f794e9d9603af49cac37f7d025210390394fe8/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f6c617374666d2f646f776e6c6f616473)](https://packagist.org/packages/nucleos/lastfm)[![Monthly Downloads](https://camo.githubusercontent.com/211581e2f227609655be7371224fa45e68c2c663da5f1be23e7c24fe3603edfd/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f6c617374666d2f642f6d6f6e74686c79)](https://packagist.org/packages/nucleos/lastfm)[![Daily Downloads](https://camo.githubusercontent.com/230ff6f87bbe68ca5f9ab2b6b525f47b949febe84fc4eb993bdfe19325942ea2/68747470733a2f2f706f7365722e707567782e6f72672f6e75636c656f732f6c617374666d2f642f6461696c79)](https://packagist.org/packages/nucleos/lastfm)

[![Continuous Integration](https://github.com/nucleos/lastfm/actions/workflows/continuous-integration.yml/badge.svg?event=push)](https://github.com/nucleos/lastfm/actions?query=workflow%3A%22Continuous+Integration%22+event%3Apush)[![Code Coverage](https://camo.githubusercontent.com/335f8b5a084ed7a5c9e236b568254eec5887cb621eb8ca70faedbae664ea6337/68747470733a2f2f636f6465636f762e696f2f67682f6e75636c656f732f6c617374666d2f67726170682f62616467652e737667)](https://codecov.io/gh/nucleos/lastfm)

This library provides a wrapper for using the [Last.fm API](http://www.last.fm/api) inside PHP.

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

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:

```
composer require iuliandobrea/lastfm-php
# To define a default http client and message factory
composer require symfony/http-client nyholm/psr7

```

Usage
-----

[](#usage)

```
# Create a client
$apiClient = new \Nucleos\LastFm\Client\ApiClient(
    new \Nucleos\LastFm\Connection\PsrClientConnection(
        new \GuzzleHttp\Client(),
        new \Http\Discovery\Psr17Factory()
    ),
    'API_KEY',
    'SHARED_SECRET'
);

# searching for artist
$artistName = 'Shakira';
$artistApi = new \Nucleos\LastFm\Service\ArtistService($apiClient);
$artistSearchResult = $artistApi->search($artistName, 5);

foreach ($artistSearchResult as $eachArtist) {
    if (empty($eachArtist)) {
        continue;
    }

    $artistId = $eachArtist->getMbid();
    break;
}

# from $artistSearchResult we can obtain $artistId and keep/cache it for future requests

$artistResult = $artistApi->getInfo(
    \Nucleos\LastFm\Builder\ArtistInfoBuilder::forMbid($artistId)
);

# searching for albums
$albumApi = new \Nucleos\LastFm\Service\AlbumService($apiClient);
$albumSearchResult = $albumApi->search($albumTitle, 10);

$albumGetInfoResult = $albumApi->getInfo(
    \Nucleos\LastFm\Builder\AlbumInfoBuilder::forAlbum($artistName, $albumTitle)
);

$albumGetInfoResult = $albumApi->getInfo(
    \Nucleos\LastFm\Builder\AlbumInfoBuilder::forMbid($albumId)
);

# search for records
$trackApi = new \Nucleos\LastFm\Service\TrackService($apiClient);
$result = $trackApi->getInfo(
    \Nucleos\LastFm\Builder\TrackInfoBuilder::forMbid($recordingId)
);

#
$chartApi = new \Nucleos\LastFm\Service\ChartService($apiClient);
$tags = $chartApi->getTopTags(10);
```

Limitations
-----------

[](#limitations)

Last.fm removed some of their favorite APIs due their relaunch in March 2016. Some of the following removed methods are available via a webcrawler. Please have a look at the `Nucleos\LastFm\Crawler` package.

```
    Album
        album.getBuylinks
        album.getShouts
        album.share
    Artist
        artist.getEvents
        artist.getPastEvents
        artist.getPodcast
        artist.getShouts
        artist.getTopFans
        artist.share
        artist.shout
    Chart
        chart.getHypedArtists
        chart.getHypedTracks
        chart.getLovedTracks
    Event
        event.attend
        event.getAttendees
        event.getInfo
        event.getShouts
        event.share
        event.shout
    Geo
        geo.getEvents
        geo.getMetroArtistChart
        geo.getMetroHypeArtistChart
        geo.getMetroHypeTrackChart
        geo.getMetroTrackChart
        geo.getMetroUniqueArtistChart
        geo.getMetroUniqueTrackChart
        geo.getMetroWeeklyChartlist
        geo.getMetros
    Group
        group.getHype
        group.getMembers
        group.getWeeklyAlbumChart
        group.getWeeklyArtistChart
        group.getWeeklyChartList
        group.getWeeklyTrackChart
    Library
        library.addAlbum
        library.addArtist
        library.addTrack
        library.getAlbums
        library.getTracks
        library.removeAlbum
        library.removeArtist
        library.removeScrobble
        library.removeTrack
    Playlist
        playlist.addTrack
        playlist.create
    Radio
        radio.getPlaylist
        radio.search
        radio.tune
    Tag
        tag.getWeeklyArtistChart
        tag.search
    Tasteometer
        tasteometer.compare
        tasteometer.compareGroup
    Track
        track.ban
        track.getBuylinks
        track.getFingerprintMetadata
        track.getShouts
        track.getTopFans
        track.share
        track.unban
    User
        user.getArtistTracks
        user.getBannedTracks
        user.getEvents
        user.getNeighbours
        user.getNewReleases
        user.getPastEvents
        user.getPlaylists
        user.getRecentStations
        user.getRecommendedArtists
        user.getRecommendedEvents
        user.getShouts
        user.shout
        user.signUp
        user.terms
    Venue
        venue.getEvents
        venue.getPastEvents
        venue.search

```

License
-------

[](#license)

This library is under the [MIT license](LICENSE.md).

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance47

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor2

2 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/21a5476be8e4f627cf4141cd87f9ca8b81b77f3d1d02102ac60c6da4f2e277f2?d=identicon)[iuliandobrea](/maintainers/iuliandobrea)

---

Top Contributors

[![core23](https://avatars.githubusercontent.com/u/3440437?v=4)](https://github.com/core23 "core23 (386 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (255 commits)")[![nucleos-bot](https://avatars.githubusercontent.com/u/60489587?v=4)](https://github.com/nucleos-bot "nucleos-bot (252 commits)")[![kodiakhq[bot]](https://avatars.githubusercontent.com/in/29196?v=4)](https://github.com/kodiakhq[bot] "kodiakhq[bot] (43 commits)")[![iuliandobrea](https://avatars.githubusercontent.com/u/7261184?v=4)](https://github.com/iuliandobrea "iuliandobrea (8 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (5 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (2 commits)")[![jstowey](https://avatars.githubusercontent.com/u/5090149?v=4)](https://github.com/jstowey "jstowey (1 commits)")

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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