Download the PHP package aerni/laravel-spotify without Composer
On this page you can find all versions of the php package aerni/laravel-spotify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-spotify
Spotify for Laravel
An easy to use Spotify Web API wrapper for Laravel 11
Installation •
Usage Example •
Optional Parameters •
Spotify API Reference •
Recommendations
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.
Installation
Install the package using Composer. The package will automatically register itself.
Publish the config of the package.
The following config will be published to config/spotify.php
.
Set the Client ID
and Client Secret
of your Spotify App in your .env
file.
Usage Example
Import the package at the top of your file. All of the following examples use the Facade.
Search for tracks with the name Closed on Sunday
.
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
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.
Parameter Methods API Reference
Consult the Spotify Web API Reference Documentation to check which parameters are available to what endpoint.
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.
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.
Spotify API Reference
Note: Any parameter that accepts multiple values can either receive a string with comma-separated values or an array of values.
Albums
Spotify Web API Reference on Albums
Artists
Spotify Web API Reference on Artists
Browse
Spotify Web API Reference on Browse
Episodes
Spotify Web API Reference on Episodes
Playlists
Spotify Web API Reference on Playlists
Search
Spotify Web API Reference on Search
Shows
Spotify Web API Reference on Shows
Tracks
Spotify Web API Reference on Tracks
User's Profile
Spotify Web API Reference on User's Profile
Recommendations
You can get personalized tracks using the recommendations endpoint by seeding artists, genres and tracks along with a bunch of adjustable properties such as energy, key and danceability.
Usage Example
Import the SpotifySeed
class. All of the following examples use the Facade.
Build your personalized $seed
. You may chain as many methods as you want.
Get your personalized tracks by passing the $seed
to the recommendations()
method.
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 tunable properties to your seed:
Tests
Run the tests like this: