Skip to content

Latest commit

 

History

History
1777 lines (1234 loc) · 50.1 KB

SpotifyWebAPI.md

File metadata and controls

1777 lines (1234 loc) · 50.1 KB

SpotifyWebAPI

Table of Contents

Constants

Methods

__construct

SpotifyWebAPI::__construct($options, $session, $request)

Constructor
Set options and class instances to use.

Arguments

  • $options array|object - Optional. Options to set.
  • $session \SpotifyWebAPI\Session - Optional. The Session object to use.
  • $request \SpotifyWebAPI\Request - Optional. The Request object to use.

addMyAlbums

SpotifyWebAPI::addMyAlbums($albums)

Add albums to the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/save-albums-user

Arguments

  • $albums string|array - Album IDs or URIs to add.

Return values

  • bool Whether the albums was successfully added.

addMyEpisodes

SpotifyWebAPI::addMyEpisodes($episodes)

Add episodes to the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/save-episodes-user

Arguments

  • $episodes string|array - Episode IDs or URIs to add.

Return values

  • bool Whether the episodes was successfully added.

addMyShows

SpotifyWebAPI::addMyShows($shows)

Add shows to the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/save-shows-user

Arguments

  • $shows string|array - Show IDs or URIs to add.

Return values

  • bool Whether the shows was successfully added.

addMyTracks

SpotifyWebAPI::addMyTracks($tracks)

Add tracks to the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/save-tracks-user

Arguments

  • $tracks string|array - Track IDs or URIs to add.

Return values

  • bool Whether the tracks was successfully added.

addPlaylistTracks

SpotifyWebAPI::addPlaylistTracks($playlistId, $tracks, $options)

Add tracks to a playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/add-tracks-to-playlist

Arguments

  • $playlistId string - ID of the playlist to add tracks to.
  • $tracks string|array - Track IDs, track URIs, and episode URIs to add.
  • $options array|object - Optional. Options for the new tracks.
    • int position Optional. Zero-based track position in playlist. Tracks will be appended if omitted or false.

Return values

  • string|bool A new snapshot ID or false if the tracks weren't successfully added.

changeMyDevice

SpotifyWebAPI::changeMyDevice($options)

Change the current user's playback device.
https://developer.spotify.com/documentation/web-api/reference/#/operations/transfer-a-users-playback

Arguments

  • $options array|object - Options for the playback transfer.
    • string|array device_ids Required. ID of the device to switch to.
    • bool play Optional. Whether to start playing on the new device

Return values

  • bool Whether the playback device was successfully changed.

changeVolume

SpotifyWebAPI::changeVolume($options)

Change playback volume for the current user.
https://developer.spotify.com/documentation/web-api/reference/#/operations/set-volume-for-users-playback

Arguments

  • $options array|object - Optional. Options for the playback volume.
    • int volume_percent Required. The volume to set.
    • string device_id Optional. ID of the device to target.

Return values

  • bool Whether the playback volume was successfully changed.

createPlaylist

SpotifyWebAPI::createPlaylist($userId, $options)

Create a new playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/create-playlist

Arguments

  • $userId string - ID or URI of the user to create the playlist for.
  • $options array|object - Options for the new playlist.
    • string name Required. Name of the playlist.
    • bool collaborative Optional. Whether the playlist should be collaborative or not.
    • string description Optional. Description of the playlist.
    • bool public Optional. Whether the playlist should be public or not.

Return values

  • array|object The new playlist. Type is controlled by the return_assoc option.

currentUserFollows

SpotifyWebAPI::currentUserFollows($type, $ids)

Check to see if the current user is following one or more artists or other Spotify users.
https://developer.spotify.com/documentation/web-api/reference/#/operations/check-current-user-follows

Arguments

  • $type string - The type to check: either 'artist' or 'user'.
  • $ids string|array - IDs or URIs of the users or artists to check for.

Return values

  • array Whether each user or artist is followed.

deleteMyAlbums

SpotifyWebAPI::deleteMyAlbums($albums)

Delete albums from the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-albums-user

Arguments

  • $albums string|array - Album IDs or URIs to delete.

Return values

  • bool Whether the albums was successfully deleted.

deleteMyEpisodes

SpotifyWebAPI::deleteMyEpisodes($episodes)

Delete episodes from the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-episodes-user

