PHPackages                             gerenuk/spotify-for-laravel - 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. gerenuk/spotify-for-laravel

AbandonedArchivedLibrary[API Development](/categories/api)

gerenuk/spotify-for-laravel
===========================

A Laravel wrapper for the Spotify Web API.

v2.3.5(1y ago)0100[4 PRs](https://github.com/Gerenuk-LTD/spotify-for-laravel/pulls)MITPHPPHP ^8.1

Since Mar 16Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Gerenuk-LTD/spotify-for-laravel)[ Packagist](https://packagist.org/packages/gerenuk/spotify-for-laravel)[ Docs](https://github.com/gerenuk-ltd/spotify-for-laravel)[ GitHub Sponsors](https://github.com/Gerenuk)[ RSS](/packages/gerenuk-spotify-for-laravel/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (14)Versions (19)Used By (0)

[![Project banner](https://camo.githubusercontent.com/ec000f972d72c6f6221ceb3ee6488d5efe2ee5504f015a66d7e0871636585729/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f53706f74696679253230666f722532304c61726176656c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d676572656e756b25324673706f746966792d666f722d6c61726176656c267061747465726e3d627269636b57616c6c267374796c653d7374796c655f31266465736372697074696f6e3d412b4c61726176656c2b777261707065722b666f722b7468652b53706f746966792b5765622b415049266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/ec000f972d72c6f6221ceb3ee6488d5efe2ee5504f015a66d7e0871636585729/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f53706f74696679253230666f722532304c61726176656c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d676572656e756b25324673706f746966792d666f722d6c61726176656c267061747465726e3d627269636b57616c6c267374796c653d7374796c655f31266465736372697074696f6e3d412b4c61726176656c2b777261707065722b666f722b7468652b53706f746966792b5765622b415049266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

Spotify for Laravel
===================

[](#spotify-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9ff33ea9fa0e2c87addb29b01e65d04fd8baa417da157787d5528c48854e2ad8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676572656e756b2f73706f746966792d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gerenuk/spotify-for-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3df72bf9bb96d7a9282b7238e9d2c4bc5fd21a2ad2a12e4782b70ac3bf6db486/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f676572656e756b2d6c74642f73706f746966792d666f722d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/gerenuk-ltd/spotify-for-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/61e45a4260141d653e9908912ff58786356bd05d31b90ad0fe441bc560417262/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f676572656e756b2d6c74642f73706f746966792d666f722d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/gerenuk-ltd/spotify-for-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/794b27e034d73ff31160f606aca13e5353884661ad25737c5cd582e170ec9984/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f676572656e756b2f73706f746966792d666f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gerenuk/spotify-for-laravel)

Spotify for Laravel is an easy-to-use [Spotify Web API](https://developer.spotify.com/documentation/web-api) wrapper for Laravel, providing methods for each endpoint and a fluent interface for optional parameters. It is based on [aerni/laravel-spotify](https://github.com/aerni/laravel-spotify) adding support for the ['Authorization Code Flow'](https://developer.spotify.com/documentation/web-api/tutorials/code-flow).

Note

This package is still under development and may not support all endpoints.

Table of Contents
-----------------

[](#table-of-contents)

1. [Introduction](#spotify-for-laravel)
2. [Version Compatability](#version-compatability)
3. [Installation](#installation)
4. [Usage](#usage)
5. [Optional Parameters](#optional-parameters)
6. [Spotify API Reference](#spotify-api-reference)
    - [Albums](#albums)
    - [Artists](#artists)
    - [Audiobooks](#audiobooks)
    - [Categories](#categories)
    - [Chapters](#chapters)
    - [Episodes](#episodes)
    - [Markets](#markets)
    - [Player](#player)
    - [Playlists](#playlists)
    - [Search](#search)
    - [Shows](#shows)
    - [Tracks](#tracks)
    - [Users](#users)
7. [Testing](#testing)
8. [Changelog](#changelog)
9. [Contributing](#contributing)
10. [Security Vulnerabilities](#security-vulnerabilities)
11. [Credits](#credits)
12. [License](#license)

Version Compatability
---------------------

[](#version-compatability)

PluginPHP1.x8.x2.x8.xInstallation
------------

[](#installation)

You can install the package via composer:

```
composer require gerenuk/spotify-for-laravel
```

You can publish the config file with:

```
php artisan vendor:publish --tag="spotify-for-laravel-config"
```

This is the contents of the published config file:

```
return [
    /*
    |--------------------------------------------------------------------------
    | API Base URL
    |--------------------------------------------------------------------------
    |
    | Here you may define the base URL of the Spotify API.
    |
    */

    'api_url' => 'https://api.spotify.com/v1',

    /*
    |--------------------------------------------------------------------------
    | Authentication
    |--------------------------------------------------------------------------
    |
    | Here you may define the required settings depending on which auth flow
    | you are using.
    |
    */

    'auth' => [
        'client_id' => env('SPOTIFY_CLIENT_ID'),
        'client_secret' => env('SPOTIFY_CLIENT_SECRET'),
        'redirect_uri' => '',
        'scope' => [],
        'show_dialog' => false,
    ],

    /*
    |--------------------------------------------------------------------------
    | Default Config
    |--------------------------------------------------------------------------
    |
    | You may define a default country, locale and market that will be used
    | for your Spotify API requests.
    |
    */

    'default_config' => [
        'country' => null,
        'locale' => null,
        'market' => null,
    ],
];
```

Set the `Client ID` and `Client Secret` of your [Spotify App](https://developer.spotify.com/dashboard) in your `.env` file.

```
SPOTIFY_CLIENT_ID=********************************
SPOTIFY_CLIENT_SECRET=********************************
```

Note

You will need to set the 'scope' and 'redirect\_uri' if using endpoints that access user data.

Usage
-----

[](#usage)

Before using the methods in this package you will need to generate an `access_token`.

```
using Gerenuk\SpotifyForLaravel\Facades\SpotifyAuth;

// Using the 'Authorization Code Flow'.
SpotifyAuth::authorize();
SpotifyAuth::generateAccessToken('code'); // redirect_uri?code=

// Using the 'Credentials Flow'.
SpotifyAuth::generateCredentialsToken();
```

Once the `access_token` has expired you will need to generate a new one, this can be done by:

```
using Gerenuk\SpotifyForLaravel\Facades\SpotifyAuth;

// Using the 'Authorization Code Flow'.
SpotifyAuth::refreshAccessToken();

// Using the 'Credentials Flow'.
SpotifyAuth::generateCredentialsToken();
```

Below is a simple example of searching for tracks with the name `Closed on Sunday`:

```
use Gerenuk\SpotifyForLaravel\Facades\Spotify;

Spotify::searchTracks('Closed on Sunday')->get();
```

**Important:** The `get()` method acts as the final method of the fluent interface. Make sure to always call it last in the method chain to execute a request to the Spotify Web API.

Optional Parameters
-------------------

[](#optional-parameters)

You may pass optional parameters to your requests using the fluent interface provided by this package. A common use case is to set a `limit` and `offset` to your request.

```
Spotify::searchTracks('Closed on Sunday')->limit(50)->offset(50)->get();
```

### Parameter Methods API Reference

[](#parameter-methods-api-reference)

Consult the [Spotify Web API Reference Documentation](https://developer.spotify.com/documentation/web-api/reference/) to check which parameters are available to what endpoint.

```
// Limit the response to a particular geographical market.
Spotify::artistAlbums('artist_id')->country('US')->get();

// Filter the query using the provided string.
Spotify::playlist('playlist_id')->fields('description, uri')->get();

// Include any relevant content that is hosted externally.
Spotify::searchTracks('query')->includeExternal('audio')->get();

// Filter the response using the provided string.
Spotify::artistAlbums('artist_id')->includeGroups('album, single, appears_on, compilation')->get();

// Set the number of track objects to be returned.
Spotify::searchTracks('query')->limit(10)->get();

// Set the index of the first track to be returned.
Spotify::searchTracks('query')->offset(10)->get();

// Limit the response to a particular geographical market.
Spotify::searchAlbums('query')->market('US')->get();

// Limit the response to a particular language.
Spotify::category('category_id')->locale('en_US')->get();
```

### Resetting Defaults

[](#resetting-defaults)

You may want to reset the default setting of `country`, `locale` or `market` for a given request. You may do so by calling the corresponding parameter method with an empty argument.

```
// This will reset the default market to nothing.
Spotify::searchTracks('query')->market()->get();
```

### Response Key

[](#response-key)

Some API responses are wrapped in a top level object like `artists` or `tracks`. If you want to directly access the content of a given top level object, you may do so by passing its key as a string to the `get()` method.

```
// This will return the content of the tracks object.
Spotify::searchTracks('query')->get('tracks');
```

Spotify API Reference
---------------------

[](#spotify-api-reference)

**Note:** Any parameter that accepts multiple values can either receive a string with comma-separated values or an array of values.

```
// Pass a string with comma-separated values
Spotify::albums('album_id, album_id_2, album_id_3')->get();

// Or pass an array of values
Spotify::albums(['album_id', 'album_id_2', 'album_id_3'])->get();
```

### Albums

[](#albums)

```
// Get an album by ID.
Spotify::album('album_id')->get();

// Get several albums by IDs. Provide a string or array of IDs.
Spotify::albums('album_id, album_id_2, album_id_3')->get();

// Get the tracks of an album by ID.
Spotify::albumTracks('album_id')->get();

// Get the currently authenticated users saved albums.
Spotify::currentUsersSavedAlbums()->get();

// Save one or more albums to the currently authenticated users' library.
Spotify::currentUsersSavedAlbums()->add('album_id', 'album_id_2', 'album_id_3')->save();

// Remove one or more albums to the currently authenticated users' library.
Spotify::currentUsersSavedAlbums()->remove('album_id', 'album_id_2', 'album_id_3')->save();

// Check if one or more albums are saved by the currently authenticated user.
Spotify::currentUsersSavedAlbums()->contains('album_id', 'album_id_2', 'album_id_3')->check();

// Get new album releases shown in the Spotify browse tab.
Spotify::newReleases()->get();
```

### Artists

[](#artists)

```
// Get an artist by ID.
Spotify::artist('artist_id')->get();

// Get several artists by IDs. Provide a string or array of IDs.
Spotify::artists('artist_id, artist_id_2, artist_id_3')->get();

// Get albums of an artist by ID.
Spotify::artistAlbums('artist_id')->get();

// Get the artist's top tracks by ID.
Spotify::artistTopTracks('artist_id')->get();
```

### Audiobooks

[](#audiobooks)

```
// Get an audiobook by ID.
Spotify::audiobook('audiobook_id')->get();

// Get several audiobooks by IDs. Provide a string or array of IDs.
Spotify::audiobooks('audiobook_id, audiobook_id_2, audiobook_id_3')->get();

// Get chapters of an audiobook by ID.
Spotify::audiobookChapters('audiobook_id')->get();

// Get the currently authenticated users saved audiobooks.
Spotify::currentUsersSavedAudiobooks()->get();

// Save one or more audiobooks to the currently authenticated users' library.
Spotify::currentUsersSavedAudiobooks()->add('audiobook_id, audiobook_id_2, audiobook_id_3')->save();

// Remove one or more audiobooks to the currently authenticated users' library.
Spotify::currentUsersSavedAudiobooks()->remove('audiobook_id, audiobook_id_2, audiobook_id_3')->save();

// Check if one or more audiobooks are saved by the currently authenticated user.
Spotify::currentUsersSavedAudiobooks()->contains('audiobook_id, audiobook_id_2, audiobook_id_3')->check();
```

### Categories

[](#categories)

```
// Get a category by ID.
Spotify::category('category_id')->get();

// Get a list of categories.
Spotify::categories()->get();
```

### Chapters

[](#chapters)

```
// Get a chapter by ID.
Spotify::chapter('chapter_id')->get();

// Get several chapters by IDs. Provide a string or array of IDs.
Spotify::chapters('chapter_id, chapter_id_2, chapter_id_3')->get();
```

### Episodes

[](#episodes)

```
// Get an episode by ID.
Spotify::episode('episode_id')->get();

// Get several episodes by IDs. Provide a string or array of IDs.
Spotify::episodes('episode_id, episode_id_2, episode_id_3')->get();

// Get the currently authenticated users saved episodes.
Spotify::currentUsersSavedEpisodes()->get();

// Save one or more episodes to the currently authenticated users' library.
Spotify::currentUsersSavedEpisodes()->add('episode_id, episode_id_2, episode_id_3')->save();

// Remove one or more episodes to the currently authenticated users' library.
Spotify::currentUsersSavedEpisodes()->remove('episode_id, episode_id_2, episode_id_3')->save();

// Check if one or more episodes are saved by the currently authenticated user.
Spotify::currentUsersSavedEpisodes()->contains('episode_id, episode_id_2, episode_id_3')->check();
```

### Markets

[](#markets)

```
// Get available markets.
Spotify::markets()->get();
```

### Player

[](#player)

```
// Get the currently authenticated users playback state.
Spotify::playbackState()->get();

// Get the currently authenticated users available devices.
Spotify::availableDevices()->get();

// Get the currently authenticated users currently playing track.
Spotify::currentlyPlayingTrack()->get();

// Get the currently authenticated users recently played tracks.
Spotify::recentlyPlayedTracks()->get();

// Get the currently authenticated users track queue.
Spotify::currentUsersQueue()->get();
```

### Playlists

[](#playlists)

```
// Get a playlist by ID.
Spotify::playlist('playlist_id')->get();

// Get a playlist's tracks by ID.
Spotify::playlistTracks('playlist_id')->get();

// Get the currently authenticated users playlists.
Spotify::currentUsersPlaylists()->get();

// Get a users playlists by  user ID.
Spotify::usersPlaylists('user_id')->get();

// Get a playlist's cover image by ID.
Spotify::playlistCoverImage('playlist_id')->get();
```

### Search

[](#search)

```
// Search items by query. Provide a string or array to the first parameter.
Spotify::searchItems('album, artist, playlist, track, show, episode, audiobook', 'query')->get();

// Search albums by query.
Spotify::searchAlbums('query')->get();

// Search artists by query.
Spotify::searchArtists('query')->get();

// Search playlists by query.
Spotify::searchPlaylists('query')->get();

// Search tracks by query.
Spotify::searchTracks('query')->get();

// Search shows by query.
Spotify::searchShows('query')->get();

// Search episodes by query.
Spotify::searchEpisodes('query')->get();

// Search audiobooks by query.
Spotify::searchAudiobooks('query')->get();
```

### Shows

[](#shows)

```
// Get a show by ID.
Spotify::show('show_id')->get();

// Get several shows by IDs. Provide a string or array of IDs.
Spotify::shows('show_id, show_id_2, show_id_3')->get();

// Get the episodes of a show by ID.
Spotify::showEpisodes('show_id')->get();

// Get the currently authenticated users saved shows.
Spotify::currentUsersSavedShows()->get();

// Save one or more shows to the currently authenticated users' library.
Spotify::currentUsersSavedShows()->add('show_id, show_id_2, show_id_3')->save();

// Remove one or more shows to the currently authenticated users' library.
Spotify::currentUsersSavedShows()->martket('GB')->remove('show_id, show_id_2, show_id_3')->save();

// Check if one or more shows are saved by the currently authenticated user.
Spotify::currentUsersSavedShows()->contains('show_id, show_id_2, show_id_3')->check();
```

### Tracks

[](#tracks)

```
// Get a track by ID.
Spotify::track('track_id')->get();

// Get several tracks by IDs. Provide a string or array of IDs.
Spotify::tracks('track_id, track_id_2, track_id_3')->get();

// Get the currently authenticated users saved tracks.
Spotify::currentUsersSavedTracks()->get();

// Save one or more tracks to the currently authenticated users' library.
Spotify::currentUsersSavedTracks()->add('track_id, track_id_2, track_id_3')->save();

// Remove one or more tracks to the currently authenticated users' library.
Spotify::currentUsersSavedTracks()->remove('track_id, track_id_2, track_id_3')->save();

// Check if one or more tracks are saved by the currently authenticated user.
Spotify::currentUsersSavedTracks()->contains('track_id, track_id_2, track_id_3')->check();
```

### Users

[](#users)

```
// Get the currently authenticated users profile.
Spotify::currentUsersProfile()->get();

// Get the currently authenticated users top items.
Spotify::currentUsersTopItems('item_type')->get();

// Get a user's profile
Spotify::user('user_id')->get();

// Get the currently authenticated users followed artists.
Spotify::followedArtists()->get();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- Modified version of [laravel-spotify](https://github.com/aerni/laravel-spotify) from [aerni](https://github.com/aerni)
- [Kieran Proctor](https://github.com/KieranLProctor)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance66

Regular maintenance activity

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.2% 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

Every ~1 days

Total

13

Last Release

447d ago

Major Versions

v0.0.1 → v1.0.02025-03-16

v1.0.1 → v2.0.02025-03-17

PHP version history (2 changes)v0.0.0PHP ^8.4

v2.3.5PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3168512?v=4)[gerenuk](/maintainers/gerenuk)[@Gerenuk](https://github.com/Gerenuk)

---

Top Contributors

[![KieranLProctor](https://avatars.githubusercontent.com/u/25559341?v=4)](https://github.com/KieranLProctor "KieranLProctor (82 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

composerlaravel-packagephpspotifyspotify-apilaravelspotifyspotify-apispotify-web-apiGerenuklaravel-spotifyspotify-for-laravelspotify-auth

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/gerenuk-spotify-for-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/gerenuk-spotify-for-laravel/health.svg)](https://phpackages.com/packages/gerenuk-spotify-for-laravel)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k9.9M90](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[spatie/laravel-github-webhooks

Handle GitHub webhooks in a Laravel application

93157.3k5](/packages/spatie-laravel-github-webhooks)

PHPackages © 2026

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