{"id":15293856,"url":"https://github.com/barryvanveen/lastfm","last_synced_at":"2025-04-13T13:30:51.615Z","repository":{"id":17628637,"uuid":"75550152","full_name":"barryvanveen/lastfm","owner":"barryvanveen","description":"🎶 Last.fm API client for PHP. Comes with a Laravel service provider.","archived":false,"fork":false,"pushed_at":"2022-06-06T07:36:56.000Z","size":148,"stargazers_count":24,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T04:33:26.549Z","etag":null,"topics":["laravel","laravel-package","lastfm","lastfm-api","php"],"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/barryvanveen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-04T16:41:22.000Z","updated_at":"2024-11-16T06:17:30.000Z","dependencies_parsed_at":"2022-07-24T20:32:24.782Z","dependency_job_id":null,"html_url":"https://github.com/barryvanveen/lastfm","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barryvanveen%2Flastfm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barryvanveen%2Flastfm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barryvanveen%2Flastfm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/barryvanveen%2Flastfm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/barryvanveen","download_url":"https://codeload.github.com/barryvanveen/lastfm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248456370,"owners_count":21106602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["laravel","laravel-package","lastfm","lastfm-api","php"],"created_at":"2024-09-30T16:53:29.727Z","updated_at":"2025-04-13T13:30:49.117Z","avatar_url":"https://github.com/barryvanveen.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Last.fm API client for PHP 8\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Total Downloads][ico-downloads]][link-downloads]\n\n* [API keys](#api-keys)\n* [Installation](#installation)\n* [Laravel installation](#laravel-installation)\n* [Usage](#usage)\n    * [Basic example](#basic-example)\n    * [Laravel example](#laravel-example)\n    * [All available methods](#all-available-methods)\n    * [Filtering results](#filtering-results)\n    * [Valid time periods](#valid-time-periods)\n* [Official API docs](#official-api-docs)\n\n## API keys\nYou can create a last.fm API account at [http://www.last.fm/api/account/create](http://www.last.fm/api/account/create). \n\n## Installation\n\nVia Composer\n\n``` bash\n$ composer require barryvanveen/lastfm\n```\n\n## Laravel installation\n\nAdd a LASTFM_API_KEY variable to your .env configuration. You could also publish the default configuration and alter it\n yourself:\n\n```php\nphp  artisan vendor:publish --provider=\"Barryvanveen\\Lastfm\\LastfmServiceProvider\"\n```\n\nUpdate `config/app.php` by adding the LastfmServiceProvider:\n```php\n'providers' =\u003e [\n    ...\n    Barryvanveen\\Lastfm\\LastfmServiceProvider::class,\n];\n```\n\nIf you are using Laravel 5.5 or higher, the service provider will be detected automagically by Laravel's [package discovery](https://laravel.com/docs/5.5/packages#package-discovery).\n\nTested against Laravel 5.* but probably works in most versions because it is so simple. Please create an issue if it \ndoesn't work for you. \n\n## Usage\n\n### Basic example\n```php\nuse Barryvanveen\\Lastfm\\Lastfm;\nuse GuzzleHttp\\Client;\n \n$lastfm = new Lastfm(new Client(), 'YourApiKey');\n    \n$albums = $lastfm-\u003euserTopAlbums('AnyUsername')-\u003eget();\n```\n\n### Laravel example\n```php\nuse Barryvanveen\\Lastfm\\Lastfm;\n \npublic function index(Lastfm $lastfm)\n{\n    $albums = $lastfm-\u003euserTopAlbums('AnyUsername')-\u003eget();\n    \n    return view('home', compact('albums'));\n}\n```\n\n### All available methods\n```php\n// Get top albums for user\n$albums = $lastfm-\u003euserTopAlbums('AnyUsername')-\u003eget();\n \n// Get top artists for user\n$artists = $lastfm-\u003euserTopArtists('AnyUsername')-\u003eget();\n \n// Get recent tracks for user\n$tracks = $lastfm-\u003euserRecentTracks('AnyUsername')-\u003eget();\n \n// Get user info\n$info = $lastfm-\u003euserInfo('AnyUsername')-\u003eget();\n \n// Get track that user is now listening to, or FALSE\n$trackOrFalse = $lastfm-\u003enowListening('AnyUsername'); \n \n// Get the weekly top albums given a starting day \n$albums = $lastfm-\u003euserWeeklyTopAlbums('AnyUsername', new \\DateTime('2017-01-01'));                      \n \n// Get the weekly top artists given a starting day \n$artists = $lastfm-\u003euserWeeklyTopArtists('AnyUsername', new \\DateTime('2017-01-01'));\n \n// Get the weekly top tracks given a starting day \n$tracks = $lastfm-\u003euserWeeklyTopTracks('AnyUsername', new \\DateTime('2017-01-01'));\n```\n\n### Filtering results\n```php\n// Define time period for results\n$lastfm-\u003euserTopAlbums('AnyUsername')\n       -\u003eperiod(Barryvanveen\\Lastfm\\Constants::PERIOD_WEEK)\n       -\u003eget();\n                  \n// Limit number of results\n$lastfm-\u003euserTopAlbums('AnyUsername')\n       -\u003elimit(5)\n       -\u003eget();     \n                 \n// Retrieve paginated results\n$lastfm-\u003euserTopAlbums('AnyUsername')\n       -\u003elimit(5)\n       -\u003epage(2)\n       -\u003eget();     \n```\n\n### Valid time periods\n```php\n// use these constants as an argument to -\u003eperiod()\nBarryvanveen\\Lastfm\\Constants::PERIOD_WEEK     = '7day';\nBarryvanveen\\Lastfm\\Constants::PERIOD_MONTH    = '1month';\nBarryvanveen\\Lastfm\\Constants::PERIOD_3_MONTHS = '3month';\nBarryvanveen\\Lastfm\\Constants::PERIOD_6_MONTHS = '6month';\nBarryvanveen\\Lastfm\\Constants::PERIOD_YEAR     = '12month';\nBarryvanveen\\Lastfm\\Constants::PERIOD_OVERALL  = 'overall';\n```\n\n## Official API docs\nRead the official API documentation at [http://www.last.fm/api](http://www.last.fm/api).\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\nCopy `phpunit.xml.dist` to `phpunit.xml`. Then run the tests using:  \n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email barryvanveen@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Barry van Veen][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/barryvanveen/lastfm.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/barryvanveen/lastfm.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/barryvanveen/lastfm\n[link-downloads]: https://packagist.org/packages/barryvanveen/lastfm\n[link-author]: https://github.com/barryvanveen\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarryvanveen%2Flastfm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbarryvanveen%2Flastfm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbarryvanveen%2Flastfm/lists"}