Arguments

  • $episodes string|array - Episode IDs or URIs to delete.

Return values

  • bool Whether the episodes was successfully deleted.

deleteMyShows

SpotifyWebAPI::deleteMyShows($shows)

Delete shows from the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-shows-user

Arguments

  • $shows string|array - Show IDs or URIs to delete.

Return values

  • bool Whether the shows was successfully deleted.

deleteMyTracks

SpotifyWebAPI::deleteMyTracks($tracks)

Delete tracks from the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-tracks-user

Arguments

  • $tracks string|array - Track IDs or URIs to delete.

Return values

  • bool Whether the tracks was successfully deleted.

deletePlaylistTracks

SpotifyWebAPI::deletePlaylistTracks($playlistId, $tracks, $snapshotId)

Delete tracks from a playlist and retrieve a new snapshot ID.
https://developer.spotify.com/documentation/web-api/reference/#/operations/remove-tracks-playlist

Arguments

  • $playlistId string - ID or URI of the playlist to delete tracks from.
  • $tracks array - An array with the key "tracks" containing arrays or objects with tracks to delete. Or an array with the key "positions" containing integer positions of the tracks to delete. If the "tracks" key is used, the following fields are also available:
    • string uri Required. Track ID, track URI, or episode URI.
    • int|array positions Optional. The track's positions in the playlist.
  • $snapshotId string - Required when $tracks['positions'] is used, optional otherwise. The playlist's snapshot ID.

Return values

  • string|bool A new snapshot ID or false if the tracks weren't successfully deleted.

followArtistsOrUsers

SpotifyWebAPI::followArtistsOrUsers($type, $ids)

Add the current user as a follower of one or more artists or other Spotify users.
https://developer.spotify.com/documentation/web-api/reference/#/operations/follow-artists-users

Arguments

  • $type string - The type of ID to follow: either 'artist' or 'user'.
  • $ids string|array - IDs or URIs of the users or artists to follow.

Return values

  • bool Whether the artist or user was successfully followed.

followPlaylist

SpotifyWebAPI::followPlaylist($playlistId, $options)

Add the current user as a follower of a playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/follow-playlist

Arguments

  • $playlistId string - ID or URI of the playlist to follow.
  • $options array|object - Optional. Options for the followed playlist.
    • bool public Optional. Whether the playlist should be followed publicly or not.

Return values

  • bool Whether the playlist was successfully followed.

getAlbum

SpotifyWebAPI::getAlbum($albumId, $options)

Get an album.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-album

Arguments

  • $albumId string - ID or URI of the album.
  • $options array|object - Optional. Options for the album.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.

Return values

  • array|object The requested album. Type is controlled by the return_assoc option.

getAlbums

SpotifyWebAPI::getAlbums($albumIds, $options)

Get multiple albums.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-multiple-albums

Arguments

  • $albumIds array - IDs or URIs of the albums.
  • $options array|object - Optional. Options for the albums.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.

Return values

  • array|object The requested albums. Type is controlled by the return_assoc option.

getAlbumTracks

SpotifyWebAPI::getAlbumTracks($albumId, $options)

Get an album's tracks.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-albums-tracks

Arguments

  • $albumId string - ID or URI of the album.
  • $options array|object - Optional. Options for the tracks.
    • int limit Optional. Limit the number of tracks.
    • int offset Optional. Number of tracks to skip.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.

Return values

  • array|object The requested album tracks. Type is controlled by the return_assoc option.

getArtist

SpotifyWebAPI::getArtist($artistId)

Get an artist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artist

Arguments

  • $artistId string - ID or URI of the artist.

Return values

  • array|object The requested artist. Type is controlled by the return_assoc option.

getArtists

SpotifyWebAPI::getArtists($artistIds)

Get multiple artists.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-multiple-artists

Arguments

  • $artistIds array - IDs or URIs of the artists.

Return values

  • array|object The requested artists. Type is controlled by the return_assoc option.

getArtistRelatedArtists

Deprecated. See https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api

SpotifyWebAPI::getArtistRelatedArtists($artistId)

Get an artist's related artists.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-related-artists

Arguments

  • $artistId string - ID or URI of the artist.

Return values

  • array|object The artist's related artists. Type is controlled by the return_assoc option.

getArtistAlbums

SpotifyWebAPI::getArtistAlbums($artistId, $options)

