PHPackages                             thatobabusi/laravel-lastfm - 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. thatobabusi/laravel-lastfm

ActiveLibrary[API Development](/categories/api)

thatobabusi/laravel-lastfm
==========================

Last.fm API client for Laravel 7-13

v2.0.2(1mo ago)023[3 PRs](https://github.com/thatobabusi/laravel-lastfm/pulls)MITPHPPHP &gt;=7.4CI failing

Since Jul 12Pushed 3w ago1 watchersCompare

[ Source](https://github.com/thatobabusi/laravel-lastfm)[ Packagist](https://packagist.org/packages/thatobabusi/laravel-lastfm)[ Docs](https://github.com/thatobabusi/laravel-lastfm)[ RSS](/packages/thatobabusi-laravel-lastfm/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

[![Last.fm API Client for Laravel](https://camo.githubusercontent.com/89f89a409b4eee6b524ab2e14bcb493d44c110c03334f076520c8258ab81368e/68747470733a2f2f63617073756c652d72656e6465722e76657263656c2e6170702f6170693f747970653d776176696e6726636f6c6f723d303a6239316331632c35303a6463323632362c3130303a656634343434266865696768743d3138302673656374696f6e3d68656164657226746578743d4c6173742e666d25323041504926666f6e7453697a653d353226666f6e74436f6c6f723d66666666666626616e696d6174696f6e3d66616465496e26666f6e74416c69676e593d333526646573633d547970652d53616665253230436c69656e742532302537432532304c61726176656c253230372d3133253230253743253230466c75656e74253230496e746572666163652664657363416c69676e593d3535266465736353697a653d3136)](https://camo.githubusercontent.com/89f89a409b4eee6b524ab2e14bcb493d44c110c03334f076520c8258ab81368e/68747470733a2f2f63617073756c652d72656e6465722e76657263656c2e6170702f6170693f747970653d776176696e6726636f6c6f723d303a6239316331632c35303a6463323632362c3130303a656634343434266865696768743d3138302673656374696f6e3d68656164657226746578743d4c6173742e666d25323041504926666f6e7453697a653d353226666f6e74436f6c6f723d66666666666626616e696d6174696f6e3d66616465496e26666f6e74416c69676e593d333526646573633d547970652d53616665253230436c69656e742532302537432532304c61726176656c253230372d3133253230253743253230466c75656e74253230496e746572666163652664657363416c69676e593d3535266465736353697a653d3136)[ ![Typing intro](https://camo.githubusercontent.com/272e6cc04dadbd3e06aed0a8c89041be829316a5c510cf1ab0ff8474fa65ec33/68747470733a2f2f726561646d652d747970696e672d7376672e64656d6f6c61622e636f6d3f666f6e743d466972612b436f6465267765696768743d3530302673697a653d31382670617573653d3132303026636f6c6f723d6463323632362663656e7465723d74727565267643656e7465723d747275652677696474683d363530266c696e65733d636f6d706f7365722b726571756972652b746861746f6261627573692f6c61726176656c2d6c617374666d3b547970652d736166652b2545322538302541322b466c75656e742b4150492b2545322538302541322b4c61726176656c2b372d31333b4765742b757365722b73746174732b2532432b747261636b732b2532432b2532362b636861727473)](https://github.com/thatobabusi/laravel-lastfm)[![Repo stars](https://camo.githubusercontent.com/d7eb5275fac44d2df432a7b2f1490fae9bf2d94a4fb59e589759a0b083324f87/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6162656c436f6c6f723d31613162323726636f6c6f723d646332363236)](https://github.com/thatobabusi/laravel-lastfm/stargazers)[![Repo forks](https://camo.githubusercontent.com/8da1a5100f90243e7578c5ae1b62d0287df585f3659f296ad3aa853b6ed1f310/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6162656c436f6c6f723d31613162323726636f6c6f723d656634343434)](https://github.com/thatobabusi/laravel-lastfm/forks)[![Repo watchers](https://camo.githubusercontent.com/0bdb57e0dbe301842191185537b35ae25874647d1aae4a951277c28825d7a0ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f77617463686572732f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6162656c436f6c6f723d31613162323726636f6c6f723d393931623162)](https://github.com/thatobabusi/laravel-lastfm/watchers)

[![Latest release](https://camo.githubusercontent.com/3853ada72755f766a6bc28be3c6adb1df3075186dd3ed766b2078294aacaa969/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6162656c436f6c6f723d31613162323726636f6c6f723d386235636636)](https://github.com/thatobabusi/laravel-lastfm/releases)[![Last commit](https://camo.githubusercontent.com/906edd20a7a06ae681dd38a5c5f92fe1ed30880109805b620548c41849f3b08a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d676974266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d31613162323726636f6c6f723d323263353565)](https://github.com/thatobabusi/laravel-lastfm/commits/main)[![Open issues](https://camo.githubusercontent.com/cfd62b7e43150c5837e2b504fbed3bb1dc15930fa44a1de262574acc14d011c2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6162656c436f6c6f723d31613162323726636f6c6f723d663937333136)](https://github.com/thatobabusi/laravel-lastfm/issues)[![Open pull requests](https://camo.githubusercontent.com/429e2f2b52223add94c7a1c297fb7916576dce184e580c38d98f09ed91ca151b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6162656c436f6c6f723d31613162323726636f6c6f723d656334383939)](https://github.com/thatobabusi/laravel-lastfm/pulls)[![License](https://camo.githubusercontent.com/c822a94ad5ec7b8c92e490407d42e73569da47b189657cc0b59c64940c10f182/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6162656c436f6c6f723d31613162323726636f6c6f723d363437343862)](LICENSE.md)[![Contributors](https://camo.githubusercontent.com/bf59fbd846def61304f00fb37faa9fbde883455c09ac9b21d99919f8e87c6c62/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6162656c436f6c6f723d31613162323726636f6c6f723d313462386136)](https://github.com/thatobabusi/laravel-lastfm/graphs/contributors)

[![Packagist](https://camo.githubusercontent.com/3f8df644b92f654e948693771d9e390025a9bbb245632900c3a7db7def6de6da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d636f6d706f736572266c6162656c436f6c6f723d31613162323726636f6c6f723d646332363236)](https://packagist.org/packages/thatobabusi/laravel-lastfm)[![Downloads](https://camo.githubusercontent.com/66099b403d60bb7c92566386ad5c1816c06292a52c79d1bf5126a5d3fd221372/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746861746f6261627573692f6c61726176656c2d6c617374666d3f7374796c653d666c61742d737175617265266c6f676f3d636f6d706f736572266c6162656c436f6c6f723d31613162323726636f6c6f723d656634343434)](https://packagist.org/packages/thatobabusi/laravel-lastfm)[![MIT License](https://camo.githubusercontent.com/22a94275e80b12ef23021a835b5f0d5b115cc6ecfd66fc77bdff4e34690e879b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265266c6162656c436f6c6f723d31613162323726636f6c6f723d323263353565)](LICENSE.md)

**[📦 Packagist](https://packagist.org/packages/thatobabusi/laravel-lastfm)** · **[📚 Docs](#documentation)** · **[📜 Changelog](docs/CHANGELOG.md)** · **[🔗 Last.fm API](https://www.last.fm/api)**

---

A modern, type-safe Last.fm API client for Laravel 7-13. Built with fluent interfaces, full type hints, and dependency injection support.

Documentation
-------------

[](#documentation)

### Features

[](#features)

**API Integration**

- Fluent interface for all major Last.fm API endpoints
- User statistics and track information retrieval
- Weekly and overall chart data
- Now-playing track detection

**Laravel Integration**

- Auto-registration via package discovery (Laravel 5.5+)
- Dependency injection support
- Configuration publishing
- Service provider binding

**Developer Experience**

- Full type hints and strict mode
- Chainable query builder pattern
- Per-request period and limit filtering
- Tested against Laravel 7, 8, 9, 10, 11, 12, and 13

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- Laravel &gt;= 7.0
- Guzzle HTTP Client 6 or 7

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

[](#installation)

Install via Composer:

```
composer require thatobabusi/laravel-lastfm
```

Configuration
-------------

[](#configuration)

Add your Last.fm API key to your `.env` file:

```
LASTFM_API_KEY=your_api_key_here
```

Or publish and customize the configuration file:

```
php artisan vendor:publish --provider="Thatobabusi\LaravelLastFm\LastfmServiceProvider"
```

For Laravel versions prior to 5.5, manually register the service provider in `config/app.php`:

```
'providers' => [
    ...
    Thatobabusi\LaravelLastFm\LastfmServiceProvider::class,
];
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

Inject the `Lastfm` class into your controller or service:

```
use Thatobabusi\LaravelLastFm\Lastfm;

public function topAlbums(Lastfm $lastfm)
{
    $albums = $lastfm->userTopAlbums('username')->get();
    return view('albums', compact('albums'));
}
```

### Available Methods

[](#available-methods)

**User Statistics**

- `userTopAlbums(string $username)` — Get user's top albums
- `userTopArtists(string $username)` — Get user's top artists
- `userTopTracks(string $username)` — Get user's top tracks
- `userInfo(string $username)` — Get user profile information
- `userRecentTracks(string $username)` — Get user's recent tracks

**Real-time Data**

- `nowListening(string $username)` — Get currently playing track (or `false`)

**Weekly Charts**

- `userWeeklyTopAlbums(string $username, DateTime $startdate)` — Get weekly top albums
- `userWeeklyTopArtists(string $username, DateTime $startdate)` — Get weekly top artists
- `userWeeklyTopTracks(string $username, DateTime $startdate)` — Get weekly top tracks
- `userWeeklyChartList(string $username)` — Get list of available weekly charts

### Filtering Results

[](#filtering-results)

Chain methods to customize your queries:

```
use Thatobabusi\LaravelLastFm\Constants;

// Filter by time period
$lastfm->userTopAlbums('username')
    ->period(Constants::PERIOD_MONTH)
    ->get();

// Limit results
$lastfm->userTopAlbums('username')
    ->limit(5)
    ->get();

// Paginate through results
$lastfm->userTopAlbums('username')
    ->limit(10)
    ->page(2)
    ->get();
```

### Time Periods

[](#time-periods)

Use these constants with the `->period()` method:

```
Constants::PERIOD_WEEK       // Last 7 days
Constants::PERIOD_MONTH      // Last month
Constants::PERIOD_3_MONTHS   // Last 3 months
Constants::PERIOD_6_MONTHS   // Last 6 months
Constants::PERIOD_YEAR       // Last 12 months
Constants::PERIOD_OVERALL    // All time
```

Getting an API Key
------------------

[](#getting-an-api-key)

Create a Last.fm account and generate an API key at:

API Documentation
-----------------

[](#api-documentation)

For complete Last.fm API reference, see:

Testing
-------

[](#testing)

Copy `phpunit.xml.dist` to `phpunit.xml` and configure your Last.fm API key, then run:

```
composer test
```

🤝 Contributing
--------------

[](#-contributing)

Issues and pull requests are welcome for **bug fixes, features, and documentation**.
Please see [CONTRIBUTING.md](CONTRIBUTING.md) and [CODE OF CONDUCT](CONDUCT.md) for details.

🔒 Security
----------

[](#-security)

If you discover a security vulnerability, please email **** instead of using the issue tracker.

📜 License
---------

[](#-license)

Open-sourced software licensed under the [MIT license](LICENSE.md).
Built with ❤️ for the Laravel community.

[![Footer wave](https://camo.githubusercontent.com/c81d3fbc06736808f3d0a3092de651bdbf667b2498bdf5347c4c0bab84063a75/68747470733a2f2f63617073756c652d72656e6465722e76657263656c2e6170702f6170693f747970653d776176696e6726636f6c6f723d303a3766316431642c35303a6463323632362c3130303a656634343434266865696768743d3130302673656374696f6e3d666f6f746572)](https://camo.githubusercontent.com/c81d3fbc06736808f3d0a3092de651bdbf667b2498bdf5347c4c0bab84063a75/68747470733a2f2f63617073756c652d72656e6465722e76657263656c2e6170702f6170693f747970653d776176696e6726636f6c6f723d303a3766316431642c35303a6463323632362c3130303a656634343434266865696768743d3130302673656374696f6e3d666f6f746572)

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance94

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 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

38d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e7e2f3e8d741b934f10633f03834a0b8ba5ad642f1ef56ed7dbe4408726bbd9c?d=identicon)[thatobabusi](/maintainers/thatobabusi)

---

Top Contributors

[![thatobabusi](https://avatars.githubusercontent.com/u/6802518?v=4)](https://github.com/thatobabusi "thatobabusi (3 commits)")

---

Tags

api-clientfluent-interfacelaravellastfmphptype-safeapiclientlaravelservice providerlast.fm

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/thatobabusi-laravel-lastfm/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.7M3.4k](/packages/craftcms-cms)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[barryvanveen/lastfm

Last.fm API client for PHP 7+

264.6k](/packages/barryvanveen-lastfm)

PHPackages © 2026

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