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

ActiveLibrary[API Development](/categories/api)

robman2100/laravel-8-spotify
============================

A Laravel wrapper for the Spotify Web API

13PHP

Since Oct 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/robman2100/laravel-8-spotify)[ Packagist](https://packagist.org/packages/robman2100/laravel-8-spotify)[ RSS](/packages/robman2100-laravel-8-spotify/feed)WikiDiscussions main Synced yesterday

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)
 Laravel-Spotify

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

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

#### An easy to use Spotify Web API wrapper for Laravel 6, 7, and 8

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

 [ ![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) [ ![Travis CI build](https://camo.githubusercontent.com/1145e0e4f3be77c327122a6febc2d9f7d4935bdff18a40c3d0c69edfe6a84f06/68747470733a2f2f666c61742e62616467656e2e6e65742f7472617669732f6165726e692f6c61726176656c2d73706f74696679) ](https://travis-ci.com/aerni/laravel-spotify) [ ![StyleCI build](https://camo.githubusercontent.com/c41217cab6c45b4e8965119334e4364084e863a4c7738eae9c1b2c38a079f903/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3234343637343835352f736869656c643f6272616e63683d6d6173746572) ](https://github.styleci.io/repos/244674855) [ ![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)

Laravel-Spotify 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 robman2100/laravel-8-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 provide a default config which will be used for every API request.
    |
    */

    'default_config' => [
        'country' => env('SPOTIFY_DEFAULT_COUNTRY', ''),
        'locale' => env('SPOTIFY_DEFAULT_LOCALE', ''),
        'market' => env('SPOTIFY_DEFAULT_MARKET', ''),
    ],

];
```

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

Optionally, you may also specify default values for the `country`, `locale` and `market` parameter. The defaults will be passed to every endpoint that supports the corresponding parameter.

```
SPOTIFY_DEFAULT_COUNTRY=US
SPOTIFY_DEFAULT_LOCALE=en_US
SPOTIFY_DEFAULT_MARKET=US
```

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/)

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

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

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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://avatars.githubusercontent.com/u/24798852?v=4)[robman2100](/maintainers/robman2100)[@robman2100](https://github.com/robman2100)

---

Top Contributors

[![robman2100](https://avatars.githubusercontent.com/u/24798852?v=4)](https://github.com/robman2100 "robman2100 (5 commits)")

### Embed Badge

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

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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