Get an artist's albums.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-albums

Arguments

  • $artistId string - ID or URI of the artist.
  • $options array|object - Optional. Options for the albums.
    • string market Optional. Limit the results to items that are playable in this country, for example SE.
    • string|array include_groups Optional. Album types to return. If omitted, all album types will be returned.
    • int limit Optional. Limit the number of albums.
    • int offset Optional. Number of albums to skip.

Return values

  • array|object The artist's albums. Type is controlled by the return_assoc option.

getArtistTopTracks

SpotifyWebAPI::getArtistTopTracks($artistId, $options)

Get an artist's top tracks in a country.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-top-tracks

Arguments

  • $artistId string - ID or URI of the artist.
  • $options array|object - Options for the tracks.
    • string market Required. An ISO 3166-1 alpha-2 country code specifying the country to get the top tracks for.

Return values

  • array|object The artist's top tracks. Type is controlled by the return_assoc option.

getAudioAnalysis

Deprecated. See https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api

SpotifyWebAPI::getAudioAnalysis($trackId)

Get audio analysis for track.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-audio-analysis

Arguments

  • $trackId string - ID or URI of the track.

Return values

  • array|object The track's audio analysis. Type is controlled by the return_assoc option.

getAudiobook

SpotifyWebAPI::getAudiobook($audiobookId, $options)

Get an audiobook.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-audiobook

Arguments

  • $audiobookId string - ID or URI of the audiobook.
  • $options array|object - Optional. Options for the audiobook.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to audiobooks available in that market.

Return values

  • array|object The requested audiobook. Type is controlled by the return_assoc option.

getAudiobooks

SpotifyWebAPI::getAudiobooks($audiobookIds, $options)

Get multiple audiobooks.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-multiple-audiobooks

Arguments

  • $audiobookIds array - IDs or URIs of the audiobooks.
  • $options array|object - Optional. Options for the audiobooks.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to audiobooks available in that market.

Return values

  • array|object The requested audiobooks. Type is controlled by the return_assoc option.

getAudioFeatures

Deprecated. See https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api

SpotifyWebAPI::getAudioFeatures($trackId)

Get audio features of a single track.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-audio-features

Arguments

  • $trackId string - ID or URI of the track.

Return values

  • array|object The track's audio features. Type is controlled by the return_assoc option.

getCategoriesList

SpotifyWebAPI::getCategoriesList($options)

Get a list of categories used to tag items in Spotify (on, for example, the Spotify player’s "Discover" tab).
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-categories

Arguments

  • $options array|object - Optional. Options for the categories.
    • string locale Optional. Language to show categories in, for example 'sv_SE'.
    • string country Optional. ISO 3166-1 alpha-2 country code. Show categories from this country.
    • int limit Optional. Limit the number of categories.
    • int offset Optional. Number of categories to skip.

Return values

  • array|object The list of categories. Type is controlled by the return_assoc option.

getCategory

SpotifyWebAPI::getCategory($categoryId, $options)

Get a single category used to tag items in Spotify (on, for example, the Spotify player’s "Discover" tab).
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-a-category

Arguments

  • $categoryId string - ID of the category.
  • $options array|object - Optional. Options for the category.
    • string locale Optional. Language to show category in, for example 'sv_SE'.
    • string country Optional. ISO 3166-1 alpha-2 country code. Show category from this country.

Return values

  • array|object The category. Type is controlled by the return_assoc option.

getCategoryPlaylists

SpotifyWebAPI::getCategoryPlaylists($categoryId, $options)

Get a list of Spotify playlists tagged with a particular category.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-a-categories-playlists

Arguments

  • $categoryId string - ID of the category.
  • $options array|object - Optional. Options for the category's playlists.
    • string country Optional. ISO 3166-1 alpha-2 country code. Show category playlists from this country.
    • int limit Optional. Limit the number of playlists.
    • int offset Optional. Number of playlists to skip.

Return values

  • array|object The list of playlists. Type is controlled by the return_assoc option.

getChapter

SpotifyWebAPI::getChapter($chapterId, $options)

Get a chapter.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-chapter

Arguments

  • $chapterId string - ID or URI of the chapter.
  • $options array|object - Optional. Options for the chapter.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to episodes available in that market.

Return values

  • array|object The requested chapter. Type is controlled by the return_assoc option.

getChapters

