Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Spotify Web Api Php Laravel Package

jwilsson/spotify-web-api-php

View on GitHub
Deep Wiki
Context7

Managing a User's Library

There are lots of operations involving a user's library that can be performed. Remember to request the correct scopes beforehand.

Adding items to a user's library

$api->addMyLibrary([
    'spotify:album:album_id',
    'spotify:artist:artist_id',
    'spotify:episode:episode_id',
    'spotify:playlist:playlist_id',
    'spotify:show:show_id',
    'spotify:track:track_id',
    'spotify:user:user_id',
]);

Deleting items from a user's library

$api->deleteMyLibrary([
    'spotify:album:album_id',
    'spotify:artist:artist_id',
    'spotify:episode:episode_id',
    'spotify:playlist:playlist_id',
    'spotify:show:show_id',
    'spotify:track:track_id',
    'spotify:user:user_id',
]);

Checking if items are present in a user's library

$contains = $api->myLibraryContains([
    'spotify:album:album_id',
    'spotify:artist:artist_id',
    'spotify:episode:episode_id',
    'spotify:playlist:playlist_id',
    'spotify:show:show_id',
    'spotify:track:track_id',
    'spotify:user:user_id',
]);

var_dump($contains);

Listing the tracks in a user's library

$tracks = $api->getMySavedTracks([
    'limit' => 5,
]);

foreach ($tracks->items as $track) {
    $track = $track->track;

    echo '<a href="' . $track->external_urls->spotify . '">' . $track->name . '</a> <br>';
}

It's also possible to list the albums, audiobooks, podcast episodes, or podcast shows in a user's library using getMySavedAlbums, getMySavedAudiobooks, getMySavedEpisodes, or getMySavedShows.

Adding tracks to a user's library

$api->addMyTracks([
    'ids' => [
        'TRACK_ID',
        'TRACK_ID',
    ],
]);
$api->addMyTracks([
    'timestamped_ids' => [
        ['id' => 'TRACK_ID', 'added_at' => '2025-10-01T11:00:00.000Z'],
        ['id' => 'TRACK_ID', 'added_at' => '2025-10-01T12:00:00.000Z'],
    ],
]);

Adding albums, audiobooks, episodes, or shows to a user's library

Note: These methods are only available to extended quota apps.

$api->addMyAlbums([
    'ALBUM_ID',
    'ALBUM_ID',
]);
$api->addMyAudiobooks([
    'AUDIOBOOK_ID',
    'AUDIOBOOK_ID',
]);
$api->addMyEpisodes([
    'EPISODE_ID',
    'EPISODE_ID',
]);
$api->addMyShows([
    'SHOW_ID',
    'SHOW_ID',
]);

Deleting tracks from a user's library

Note: These methods are only available to extended quota apps.

$api->deleteMyTracks([
    'TRACK_ID',
    'TRACK_ID',
]);

It's also possible to delete an album, an audiobook, a podcast episode, or a podcast show from a user's library using deleteMyAlbums, deleteMyAudiobooks, deleteMyEpisodes, or deleteMyShows.

Checking if tracks are present in a user's library

Note: These methods are only available to extended quota apps.

$contains = $api->myTracksContains([
    'TRACK_ID',
    'TRACK_ID',
]);

var_dump($contains);

It's also possible to check if an album, an audiobook, a podcast episode, or a podcast show is present in a user's library using myAlbumsContains, myAudiobooksContains, myEpisodesContains, or myShowsContains.

Please see the method reference for more available options for each method.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor
spatie/laravel-javascript-views