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

ActiveLibrary[API Development](/categories/api)

aerni/laravel-spotify
=====================

A Laravel wrapper for the Spotify Web API

v3.0.0(1y ago)209145.6k↓22%33[3 PRs](https://github.com/aerni/laravel-spotify/pulls)MITPHPPHP ^8.2CI failing

Since Mar 4Pushed 1y ago6 watchersCompare

[ Source](https://github.com/aerni/laravel-spotify)[ Packagist](https://packagist.org/packages/aerni/laravel-spotify)[ Docs](https://github.com/aerni/laravel-spotify)[ RSS](/packages/aerni-laravel-spotify/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (17)Used By (0)

 [![](https://github.com/aerni/laravel-spotify/raw/master/logo.png)](https://github.com/aerni/laravel-spotify/blob/master/logo.png)
 Spotify for Laravel

===========================================================================================================================================================

[](#------------spotify-for-laravel----)

#### An easy to use Spotify Web API wrapper for Laravel

[](#an-easy-to-use-spotify-web-api-wrapper-for-laravel)

 [ ![Packagist version](https://camo.githubusercontent.com/9f88da5c6d2d38f26311be58a485cac752957291c2fe9a91e1973ed09c9fb48a/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f762f6165726e692f6c61726176656c2d73706f74696679) ](https://packagist.org/packages/aerni/laravel-spotify) [ ![Packagist total downloads](https://camo.githubusercontent.com/27720357026b0ae467648f21da7c5ee70eeafcde864caeff36e7f61dea993fcd/68747470733a2f2f666c61742e62616467656e2e6e65742f7061636b61676973742f64742f6165726e692f6c61726176656c2d73706f74696679) ](https://packagist.org/packages/aerni/laravel-spotify) [ ![GitHub license](https://camo.githubusercontent.com/7ff3963e72f182f89f150322de546fd75250d620b42dc396c34d2780efd112f9/68747470733a2f2f666c61742e62616467656e2e6e65742f6769746875622f6c6963656e73652f6165726e692f6c61726176656c2d73706f74696679) ](https://github.com/aerni/laravel-spotify/blob/master/LICENSE) [ ![PayPal donate](https://camo.githubusercontent.com/b6c0575814fbde5d5354ec0e9277dd26e7b516fb855a60463c0c7e4cf8273c06/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50617950616c2d646f6e6174652d626c75652e7376673f7374796c653d666c61742d737175617265) ](https://www.paypal.me/michaelaerni)

 [Installation](#installation) • [Usage Example](#usage-example) • [Optional Parameters](#optional-parameters) • [Spotify API Reference](#spotify-api-reference) •

Introduction
------------

[](#introduction)

Spotify for Laravel makes working with the Spotify Web API a breeze. It provides straight forward methods for each endpoint and a fluent interface for optional parameters.

The package supports all Spotify Web API endpoints that are accessible with the [Client Credentials Flow](https://developer.spotify.com/documentation/general/guides/authorization-guide/#client-credentials-flow).

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

[](#installation)

Install the package using Composer. The package will automatically register itself.

```
composer require aerni/laravel-spotify
```

Publish the config of the package.

```
php artisan vendor:publish --provider="Aerni\Spotify\SpotifyServiceProvider"
```

The following config will be published to `config/spotify.php`.

```
return [

    /*
    |--------------------------------------------------------------------------
    | Authentication
    |--------------------------------------------------------------------------
    |
    | The Client ID and Client Secret of your Spotify App.
    |
    */

    'auth' => [
        'client_id' => env('SPOTIFY_CLIENT_ID'),
        'client_secret' => env('SPOTIFY_CLIENT_SECRET'),
    ],

    /*
    |--------------------------------------------------------------------------
    | 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=********************************
```

Usage Example
-------------

[](#usage-example)

Import the package at the top of your file. All of the following examples use the [Facade](https://laravel.com/docs/master/facades).

```
use Aerni\Spotify\Facades\Spotify;
```

Search for tracks with the name `Closed on Sunday`.

```
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();
```

### 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();
```

### Browse

[](#browse)

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

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

// Get a list of new releases.
Spotify::newReleases()->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();
```

### 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 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 second parameter.
Spotify::searchItems('query', 'album, artist, playlist, track')->get();

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

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

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

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

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

// Search tracks by query.
Spotify::searchTracks('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();
```

### 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();
```

### User's Profile

[](#users-profile)

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

// Get a list of a user's playlists
Spotify::userPlaylists('user_id')->get();
```

Tests
-----

[](#tests)

Run the tests like this:

```
vendor/bin/phpunit
```

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance45

Moderate activity, may be stable

Popularity52

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 91.7% 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 ~122 days

Recently: every ~189 days

Total

16

Last Release

431d ago

Major Versions

v1.6.1 → v2.0.02022-02-16

v2.4.0 → v3.0.02025-03-13

PHP version history (7 changes)v1.1.0PHP 7.2.\* || 7.3.\*

v1.3.0PHP 7.2.\* || 7.3.\* || 7.4.\*

v1.4.0PHP ^7.4

v1.6.0PHP ^7.4|^8.0

v2.0.0PHP ^8.0

v2.1.0PHP ^8.1

v2.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f0a168dc347e5e141dc13cec734d3b0a25a13445069483732580f26f71456a6?d=identicon)[aerni](/maintainers/aerni)

---

Top Contributors

[![aerni](https://avatars.githubusercontent.com/u/23167701?v=4)](https://github.com/aerni "aerni (111 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (2 commits)")[![asifkhankadiwala](https://avatars.githubusercontent.com/u/30252847?v=4)](https://github.com/asifkhankadiwala "asifkhankadiwala (1 commits)")[![codingmugen007](https://avatars.githubusercontent.com/u/66251103?v=4)](https://github.com/codingmugen007 "codingmugen007 (1 commits)")[![damidani](https://avatars.githubusercontent.com/u/29334932?v=4)](https://github.com/damidani "damidani (1 commits)")[![ariaieboy](https://avatars.githubusercontent.com/u/15873972?v=4)](https://github.com/ariaieboy "ariaieboy (1 commits)")[![foremtehan](https://avatars.githubusercontent.com/u/53290883?v=4)](https://github.com/foremtehan "foremtehan (1 commits)")[![KieranLProctor](https://avatars.githubusercontent.com/u/25559341?v=4)](https://github.com/KieranLProctor "KieranLProctor (1 commits)")[![spoyntersmith](https://avatars.githubusercontent.com/u/22387308?v=4)](https://github.com/spoyntersmith "spoyntersmith (1 commits)")[![Unleashed2k](https://avatars.githubusercontent.com/u/6856387?v=4)](https://github.com/Unleashed2k "Unleashed2k (1 commits)")

---

Tags

laravellaravel-packagespotifyspotify-apispotify-web-apispotify-web-api-laravelapisearchlaravelwrapperAlbumbrowsespotifymusictracktracksplaylistsalbumsplaylistartistsongsspotify-apispotify-web-apiArtists

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)[dariusiii/tmdb-laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

1821.1k](/packages/dariusiii-tmdb-laravel)[ardakilic/mutlucell

Mutlucell SMS API wrapper for sending sms text messages for Laravel

457.3k](/packages/ardakilic-mutlucell)[lasserafn/laravel-economic

Economic REST wrapper for Laravel

1118.5k](/packages/lasserafn-laravel-economic)

PHPackages © 2026

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