SpotifyWebAPI::getChapters($chapterIds, $options)

Get multiple chapters.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-several-chapters

Arguments

  • $chapterIds array - IDs or URIs of the chapters.
  • $options array|object - Optional. Options for the chapters.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to episodes available in that market.

Return values

  • array|object The requested chapters. Type is controlled by the return_assoc option.

getEpisode

SpotifyWebAPI::getEpisode($episodeId, $options)

Get an episode.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-episode

Arguments

  • $episodeId string - ID or URI of the episode.
  • $options array|object - Optional. Options for the episode.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to episodes available in that market.

Return values

  • array|object The requested episode. Type is controlled by the return_assoc option.

getEpisodes

SpotifyWebAPI::getEpisodes($episodeIds, $options)

Get multiple episodes.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-multiple-episodes

Arguments

  • $episodeIds string|array - IDs or URIs of the episodes.
  • $options array|object - Optional. Options for the episodes.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to episodes available in that market.

Return values

  • array|object The requested episodes. Type is controlled by the return_assoc option.

getFeaturedPlaylists

Deprecated. See https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api

SpotifyWebAPI::getFeaturedPlaylists($options)

Get Spotify featured playlists.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-featured-playlists

Arguments

  • $options array|object - Optional. Options for the playlists.
    • string locale Optional. Language to show playlists in, for example 'sv_SE'.
    • string country Optional. ISO 3166-1 alpha-2 country code. Show playlists from this country.
    • string timestamp Optional. A ISO 8601 timestamp. Show playlists relevant to this date and time.
    • int limit Optional. Limit the number of playlists.
    • int offset Optional. Number of playlists to skip.

Return values

  • array|object The featured playlists. Type is controlled by the return_assoc option.

getGenreSeeds

Deprecated. See https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api

SpotifyWebAPI::getGenreSeeds()

Get a list of possible seed genres.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-recommendation-genres

Return values

  • array|object All possible seed genres. Type is controlled by the return_assoc option.

getLastResponse

SpotifyWebAPI::getLastResponse()

Get the latest full response from the Spotify API.

Return values

  • array Response data.
    • array|object body The response body. Type is controlled by the return_assoc option.
    • array headers Response headers.
    • int status HTTP status code.
    • string url The requested URL.

getMarkets

SpotifyWebAPI::getMarkets()

Get all markets where Spotify is available.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-available-markets

Return values

  • array|object All markets where Spotify is available. Type is controlled by the return_assoc option.

getMultipleAudioFeatures

Deprecated. See https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api

SpotifyWebAPI::getMultipleAudioFeatures($trackIds)

Get audio features of multiple tracks.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-several-audio-features

Arguments

  • $trackIds string|array - IDs or URIs of the tracks.

Return values

  • array|object The tracks' audio features. Type is controlled by the return_assoc option.

getMyCurrentTrack

SpotifyWebAPI::getMyCurrentTrack($options)

Get the current user’s currently playing track.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-the-users-currently-playing-track

Arguments

  • $options array|object - Optional. Options for the track.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.
    • string|array additional_types Optional. Types of media to return info about.

Return values

  • array|object|null The user's currently playing track or null if nothing's currently playing. Type is controlled by the return_assoc option.

getMyDevices

SpotifyWebAPI::getMyDevices()

Get the current user’s devices.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-a-users-available-devices

Return values

  • array|object The user's devices. Type is controlled by the return_assoc option.

getMyCurrentPlaybackInfo

SpotifyWebAPI::getMyCurrentPlaybackInfo($options)

Get the current user’s current playback information.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-information-about-the-users-current-playback

Arguments

  • $options array|object - Optional. Options for the info.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.
    • string|array additional_types Optional. Types of media to return info about.

Return values

  • array|object|null The user's playback information or null if nothing's currently playing. Type is controlled by the return_assoc option.

getMyPlaylists

SpotifyWebAPI::getMyPlaylists($options)

Get the current user’s playlists.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-a-list-of-current-users-playlists

Arguments

  • $options array|object - Optional. Options for the playlists.
    • int limit Optional. Limit the number of playlists.
    • int offset Optional. Number of playlists to skip.

Return values

  • array|object The user's playlists. Type is controlled by the return_assoc option.

getMyQueue

SpotifyWebAPI::getMyQueue()

Get the current user’s queue.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-queue

