add_tracks_to_playlist: Add Tracks to User’s Playlist

View source: R/playlists.R

add_tracks_to_playlistR Documentation

Add Tracks to User’s Playlist

Description

Add one or more tracks to a user’s playlist.

Usage

add_tracks_to_playlist(
  playlist_id,
  uris,
  position = NULL,
  authorization = get_spotify_authorization_code()
)

Arguments

playlist_id

Required. The Spotify ID for the playlist.

uris

Optional. A character vector of Spotify track URIs to add. For example:
uris = c("61H97kuKIpi6kJQRnUEIlh", "2q6vlgBJ432KeZZNt2ZZBV")
A maximum of 100 tracks can be added in one request. The uris will be formed as uris = c("spotify If you have the "spotify:track:" prefix in your vector it will not be duplicated, otherwise it will be added.

position

Optional. Integer indicating the position to insert the tracks, a zero-based index. For example, to insert the tracks in the first position: position = 0; to insert the tracks in the third position: position = 2. If omitted, the tracks will be appended to the playlist. Tracks are added in the order they are listed in the query string or request body.

authorization

Required. A valid access token from the Spotify Accounts service. See the Web API authorization Guide for more details. Defaults to spotifyr::get_spotify_authorization_code(). The access token must have been issued on behalf of the current user.
Adding tracks to the current user’s public playlists requires authorization of the playlist-modify-public scope; adding tracks to the current user’s private playlist (including collaborative playlists) requires the playlist-modify-private scope. See Using Scopes.

Value

The response from the Spotify Web API on the POST request, with a meaningful error message if the operation was not successful.

See Also

Other playlist functions: change_playlist_details(), check_users_following(), create_playlist(), get_my_playlists(), get_playlist(), get_user_playlists(), remove_tracks_from_playlist(), tidy()


spotifyr documentation built on Dec. 28, 2022, 2:08 a.m.