spotify_ex v2.2.1 Spotify.Playlist View Source

Functions for retrieving information about a user’s playlists and for managing a user’s playlists.

Some endpoints return collections. Spotify wraps the collection in a paging object, this API does the same. A single piece of data will not be wrapped.

There are two functions for each endpoint, one that actually makes the request, and one that provides the endpoint:

  Spotify.Playist.create_playlist(conn, "foo", "bar") # makes the POST request.
  Spotify.Playist.create_playlist_url("foo", "bar") # provides the url for the request.

https://developer.spotify.com/web-api/playlist-endpoints/

Link to this section Summary

Functions

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

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

Add one or more tracks to a user’s playlist

Implements the hook expected by the Responder behaviour

Get a category's playlists

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

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

Check to see if one or more Spotify users are following a specified playlist. Spotify Documentation

Check to see if one or more Spotify users are following a specified playlist

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

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

Get a list of featured playlists. Spotify Documenation

Get a list of featured playlists

Add the current user as a follower of a playlist. Spotify Documentation

Add the current user as a follower of a playlist

Get a list of the playlists owned or followed by the current Spotify user. Spotify Documentation

Get a list of the playlists owned or followed by a Spotify user

Get full details of the tracks of a playlist owned by a Spotify user. Spotify Documentation

Get full details of the tracks of a playlist owned by a Spotify user

Get a playlist owned by a Spotify user

Get a list of the playlists owned or followed by a Spotify user. Spotify Documentation

Get a list of the playlists owned or followed by a Spotify user

Remove one or more tracks from a user’s playlist. Spotify Documentation

Remove one or more tracks from a user’s playlist

Reorder a track or a group of tracks in a playlist. Spotify Documentation

Reorder a track or a group of tracks in a playlist

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

Replace all the tracks in a playlist, overwriting its existing tracks. This

Remove the current user as a follower of a playlist. Spotify Documentation

Remove the current user as a follower of a playlist

Link to this section Functions

Link to this function

add_tracks(conn, user_id, playlist_id, params) View Source

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

Method: POST

Optional Params: uris, position

You can also pass the URI param in the request body. See Spotify docs and add_tracks/4.

Spotify.Playlist.add_tracks("123", "456", uris: "spotify:track:4iV5W9uYEdYUVa79Axb7Rh")
# => {:ok, %{"snapshot_id" => "foo"}}
Link to this function

add_tracks(conn, user_id, playlist_id, body, params) View Source

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

Method: POST

Optional Params: uris, position

You can also pass the URI param in the request body. If you don't want to pass params, use an empty list. See Spotify docs and add_tracks/5.

body = Poison.encode!(%{ uris: [ "spotify:track:755MBpLqJqCO87PkoyBBQC", "spotify:track:1hsWu8gT2We6OzjhYGAged" ]})

Spotify.Playlist.add_tracks("123", "456", body, [])
# => {:ok, %{"snapshot_id" => "foo"}}
Link to this function

add_tracks_url(user_id, playlist_id, params \\ []) View Source

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

iex> Spotify.Playlist.add_tracks_url("123", "456", uris: "spotify:track:4iV5W9uYEdYUVa79Axb7Rh")
"https://api.spotify.com/v1/users/123/playlists/456/tracks?uris=spotify%3Atrack%3A4iV5W9uYEdYUVa79Axb7Rh"

Implements the hook expected by the Responder behaviour

Link to this function

by_category(conn, id, params \\ []) View Source

Get a category's playlists. Spotify Documentation

Valid params: country, limit, offset

Method: GET

Example:

Spotify.by_category(conn, "123")
# => {:ok, %{ items: [%Spotify.Playlist{..} ...]}}
Link to this function

by_category_url(id, params \\ []) View Source

Get a category's playlists.

iex> Spotify.Playlist.by_category_url("123", [country: "US", limit: 5])
"https://api.spotify.com/v1/browse/categories/123/playlists?country=US&limit=5"
Link to this function

change_playlist(conn, user_id, playlist_id, body) View Source

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

Method: PUT