Return values

  • array|object The currently playing song and queue. Type is controlled by the return_assoc option.

getMyRecentTracks

SpotifyWebAPI::getMyRecentTracks($options)

Get the current user’s recently played tracks.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-recently-played

Arguments

  • $options array|object - Optional. Options for the tracks.
    • int limit Optional. Number of tracks to return.
    • string after Optional. Unix timestamp in ms (13 digits). Returns all items after this position.
    • string before Optional. Unix timestamp in ms (13 digits). Returns all items before this position.

Return values

  • array|object The most recently played tracks. Type is controlled by the return_assoc option.

getMySavedAlbums

SpotifyWebAPI::getMySavedAlbums($options)

Get the current user’s saved albums.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-users-saved-albums

Arguments

  • $options array|object - Optional. Options for the albums.
    • int limit Optional. Number of albums to return.
    • int offset Optional. Number of albums to skip.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.

Return values

  • array|object The user's saved albums. Type is controlled by the return_assoc option.

getMySavedEpisodes

SpotifyWebAPI::getMySavedEpisodes($options)

Get the current user’s saved episodes.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-users-saved-episodes

Arguments

  • $options array|object - Optional. Options for the episodes.
    • int limit Optional. Number of episodes to return.
    • int offset Optional. Number of episodes to skip.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to episodes available in that market.

Return values

  • array|object The user's saved episodes. Type is controlled by the return_assoc option.

getMySavedTracks

SpotifyWebAPI::getMySavedTracks($options)

Get the current user’s saved tracks.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-users-saved-tracks

Arguments

  • $options array|object - Optional. Options for the tracks.
    • int limit Optional. Limit the number of tracks.
    • int offset Optional. Number of tracks to skip.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.

Return values

  • array|object The user's saved tracks. Type is controlled by the return_assoc option.

getMySavedShows

SpotifyWebAPI::getMySavedShows($options)

Get the current user’s saved shows.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-users-saved-shows

Arguments

  • $options array|object - Optional. Options for the shows.
    • int limit Optional. Limit the number of shows.
    • int offset Optional. Number of shows to skip.

Return values

  • array|object The user's saved shows. Type is controlled by the return_assoc option.

getMyTop

SpotifyWebAPI::getMyTop($type, $options)

Get the current user's top tracks or artists.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-users-top-artists-and-tracks

Arguments

  • $type string - The type to fetch, either 'artists' or 'tracks'.
  • $options array - Optional. Options for the results.
    • int limit Optional. Limit the number of results.
    • int offset Optional. Number of results to skip.
    • string time_range Optional. Over what time frame the data is calculated. See Spotify API docs for more info.

Return values

  • array|object A list of the requested top entity. Type is controlled by the return_assoc option.

getNewReleases

SpotifyWebAPI::getNewReleases($options)

Get new releases.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-new-releases

Arguments

  • $options array|object - Optional. Options for the items.
    • string country Optional. ISO 3166-1 alpha-2 country code. Show items relevant to this country.
    • int limit Optional. Limit the number of items.
    • int offset Optional. Number of items to skip.

Return values

  • array|object The new releases. Type is controlled by the return_assoc option.

getPlaylist

SpotifyWebAPI::getPlaylist($playlistId, $options)

Get a specific playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-playlist

Arguments

  • $playlistId string - ID or URI of the playlist.
  • $options array|object - Optional. Options for the playlist.
    • string|array fields Optional. A list of fields to return. See Spotify docs for more info.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.
    • string|array additional_types Optional. Types of media to return info about.

Return values

  • array|object The user's playlist. Type is controlled by the return_assoc option.

getPlaylistImage

SpotifyWebAPI::getPlaylistImage($playlistId)

Get a playlist's cover image.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-playlist-cover

Arguments

  • $playlistId string - ID or URI of the playlist.

Return values

  • array|object The playlist cover image. Type is controlled by the return_assoc option.

getPlaylistTracks

SpotifyWebAPI::getPlaylistTracks($playlistId, $options)

Get the tracks in a playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-playlists-tracks

Arguments

  • $playlistId string - ID or URI of the playlist.
  • $options array|object - Optional. Options for the tracks.
    • string|array fields Optional. A list of fields to return. See Spotify docs for more info.
    • int limit Optional. Limit the number of tracks.
    • int offset Optional. Number of tracks to skip.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.
    • string|array additional_types Optional. Types of media to return info about.

