Class PlaylistsApi

    • Constructor Detail

      • PlaylistsApi

        public PlaylistsApi()
    • Method Detail

      • addTracksToPlaylist

        public AddTracksToPlaylistRequest addTracksToPlaylist​(String playlistId,
                                                              List<String> uris)

        Add Items to a Playlist

        Add one or more items to a user's playlist.

        Parameters:
        playlistId -

        The Spotify ID for the playlist.

        uris -

        A JSON array of the Spotify URIs to add. For example: {"uris": ["spotify:track:4iV5W9uYEdYUVa79Axb7Rh","spotify:track:1301WleyT98MSxVHPZCA6M", "spotify:episode:512ojhOuo1ktJprKbVcKyQ"]}
        A maximum of 100 items can be added in one request. Note: if the uris parameter is present in the query string, any URIs listed here in the body will be ignored.

        Returns:
        a AddTracksToPlaylistRequest object to build and execute the request
      • changePlaylistDetails

        public ChangePlaylistDetailsRequest changePlaylistDetails​(String playlistId)

        Change a Playlist's Details

        Change a playlist's name and public/private state. (The user must, of course, own the playlist.)

        Parameters:
        playlistId -

        The Spotify ID for the playlist.

        Returns:
        a ChangePlaylistDetailsRequest object to build and execute the request
      • createPlaylist

        public CreatePlaylistRequest createPlaylist​(String userId,
                                                    String name)

        Create a Playlist

        Create a playlist for a Spotify user. (The playlist will be empty until you add tracks.)

        Parameters:
        userId -

        The user's Spotify user ID.

        name -

        The name for the new playlist, for example "Your Coolest Playlist" . This name does not need to be unique; a user may have several playlists with the same name.

        Returns:
        a CreatePlaylistRequest object to build and execute the request
      • getPlaylistCover

        public GetPlaylistCoverRequest getPlaylistCover​(String playlistId)

        Get a Playlist Cover Image

        Get the current image associated with a specific playlist.

        Parameters:
        playlistId -

        The Spotify ID for the playlist.

        Returns:
        a GetPlaylistCoverRequest object to build and execute the request
      • removeTracksPlaylist

        public RemoveTracksPlaylistRequest removeTracksPlaylist​(String playlistId,
                                                                List<Map<String,​Object>> tracks)

        Remove Items from a Playlist

        Remove one or more items from a user's playlist.

        Parameters:
        playlistId -

        The Spotify ID

        tracks -

        An array of objects containing Spotify URIs of the tracks or episodes to remove. For example: { "tracks": [{ "uri": "spotify:track:4iV5W9uYEdYUVa79Axb7Rh" },{ "uri": "spotify:track:1301WleyT98MSxVHPZCA6M" }] }. A maximum of 100 objects can be sent at once.

        Returns:
        a RemoveTracksPlaylistRequest object to build and execute the request
      • reorderPlaylistsTracks

        public ReorderPlaylistsTracksRequest reorderPlaylistsTracks​(String playlistId,
                                                                    int rangeStart,
                                                                    int insertBefore)

        Reorder items in a playlist

        Reorder an item or a group of items in a playlist.

        Parameters:
        playlistId -

        The Spotify ID for the playlist.

        rangeStart -

        The position of the first item to be reordered.

        insertBefore -

        The position where the items should be inserted.
        To reorder the items to the end of the playlist, simply set insert_before to the position after the last item.
        Examples:
        To reorder the first item to the last position in a playlist with 10 items, set range_start to 0, and insert_before to 10.
        To reorder the last item in a playlist with 10 items to the start of the playlist, set range_start to 9, and insert_before to 0.

        Returns:
        a ReorderPlaylistsTracksRequest object to build and execute the request
      • replacePlaylistsTracks

        public ReplacePlaylistsTracksRequest replacePlaylistsTracks​(String playlistId,
                                                                    List<String> uris)

        Replace items in a playlist

        Replace all the items in a playlist, overwriting its existing items. This powerful request can be useful for replacing items, re-ordering existing items, or clearing the playlist.

        Parameters:
        playlistId -

        The Spotify ID for the playlist.

        uris -

        A comma-separated list of Spotify URIs to set, can be track or episode URIs. For example: uris=spotify:track:4iV5W9uYEdYUVa79Axb7Rh,spotify:track:1301WleyT98MSxVHPZCA6M,spotify:episode:512ojhOuo1ktJprKbVcKyQ
        A maximum of 100 items can be set in one request.

        Returns:
        a ReplacePlaylistsTracksRequest object to build and execute the request
      • uploadCustomPlaylistCover

        public UploadCustomPlaylistCoverRequest uploadCustomPlaylistCover​(String playlistId,
                                                                          String base64Image)

        Upload a Custom Playlist Cover Image

        Replace the image used to represent a specific playlist.

        Parameters:
        playlistId -

        The Spotify ID for the playlist.

        base64Image -

        The new cover image of the playlist as a Base64 encoded JPEG image. Maximum payload size is 256KB.

        Returns:
        a UploadCustomPlaylistCoverRequest object to build and execute the request