{"id":30766703,"url":"https://github.com/calliostro/lastfm-client","last_synced_at":"2026-01-20T16:29:57.702Z","repository":{"id":324064755,"uuid":"1047081059","full_name":"calliostro/lastfm-client","owner":"calliostro","description":"Ultra-lightweight Last.fm API client for PHP 8.1+ with modern Guzzle-based implementation — Only two classes, service descriptions, zero bloats","archived":false,"fork":false,"pushed_at":"2025-12-01T23:21:58.000Z","size":68,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-04T06:54:24.242Z","etag":null,"topics":["api","audioscrobbler","client","guzzle","lastfm","lastfm-api","leightweight","music","php","php8","rest-api","scrobble","scrobbling"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/calliostro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-29T17:54:23.000Z","updated_at":"2025-12-01T17:33:11.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/calliostro/lastfm-client","commit_stats":null,"previous_names":["calliostro/lastfm-client"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/calliostro/lastfm-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calliostro%2Flastfm-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calliostro%2Flastfm-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calliostro%2Flastfm-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calliostro%2Flastfm-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/calliostro","download_url":"https://codeload.github.com/calliostro/lastfm-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calliostro%2Flastfm-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","audioscrobbler","client","guzzle","lastfm","lastfm-api","leightweight","music","php","php8","rest-api","scrobble","scrobbling"],"created_at":"2025-09-04T19:32:32.338Z","updated_at":"2026-01-20T16:29:57.690Z","avatar_url":"https://github.com/calliostro.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⚡ Last.fm API Client for PHP 8.1+ – Lightweight with Maximum Developer Comfort\n\n[![Package Version](https://img.shields.io/packagist/v/calliostro/lastfm-client.svg)](https://packagist.org/packages/calliostro/lastfm-client)\n[![Total Downloads](https://img.shields.io/packagist/dt/calliostro/lastfm-client.svg)](https://packagist.org/packages/calliostro/lastfm-client)\n[![License](https://poser.pugx.org/calliostro/lastfm-client/license)](https://packagist.org/packages/calliostro/lastfm-client)\n[![PHP Version](https://img.shields.io/badge/php-%5E8.1-blue.svg)](https://php.net)\n[![Guzzle](https://img.shields.io/badge/guzzle-%5E6.5%7C%5E7.0-orange.svg)](https://docs.guzzlephp.org/)\n[![CI](https://github.com/calliostro/lastfm-client/actions/workflows/ci.yml/badge.svg)](https://github.com/calliostro/lastfm-client/actions/workflows/ci.yml)\n[![Code Coverage](https://codecov.io/gh/calliostro/lastfm-client/graph/badge.svg?token=0SV4IXE9V1)](https://codecov.io/gh/calliostro/lastfm-client)\n[![PHPStan Level](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg)](https://phpstan.org/)\n[![Code Style](https://img.shields.io/badge/code%20style-PSR12-brightgreen.svg)](https://github.com/FriendsOfPHP/PHP-CS-Fixer)\n\n\u003e **🚀 MINIMAL YET POWERFUL!** Focused, lightweight Last.fm API client — as compact as possible while maintaining modern PHP comfort and clean APIs.\n\n## 📦 Installation\n\n```bash\ncomposer require calliostro/lastfm-client\n```\n\n### Do You Need to Register?\n\n**For ALL API calls:** Registration required\n\n- [Register your application](https://www.last.fm/api/account/create) at Last.fm to get credentials\n- **API Key needed for:** ALL methods (artist info, search, charts, etc.)\n\n**For write operations:** Session authentication required\n\n- **Session Key needed for:** scrobbling, loving tracks, personal collections, tagging\n\n## 🚀 Quick Start\n\n**Read-only data (API key required for all methods):**\n\n```php\n$lastfm = LastFmClientFactory::createWithApiKey('your-api-key', 'your-secret');\n\n$artist = $lastfm-\u003egetArtistInfo('Billie Eilish');          // Get artist info\n$release = $lastfm-\u003egetAlbumInfo('The Weeknd', 'Dawn FM');  // Album info  \n$charts = $lastfm-\u003egetTopArtistsChart();                    // Global charts\n```\n\n**Search with API credentials:**\n\n```php\n$lastfm = LastFmClientFactory::createWithApiKey('your-api-key', 'your-secret');\n\n// Positional parameters (traditional)\n$results = $lastfm-\u003esearchArtists('Taylor Swift', 20);\n$tracks = $lastfm-\u003esearchTracks('Anti-Hero', 'Taylor Swift');\n\n// Named parameters (PHP 8.0+, recommended for clarity)\n$results = $lastfm-\u003esearchArtists(artist: 'Taylor Swift', limit: 20);\n$tracks = $lastfm-\u003esearchTracks(track: 'Anti-Hero', artist: 'Taylor Swift');\n```\n\n**Your scrobbles (session authentication):**\n\n```php\n$lastfm = LastFmClientFactory::createWithSession('your-api-key', 'your-secret', 'your-session-key');\n\n$collection = $lastfm-\u003egetUserRecentTracks('your-username');\n$loved = $lastfm-\u003egetUserLovedTracks('your-username');\n\n// Scrobble and love tracks with named parameters\n$lastfm-\u003escrobbleTrack(\n    artist: 'Bad Bunny',\n    track: 'Un Verano Sin Ti',\n    timestamp: time()\n);\n```\n\n**Multi-user apps (mobile auth):**\n\n```php\n$lastfm = LastFmClientFactory::createWithMobileAuth('your-api-key', 'your-secret', 'your-username', 'your-password');\n\n$identity = $lastfm-\u003egetUserInfo();\n```\n\n## ✨ Key Features\n\n- **Simple Setup** – Works immediately with an API key, easy authentication for advanced features\n- **Complete API Coverage** – All 55+ Last.fm API endpoints supported\n- **Clean Parameter API** – Natural method calls: `getArtistInfo('Billie Eilish')` with named parameter support\n- **Lightweight Focus** – Minimal codebase with only essential dependencies\n- **Modern PHP Comfort** – Full IDE support, type safety, PHPStan Level 8 without bloat\n- **Secure Authentication** – Full session and mobile authentication support\n- **Well Tested** – 100% test coverage, PSR-12 compliant\n- **Future-Ready** – PHP 8.1–8.5 compatible (beta/dev testing)\n- **Pure Guzzle** – Modern HTTP client, no custom transport layers\n\n## 🎵 All Last.fm API Methods as Direct Calls\n\n- **Album Methods** – getAlbumInfo(), searchAlbums(), getAlbumTopTags(), addAlbumTags(), removeAlbumTag(), getAlbumTags()\n- **Artist Methods** – getArtistInfo(), getArtistTopTracks(), getSimilarArtists(), searchArtists(), getArtistTopAlbums(), getArtistCorrection(), addArtistTags(), removeArtistTag(), getArtistTags(), getArtistTopTags()\n- **Track Methods** – getTrackInfo(), searchTracks(), getSimilarTracks(), scrobbleTrack(), updateNowPlaying(), loveTrack(), unloveTrack(), getTrackCorrection(), addTrackTags(), removeTrackTag(), getTrackTags(), getTrackTopTags()\n- **User Methods** – getUserInfo(), getUserRecentTracks(), getUserLovedTracks(), getUserTopArtists(), getUserTopTracks(), getUserTopAlbums(), getUserFriends(), getUserArtistTracks(), getUserPersonalTags(), getUserTopTags()\n- **Chart Methods** – getTopArtistsChart(), getTopTracksChart(), getTopTagsChart()\n- **Geography Methods** – getTopArtistsByCountry(), getTopTracksByCountry()\n- **Tag Methods** – getTagInfo(), getSimilarTags(), getTagTopArtists(), getTagTopTracks(), getTagTopAlbums(), getTopTags(), getTagWeeklyChartList()\n- **Authentication Methods** – getToken(), getSession(), getMobileSession()\n- **Library Methods** – getLibraryArtists()\n- **User Charts** – getUserWeeklyArtistChart(), getUserWeeklyAlbumChart(), getUserWeeklyTrackChart(), getUserWeeklyChartList()\n\n*All Last.fm API endpoints are supported with clean documentation — see [Last.fm API Documentation](https://www.last.fm/api/) for complete method reference*\n\n\u003e 💡 **Note:** Some endpoints require authentication (scrobbling, user libraries) or specific permissions.\n\n## 📋 Requirements\n\n- **php** ^8.1\n- **guzzlehttp/guzzle** ^6.5 || ^7.0\n\n## ⚙️ Configuration\n\n### Configuration\n\n**Simple (works out of the box):**\n\n```php\nuse Calliostro\\LastFm\\LastFmClientFactory;\n\n$lastfm = LastFmClientFactory::createWithApiKey('your-api-key', 'your-secret');\n```\n\n**Advanced (middleware, custom options, etc.):**\n\n```php\nuse Calliostro\\LastFm\\LastFmClientFactory;\nuse GuzzleHttp\\{HandlerStack, Middleware};\n\n$handler = HandlerStack::create();\n$handler-\u003epush(Middleware::retry(\n    fn ($retries, $request, $response) =\u003e $retries \u003c 3 \u0026\u0026 $response?-\u003egetStatusCode() === 429,\n    fn ($retries) =\u003e 1000 * 2 ** ($retries + 1) // Rate limit handling\n));\n\n$lastfm = LastFmClientFactory::createWithApiKey('your-api-key', 'your-secret', [\n    'timeout' =\u003e 30,\n    'handler' =\u003e $handler,\n    'headers' =\u003e [\n        'User-Agent' =\u003e 'MyApp/1.0 (+https://myapp.com)',\n    ]\n]);\n```\n\n\u003e 💡 **Note:** By default, the client uses `LastFmClient/2.0.0 +https://github.com/calliostro/lastfm-client` as User-Agent. You can override this by setting custom headers as shown above.\n\n## 🔐 Authentication\n\nGet credentials at [Last.fm API Registration](https://www.last.fm/api/account/create).\n\n### Quick Reference\n\n| What you want to do         | Method                   | What you need                |\n|-----------------------------|--------------------------|------------------------------|\n| Get artist/track/chart info | `createWithApiKey()`     | API key + secret             |\n| Search the database         | `createWithApiKey()`     | API key + secret             |\n| Scrobble tracks             | `createWithSession()`    | API key + secret + session   |\n| Access user collections     | `createWithSession()`    | API key + secret + session   |\n| Mobile app                  | `createWithMobileAuth()` | API key + secret + user/pass |\n\n### Complete Session Flow Example\n\n**Step 1: authorize.php** – Redirect user to Last.fm\n\n```php\n\u003c?php\n// authorize.php\n\nuse Calliostro\\LastFm\\AuthHelper;\n\n$apiKey = 'your-api-key';\n$secret = 'your-secret';\n$callbackUrl = 'https://yourapp.com/callback.php';\n\n$auth = new AuthHelper($apiKey, $secret);\n\n// For web apps, you can skip token generation and redirect directly:\n$authUrl = \"https://www.last.fm/api/auth/?api_key={$apiKey}\u0026cb=\" . urlencode($callbackUrl);\n\n// For desktop apps, generate token first:\n// $tokenData = $auth-\u003egetToken();\n// $authUrl = $auth-\u003egetAuthorizationUrl($tokenData['token']);\n\nheader(\"Location: {$authUrl}\");\nexit;\n```\n\n**Step 2: callback.php** – Handle Last.fm callback\n\n```php\n\u003c?php\n// callback.php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Calliostro\\LastFm\\{AuthHelper, LastFmClientFactory};\n\n$apiKey = 'your-api-key';\n$secret = 'your-secret';\n$token = $_GET['token'];\n\n$auth = new AuthHelper($apiKey, $secret);\n$sessionData = $auth-\u003egetSession($token);\n\n$sessionKey = $sessionData['session']['key'];\n$username = $sessionData['session']['name'];\n\n// Store tokens for future use\n$_SESSION['lastfm_session_key'] = $sessionKey;\n$_SESSION['lastfm_username'] = $username;\n\n$lastfm = LastFmClientFactory::createWithSession($apiKey, $secret, $sessionKey);\n$user = $lastfm-\u003egetUserInfo();\necho \"Hello \" . $user['user']['name'];\n```\n\n## 🤝 Contributing\n\nContributions are welcome! See [DEVELOPMENT.md](DEVELOPMENT.md) for detailed setup instructions, testing guide, and development workflow.\n\n## 📄 License\n\nMIT License – see [LICENSE](LICENSE) file.\n\n## 🙏 Acknowledgments\n\n- [Last.fm](https://www.last.fm/) for providing the excellent music data and scrobbling API\n- [Guzzle](https://docs.guzzlephp.org/) for the robust HTTP client\n- The PHP community for continuous inspiration\n\n---\n\n\u003e ⭐ **Star this repo if you find it useful!**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalliostro%2Flastfm-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalliostro%2Flastfm-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalliostro%2Flastfm-client/lists"}