Return values

  • array|object The tracks in the playlist. Type is controlled by the return_assoc option.

getRecommendations

Deprecated. See https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api

SpotifyWebAPI::getRecommendations($options)

Get recommendations based on artists, tracks, or genres.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-recommendations

Arguments

  • $options array|object - Optional. Options for the recommendations.
    • int limit Optional. Limit the number of recommendations.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.
    • mixed max_* Optional. Max value for one of the tunable track attributes.
    • mixed min_* Optional. Min value for one of the tunable track attributes.
    • array seed_artists Artist IDs to seed by.
    • array seed_genres Genres to seed by. Call SpotifyWebAPI::getGenreSeeds() for a complete list.
    • array seed_tracks Track IDs to seed by.
    • mixed target_* Optional. Target value for one of the tunable track attributes.

Return values

  • array|object The requested recommendations. Type is controlled by the return_assoc option.

getRequest

SpotifyWebAPI::getRequest()

Get the Request object in use.

Return values

  • \SpotifyWebAPI\Request The Request object in use.

getShow

SpotifyWebAPI::getShow($showId, $options)

Get a show.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-a-show

Arguments

  • $showId string - ID or URI of the show.
  • $options array|object - Optional. Options for the show.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to shows available in that market.

Return values

  • array|object The requested show. Type is controlled by the return_assoc option.

getShowEpisodes

SpotifyWebAPI::getShowEpisodes($showId, $options)

Get a show's episodes.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-a-shows-episodes

Arguments

  • $showId string - ID or URI of the album.
  • $options array|object - Optional. Options for the episodes.
    • int limit Optional. Limit the number of episodes.
    • int offset Optional. Number of episodes to skip.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to episodes available in that market.

Return values

  • array|object The requested show episodes. Type is controlled by the return_assoc option.

getShows

SpotifyWebAPI::getShows($showIds, $options)

Get multiple shows.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-multiple-shows

Arguments

  • $showIds string|array - IDs or URIs of the shows.
  • $options array|object - Optional. Options for the shows.
    • string market Optional. ISO 3166-1 alpha-2 country code, limit results to shows available in that market.

Return values

  • array|object The requested shows. Type is controlled by the return_assoc option.

getTrack

SpotifyWebAPI::getTrack($trackId, $options)

Get a track.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-track

Arguments

  • $trackId string - ID or URI of the track.
  • $options array|object - Optional. Options for the track.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.

Return values

  • array|object The requested track. Type is controlled by the return_assoc option.

getTracks

SpotifyWebAPI::getTracks($trackIds, $options)

Get multiple tracks.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-several-tracks

Arguments

  • $trackIds array - IDs or URIs of the tracks.
  • $options array|object - Optional. Options for the tracks.
    • string market Optional. ISO 3166-1 alpha-2 country code, provide this if you wish to apply Track Relinking.

Return values

  • array|object The requested tracks. Type is controlled by the return_assoc option.

getUser

SpotifyWebAPI::getUser($userId)

Get a user.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-users-profile

Arguments

  • $userId string - ID or URI of the user.

Return values

  • array|object The requested user. Type is controlled by the return_assoc option.

getUserFollowedArtists

SpotifyWebAPI::getUserFollowedArtists($options)

Get the artists followed by the current user.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-followed

Arguments

  • $options array|object - Optional. Options for the artists.
    • int limit Optional. Limit the number of artists returned.
    • string after Optional. The last artist ID retrieved from the previous request.

Return values

  • array|object A list of artists. Type is controlled by the return_assoc option.

getUserPlaylists

SpotifyWebAPI::getUserPlaylists($userId, $options)

Get a user's playlists.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-list-users-playlists

Arguments

  • $userId string - ID or URI of the user.
  • $options array|object - Optional. Options for the tracks.
    • int limit Optional. Limit the number of tracks.
    • int offset Optional. Number of tracks to skip.

Return values

  • array|object The user's playlists. Type is controlled by the return_assoc option.

me

SpotifyWebAPI::me()

Get the currently authenticated user.
https://developer.spotify.com/documentation/web-api/reference/#/operations/get-current-users-profile

Return values

  • array|object The currently authenticated user. Type is controlled by the return_assoc option.

myAlbumsContains

SpotifyWebAPI::myAlbumsContains($albums)

