Music has become an essential part of digital experiences, and many developers now want to integrate Spotify in Laravel to make their apps more interactive. Think of a concert booking platform or artist portfolio website built with Laravel that shows Spotify artist details and top tracks. That is a perfect real-life example of Spotify integration in Laravel.
It helps you pull live data such as artist info, albums, playlists, and more directly from Spotify without manual updates.
Install Laravel Spotify Package
In this example, you will use aerni/laravel-spotify package in Laravel to perform API operations for spotify. This package makes it simple to work with Spotify’s data inside your Laravel project.
Run this command in your terminal:
composer require aerni/laravel-spotifyOnce installed, Laravel will automatically finds it provider and you can start using package to integrate Spotify in Laravel. Next thing, we need to do is add Spotify credentials into our app.
Generate Spotify API Key
Before you integrate Spotify in Laravel, you need valid Spotify API credentials to connect your Laravel app with Spotify services. You can create these credentials by setting up a new application in the Spotify Developer Dashboard. Once you get your Client ID and Secret, add them to your .env file to enable API access. If you need detailed guidance, check out our separate post on Generate Spotify API Key for the full process.
Once you get Spotify creentials, open your .env file and add your Spotify Client ID and Secret. This step completes the basic setup to use Spotify in Laravel.
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secretGet Spotify Artist Info
Spotify lets you fetch detailed artist information to make your Laravel app more engaging. For example, in an event app, you can automatically show performer details like genres and followers.
Let’s see how to get artist information using the artist’s Spotify ID.
use Aerni\Spotify\Facades\Spotify;
$artist = Spotify::artist('1uNFoZAHBGtllmzznpCI3s')->get();Above code will retur full artist details such as name, followers, genres, and popularity. Integrating Spotify artist list in Laravel keeps your data updated directly from Spotify.
Get Spotify Artist Albums
With Spotify API in Laravel, you can easily retrieve all albums released by a specific artist. It’s perfect for showcasing an artist’s complete discography or highlighting their latest releases automatically. Let’s see how to fetch an artist’s albums using their Spotify ID.
use Aerni\Spotify\Facades\Spotify;
$albums = Spotify::artistAlbums('1uNFoZAHBGtllmzznpCI3s')->get();This is great for displaying the latest album releases automatically on your laravel application.
Fetch Spotify Playlists
You can also implement Spotify playlists and display them inside your application.
$playlist = Spotify::playlist('37i9dQZF1DXcBWIGoYBM5M')->get();For event booking site, showing artist’s playlist is great option.
Search Spotify Tracks with Query Parameters
Spotify API in Laravel allows you to perform advanced searches for tracks, albums, and playlists using query parameters. This feature is useful when building music discovery or search sections where users can find content based on keywords.
You can also include parameters like limit, offset, or even search by market to filter results more precisely. Let’s look at an example where we search for tracks, albums, and playlists with additional options.
$results = Spotify::search('Imagine Dragons')
    ->type('track,album,playlist')
    ->limit(10)
    ->offset(5)
    ->market('US')
    ->get();For searching, It will allow users to search by artist name, album title, or song keyword.
Conclusion
Integrating Spotify in Laravel lets your app display real-time artist info, albums, and playlists directly from Spotify. Using Spotify API in Laravel keeps your data updated automatically and makes your app more interactive. Whether it’s a music discovery platform or a concert website, Spotify integration in Laravel adds real value and enhances the user experience.