Request Data): name, public

body = "{ "name": "foo", "public": true }"
Spotify.Playlist.change_playlist(conn, "123", "456", body)
# => :ok
Link to this function

change_playlist_url(user_id, playlist_id) View Source

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

iex> Spotify.Playlist.change_playlist_url("123", "456")
"https://api.spotify.com/v1/users/123/playlists/456"
Link to this function

check_followers(conn, owner_id, playlist_id, params) View Source

Check to see if one or more Spotify users are following a specified playlist. Spotify Documentation

Method: GET

**Query Params: ids

Spotify.Playlist.check_followers(conn, "123", "456", ids: "foo,bar")
# => {:ok, boolean}
Link to this function

check_followers_url(owner_id, playlist_id, params) View Source

Check to see if one or more Spotify users are following a specified playlist.

iex> Spotify.Playlist.check_followers_url("123", "456", ids: "foo,bar")
"https://api.spotify.com/v1/users/123/playlists/456/followers/contains?ids=foo%2Cbar"
Link to this function

create_playlist(conn, user_id, body) View Source

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

Method: POST

Body Params: name, public

body = "{"name": "foo"}"
Spotify.Playlist.create_playlist(conn, "123", body)
# => %Spotify.Playlist{..}
Link to this function

create_playlist_url(user_id) View Source

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

iex> Spotify.Playlist.create_playlist_url("123")
"https://api.spotify.com/v1/users/123/playlists"
Link to this function

featured(conn, params \\ []) View Source

Get a list of featured playlists. Spotify Documenation

Valid params: locale, country, timestamp, limit, offset

Method: GET

Spotify.Playlist.featured(country: "US")
# => {:ok, %{ items: [%Spotify.Playlist{..} ...]}}
Link to this function

follow_playlist(conn, owner_id, playlist_id, body \\ "") View Source

Add the current user as a follower of a playlist. Spotify Documentation

Optional Body Params: public

Method: PUT

Spotify.Playlist.follow_playlist(conn, "123", "456")
# => :ok
Link to this function

follow_playlist_url(owner_id, playlist_id) View Source

Add the current user as a follower of a playlist.

iex> Spotify.Playlist.follow_playlist_url("123", "456")
"https://api.spotify.com/v1/users/123/playlists/456/followers"
Link to this function

get_current_user_playlists(conn, params \\ []) View Source

Get a list of the playlists owned or followed by the current Spotify user. Spotify Documentation

Method: GET

** Optional Params: limit, offset

Spotify.Playlist.get_users_playlists(conn, "123", q: "foo", limit: 5)
# => {:ok, %{
#     cursor: nil,
#     href: ..,
#     items: [%Spotify.Playlist{..} ...],
#     limit: 20,
#     next: nil,
#     offset: 0,
#     previous: nil,
#     total: 20
#   }
# }
Link to this function

get_current_user_playlists_url(params \\ []) View Source

Get a list of the playlists owned or followed by a Spotify user.

iex> Spotify.Playlist.get_current_user_playlists_url(limit: 5)
"https://api.spotify.com/v1/me/playlists?limit=5"
Link to this function

get_playlist(conn, user_id, playlist_id, params \\ []) View Source

Get a playlist owned by a Spotify user. Spotify Documentation

Method: GET

**Optional Params fields, market

Spotify.Playlist.get_playlist(conn, "123", "456")
# => {:ok, %Spotify.Playlist{..}}
Link to this function

get_playlist_tracks(conn, user_id, playlist_id, params \\ []) View Source

Get full details of the tracks of a playlist owned by a Spotify user. Spotify Documentation

Method: GET

**Optional Params fields, market, limit, offset

Spotify.Playlist.get_playlist_tracks(conn, "123", "456")
# => {:ok, %Spotify.Playlist{..}}
Link to this function

get_playlist_tracks_url(user_id, playlist_id, params \\ []) View Source

Get full details of the tracks of a playlist owned by a Spotify user.