Check if albums are saved in the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/check-users-saved-albums

Arguments

  • $albums string|array - Album IDs or URIs to check for.

Return values

  • array Whether each album is saved.

myEpisodesContains

SpotifyWebAPI::myEpisodesContains($episodes)

Check if episodes are saved in the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/check-users-saved-episodes

Arguments

  • $episodes string|array - Episode IDs or URIs to check for.

Return values

  • array Whether each episode is saved.

myShowsContains

SpotifyWebAPI::myShowsContains($shows)

Check if shows are saved in the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/check-users-saved-shows

Arguments

  • $shows string|array - Show IDs or URIs to check for.

Return values

  • array Whether each show is saved.

myTracksContains

SpotifyWebAPI::myTracksContains($tracks)

Check if tracks are saved in the current user's Spotify library.
https://developer.spotify.com/documentation/web-api/reference/#/operations/check-users-saved-tracks

Arguments

  • $tracks string|array - Track IDs or URIs to check for.

Return values

  • array Whether each track is saved.

next

SpotifyWebAPI::next($deviceId)

Play the next track in the current users's queue.
https://developer.spotify.com/documentation/web-api/reference/#/operations/skip-users-playback-to-next-track

Arguments

  • $deviceId string - Optional. ID of the device to target.

Return values

  • bool Whether the track was successfully skipped.

pause

SpotifyWebAPI::pause($deviceId)

Pause playback for the current user.
https://developer.spotify.com/documentation/web-api/reference/#/operations/pause-a-users-playback

Arguments

  • $deviceId string - Optional. ID of the device to pause on.

Return values

  • bool Whether the playback was successfully paused.

play

SpotifyWebAPI::play($deviceId, $options)

Start playback for the current user.
https://developer.spotify.com/documentation/web-api/reference/#/operations/start-a-users-playback

Arguments

  • $deviceId string - Optional. ID of the device to play on.
  • $options array|object - Optional. Options for the playback.
    • string context_uri Optional. URI of the context to play, for example an album.
    • array uris Optional. Spotify track URIs to play.
    • object offset Optional. Indicates from where in the context playback should start.
    • int position_ms. Optional. Indicates the position to start playback from.

Return values

  • bool Whether the playback was successfully started.

previous

SpotifyWebAPI::previous($deviceId)

Play the previous track in the current users's queue.
https://developer.spotify.com/documentation/web-api/reference/#/operations/skip-users-playback-to-previous-track

Arguments

  • $deviceId string - Optional. ID of the device to target.

Return values

  • bool Whether the track was successfully skipped.

queue

SpotifyWebAPI::queue($trackUri, $deviceId)

Add an item to the queue.
https://developer.spotify.com/documentation/web-api/reference/#/operations/add-to-queue

Arguments

  • $trackUri string - Required. Track ID, track URI or episode URI to queue.
  • $deviceId string - Optional. ID of the device to target.

Return values

  • bool Whether the track was successfully queued.

reorderPlaylistTracks

SpotifyWebAPI::reorderPlaylistTracks($playlistId, $options)

Reorder the tracks in a playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/reorder-or-replace-playlists-tracks

Arguments

  • $playlistId string - ID or URI of the playlist.
  • $options array|object - Options for the new tracks.
    • int range_start Required. Position of the first track to be reordered.
    • int range_length Optional. The amount of tracks to be reordered.
    • int insert_before Required. Position where the tracks should be inserted.
    • string snapshot_id Optional. The playlist's snapshot ID.

Return values

  • string|bool A new snapshot ID or false if the tracks weren't successfully reordered.

repeat

SpotifyWebAPI::repeat($options)

Set repeat mode for the current user’s playback.
https://developer.spotify.com/documentation/web-api/reference/#/operations/set-repeat-mode-on-users-playback

Arguments

  • $options array|object - Optional. Options for the playback repeat mode.
    • string state Required. The repeat mode. See Spotify docs for possible values.
    • string device_id Optional. ID of the device to target.

Return values

  • bool Whether the playback repeat mode was successfully changed.

replacePlaylistTracks

SpotifyWebAPI::replacePlaylistTracks($playlistId, $tracks)

Replace all tracks in a playlist with new ones.
https://developer.spotify.com/documentation/web-api/reference/#/operations/reorder-or-replace-playlists-tracks

