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

ActiveLibrary[API Development](/categories/api)

sanmon1985/laravel-spotify
==========================

A Laravel wrapper for the Spotify Web API

0569—0%PHP

Since Dec 20Pushed 5mo agoCompare

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

READMEChangelogDependenciesVersions (1)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 11

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

 [ ![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) • [Recommendations](#recommendations)

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\Providers\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 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();

// Get results based on a specific date and time.
Spotify::featuredPlaylists()->timestamp('2020-03-02T09:00:00')->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)

[Spotify Web API Reference on Albums](https://developer.spotify.com/documentation/web-api/reference/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)

[Spotify Web API Reference on Artists](https://developer.spotify.com/documentation/web-api/reference/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();

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

### Browse

[](#browse)

[Spotify Web API Reference on Browse](https://developer.spotify.com/documentation/web-api/reference/browse/)

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

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

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

// Get a list of featured playlists.
Spotify::featuredPlaylists()->get();

// Get a list of new releases.
Spotify::newReleases()->get();

// Get available genre seeds.
Spotify::availableGenreSeeds()->get();

// Get recommendations based on a seed.
Spotify::recommendations($seed)->get();
```

### Episodes

[](#episodes)

[Spotify Web API Reference on Episodes](https://developer.spotify.com/documentation/web-api/reference/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)

[Spotify Web API Reference on Playlists](https://developer.spotify.com/documentation/web-api/reference/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)

[Spotify Web API Reference on Search](https://developer.spotify.com/documentation/web-api/reference/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)

[Spotify Web API Reference on Shows](https://developer.spotify.com/documentation/web-api/reference/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)

[Spotify Web API Reference on Tracks](https://developer.spotify.com/documentation/web-api/reference/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 audio analysis for a track by ID.
Spotify::audioAnalysisForTrack('track_id')->get();

// Get audio features for a track by ID.
Spotify::audioFeaturesForTrack('track_id')->get();

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

### User's Profile

[](#users-profile)

[Spotify Web API Reference on User's Profile](https://developer.spotify.com/documentation/web-api/reference/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();
```

Recommendations
---------------

[](#recommendations)

You can get personalized tracks using the [recommendations endpoint](https://developer.spotify.com/documentation/web-api/reference/browse/get-recommendations) by seeding artists, genres and tracks along with a bunch of adjustable properties such as energy, key and danceability.

### Usage Example

[](#usage-example-1)

Import the `SpotifySeed` class. All of the following examples use the [Facade](https://laravel.com/docs/master/facades).

```
use SpotifySeed;
```

Build your personalized `$seed`. You may chain as many methods as you want.

```
$seed = SpotifySeed::setGenres(['gospel', 'pop', 'funk'])
    ->setTargetValence(1.00)
    ->setSpeechiness(0.3, 0.9)
    ->setLiveness(0.3, 1.0);
```

Get your personalized tracks by passing the `$seed` to the `recommendations()` method.

```
Spotify::recommendations($seed)->get();
```

### SpotifySeed API Reference

[](#spotifyseed-api-reference)

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

**Add artists, genres and tracks to your seed:**

```
// Add an artist by ID.
SpotifySeed::addArtist('artist_id');

// Add several artists by IDs. Provide a string or array of IDs.
SpotifySeed::addArtists('artist_id_1, artist_id_2, artist_id_3');

// Set artists by IDs. Provide a string or array of IDs. This overwrites previously added artists.
SpotifySeed::setArtists('artist_id_1, artist_id_2, artist_id_3');

// Add a genre by ID.
SpotifySeed::addGerne('gerne_id');

// Add several genres by IDs. Provide a string or array of IDs.
SpotifySeed::addGenres('gerne_id_1, gerne_id_2, gerne_id_3');

// Set gernes by IDs. Provide a string or array of IDs. This overwrites previously added genres.
SpotifySeed::setGenres('genre_id_1, genre_id_2, genre_id_3');

// Add a track by ID.
SpotifySeed::addTrack('track_id');

// Add several tracks by IDs. Provide a string or array of IDs.
SpotifySeed::addTracks('track_id_1, track_id_2, track_id_3');

// Set tracks by IDs. Provide a string or array of IDs. This overwrites previously added tracks.
SpotifySeed::setTracks('track_id_1, track_id_2, track_id_3');
```

**Add tunable properties to your seed:**

```
SpotifySeed::setAcousticness(float $min, float $max);
SpotifySeed::setTargetAcousticness(float $target);

SpotifySeed::setDanceability(float $min, float $max);
SpotifySeed::setTargetDanceability(float $target);

SpotifySeed::setDuration(int $min, int $max);
SpotifySeed::setTargetDuration(int $target);

SpotifySeed::setEnergy(float $min, float $max);
SpotifySeed::setTargetEnergy(float $target);

SpotifySeed::setInstrumentalness(float $min, float $max);
SpotifySeed::setTargetInstrumentalness(float $target);

SpotifySeed::setKey(int $min, int $max);
SpotifySeed::setTargetKey(int $target);

SpotifySeed::setLiveness(float $min, float $max);
SpotifySeed::setTargetLiveness(float $target);

SpotifySeed::setLoudness(float $min, float $max);
SpotifySeed::setTargetLoudness(float $target);

SpotifySeed::setMode(int $min, int $max);
SpotifySeed::setTargetMode(int $target);

SpotifySeed::setPopularity(float $min, float $max);
SpotifySeed::setTargetPopularity(float $target);

SpotifySeed::setSpeechiness(float $min, float $max);
SpotifySeed::setTargetSpeechiness(float $target);

SpotifySeed::setTempo(int $min, int $max);
SpotifySeed::setTargetTempo(int $target);

SpotifySeed::setTimeSignature(int $min, int $max);
SpotifySeed::setTargetTimeSignature(int $target);

SpotifySeed::setValence(float $min, float $max);
SpotifySeed::setTargetValence(float $target);
```

Tests
-----

[](#tests)

Run the tests like this:

```
vendor/bin/phpunit
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance50

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/8de9702f8b1c3f31fb4a202669f2796241a773a09d3252868dfb8a267b92b02c?d=identicon)[sanmon1985](/maintainers/sanmon1985)

---

Top Contributors

[![aerni](https://avatars.githubusercontent.com/u/23167701?v=4)](https://github.com/aerni "aerni (108 commits)")[![sanmon1985](https://avatars.githubusercontent.com/u/486003?v=4)](https://github.com/sanmon1985 "sanmon1985 (5 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (2 commits)")[![codingmugen007](https://avatars.githubusercontent.com/u/66251103?v=4)](https://github.com/codingmugen007 "codingmugen007 (1 commits)")[![asifkhankadiwala](https://avatars.githubusercontent.com/u/30252847?v=4)](https://github.com/asifkhankadiwala "asifkhankadiwala (1 commits)")[![foremtehan](https://avatars.githubusercontent.com/u/53290883?v=4)](https://github.com/foremtehan "foremtehan (1 commits)")[![ariaieboy](https://avatars.githubusercontent.com/u/15873972?v=4)](https://github.com/ariaieboy "ariaieboy (1 commits)")[![Unleashed2k](https://avatars.githubusercontent.com/u/6856387?v=4)](https://github.com/Unleashed2k "Unleashed2k (1 commits)")

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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