iex> Spotify.Playlist.get_playlist_tracks_url("123", "456", limit: 5, offset: 5)
"https://api.spotify.com/v1/users/123/playlists/456/tracks?limit=5&offset=5"
Link to this function

get_playlist_url(user_id, playlist_id, params \\ []) View Source

Get a playlist owned by a Spotify user.

iex> Spotify.Playlist.get_playlist_url("123", "456", market: "foo")
"https://api.spotify.com/v1/users/123/playlists/456?market=foo"
Link to this function

get_users_playlists(conn, user_id, params \\ []) View Source

Get a list of the playlists owned or followed by a Spotify user. Spotify Documentation

Method: GET

** Optional Params: limit, offset

Spotify.Playlist.get_users_playlists(conn, "123", q: "foo", limit: 5)
# => {:ok, %{
#     cursor: nil,
#     href: ..,
#     items: [%Spotify.Playlist{..} ...],
#     limit: 20,
#     next: nil,
#     offset: 0,
#     previous: nil,
#     total: 20
#   }
# }
Link to this function

get_users_playlists_url(user_id, params \\ []) View Source

Get a list of the playlists owned or followed by a Spotify user.

iex> Spotify.Playlist.get_users_playlists_url("123", limit: 5)
"https://api.spotify.com/v1/users/123/playlists?limit=5"
Link to this function

remove_tracks(conn, user_id, playlist_id) View Source

Remove one or more tracks from a user’s playlist. Spotify Documentation

Method: DELETE

Request Data: tracks

Spotify.Playlist.remove_tracks(conn, "123", "456")
# => {:ok, %{"snapshot_id": "foo"}}
Link to this function

remove_tracks_url(user_id, playlist_id) View Source

Remove one or more tracks from a user’s playlist.

iex> Spotify.Playlist.remove_tracks_url("123", "456")
"https://api.spotify.com/v1/users/123/playlists/456/tracks"
Link to this function

reorder_tracks(conn, user_id, playlist_id, body) View Source

Reorder a track or a group of tracks in a playlist. Spotify Documentation

Method: PUT

Required Request Body Data: range_start, insert_before

Optional Request Body Data: range_length, snapshot_id

body = { "range_start": "..." }
Spotify.Playlist.change_playlist(conn, "123", "456", body)
# => {:ok, %{"snapshot_id" => "klq34klj..."} }
Link to this function

reorder_tracks_url(user_id, playlist_id) View Source

Reorder a track or a group of tracks in a playlist.

iex> Spotify.Playlist.reorder_tracks_url("123", "456")
"https://api.spotify.com/v1/users/123/playlists/456/tracks"
Link to this function

replace_tracks(conn, user_id, playlist_id, params) View Source

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

Method: PUT

Optional Query Params: uris

You can also pass the URI param in the request body. Use replace_tracks/2. See Spotify docs.

Spotify.Playlist.replace_tracks(conn, "123", "456", uris: "spotify:track:4iV5W9uYEdYUVa79Axb7Rh,spotify:track:adkjaklsd94h")
:ok
Link to this function

replace_tracks_url(user_id, playlist_id, params \\ []) View Source

Replace all the tracks in a playlist, overwriting its existing tracks. This

iex> Spotify.Playlist.replace_tracks_url("123", "456", uris: "spotify:track:4iV5W9uYEdYUVa79Axb7Rh,spotify:track:adkjaklsd94h")
"https://api.spotify.com/v1/users/123/playlists/456/tracks?uris=spotify%3Atrack%3A4iV5W9uYEdYUVa79Axb7Rh%2Cspotify%3Atrack%3Aadkjaklsd94h"
Link to this function

unfollow_playlist(conn, owner_id, playlist_id) View Source

Remove the current user as a follower of a playlist. Spotify Documentation

Method: DELETE

Spotify.Playlist.unfollow_playlist(conn, "123", "456")
# => :ok
Link to this function

unfollow_playlist_url(owner_id, playlist_id) View Source

Remove the current user as a follower of a playlist.

iex> Spotify.Playlist.unfollow_playlist_url("123", "456")
"https://api.spotify.com/v1/users/123/playlists/456/followers"