Arguments

  • $playlistId string - ID or URI of the playlist.
  • $tracks string|array - IDs, track URIs, or episode URIs to replace with.

Return values

  • bool Whether the tracks was successfully replaced.

search

SpotifyWebAPI::search($query, $type, $options)

Search for an item.
https://developer.spotify.com/documentation/web-api/reference/#/operations/search

Arguments

  • $query string - The term to search for.
  • $type string|array - The type of item to search for.
  • $options array|object - Optional. Options for the search.
    • string market Optional. Limit the results to items that are playable in this market, for example SE.
    • int limit Optional. Limit the number of items.
    • int offset Optional. Number of items to skip.
    • string include_external Optional. Whether or not to mark externally hosted content as playable.

Return values

  • array|object The search results. Type is controlled by the return_assoc option.

seek

SpotifyWebAPI::seek($options)

Change playback position for the current user.
https://developer.spotify.com/documentation/web-api/reference/#/operations/seek-to-position-in-currently-playing-track

Arguments

  • $options array|object - Optional. Options for the playback seeking.
    • string position_ms Required. The position in milliseconds to seek to.
    • string device_id Optional. ID of the device to target.

Return values

  • bool Whether the playback position was successfully changed.

setAccessToken

SpotifyWebAPI::setAccessToken($accessToken)

Set the access token to use.

Arguments

  • $accessToken string - The access token.

Return values

  • self

setOptions

SpotifyWebAPI::setOptions($options)

Set options

Arguments

  • $options array|object - Options to set.

Return values

  • self

setSession

SpotifyWebAPI::setSession($session)

Set the Session object to use.

Arguments

  • $session \SpotifyWebAPI\Session - The Session object.

Return values

  • self

shuffle

SpotifyWebAPI::shuffle($options)

Set shuffle mode for the current user’s playback.
https://developer.spotify.com/documentation/web-api/reference/#/operations/toggle-shuffle-for-users-playback

Arguments

  • $options array|object - Optional. Options for the playback shuffle mode.
    • bool state Required. The shuffle mode. See Spotify docs for possible values.
    • string device_id Optional. ID of the device to target.

Return values

  • bool Whether the playback shuffle mode was successfully changed.

unfollowArtistsOrUsers

SpotifyWebAPI::unfollowArtistsOrUsers($type, $ids)

Remove the current user as a follower of one or more artists or other Spotify users.
https://developer.spotify.com/documentation/web-api/reference/#/operations/unfollow-artists-users

Arguments

  • $type string - The type to check: either 'artist' or 'user'.
  • $ids string|array - IDs or URIs of the users or artists to unfollow.

Return values

  • bool Whether the artists or users were successfully unfollowed.

unfollowPlaylist

SpotifyWebAPI::unfollowPlaylist($playlistId)

Remove the current user as a follower of a playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/unfollow-playlist

Arguments

  • $playlistId string - ID or URI of the playlist to unfollow.

Return values

  • bool Whether the playlist was successfully unfollowed.

updatePlaylist

SpotifyWebAPI::updatePlaylist($playlistId, $options)

Update the details of a playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/change-playlist-details

Arguments

  • $playlistId string - ID or URI of the playlist to update.
  • $options array|object - Options for the playlist.
    • bool collaborative Optional. Whether the playlist should be collaborative or not.
    • string description Optional. Description of the playlist.
    • string name Optional. Name of the playlist.
    • bool public Optional. Whether the playlist should be public or not.

Return values

  • bool Whether the playlist was successfully updated.

updatePlaylistImage

SpotifyWebAPI::updatePlaylistImage($playlistId, $imageData)

Update the image of a playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/upload-custom-playlist-cover

Arguments

  • $playlistId string - ID or URI of the playlist to update.
  • $imageData string - Base64 encoded JPEG image data, maximum 256 KB in size.

Return values

  • bool Whether the playlist was successfully updated.

usersFollowPlaylist

SpotifyWebAPI::usersFollowPlaylist($playlistId, $options)

Check if a set of users are following a playlist.
https://developer.spotify.com/documentation/web-api/reference/#/operations/check-if-user-follows-playlist

Arguments

  • $playlistId string - ID or URI of the playlist.
  • $options array|object - Options for the check.
    • ids string|array Required. IDs or URIs of the users to check for.

Return values

  • array Whether each user is following the playlist.