close
The Wayback Machine - https://web.archive.org/web/20140813170924/https://developer.beatsmusic.com/docs/read/playlists/Tracks_Update

Tracks: Update

You can set or clear the tracks for a playlist. The track IDs you specify will overwrite any existing tracks for this playlist.


Endpoint URL

/api/playlists/:playlist_id/tracks


HTTP Method

PUT


Authentication

OAuth 2.0: Access token required. See Authentication for examples and details.


Parameters

Name Required Description Example
playlist_id required The unique ID for the playlist. pl151699877020041728
track_ids required An array of track IDs to assign to the playlist. To clear the track list, pass in an empty parameter (track_ids=). track_ids=tr649915&track_ids=568234

Response Elements

ResponseDescription
code

Beats API response code. OK if successful; otherwise an error code is returned.


 

Example Request

One of the central activities for a user is creating playlists (see Create or the Tutorial). When you create a playlist, it simply has a name (along with other metadata) but no tracks. After you create the playlist, you can add tracks to it.

Recall that when you first created the playlist, a response containing the playlist ID was returned:

{
    "data": {
        "type": "playlist",
        "id": "pl151699877020041728",
        "name": "My New Playlist",
        "description": "",
        ...
    },
    "code": "OK"
}

If you no longer have that playlist ID, retrieve the user's playlist collection by invoking the User API.

We will use the playlist ID (pl151699877020041728) to add tracks to the existing playlist, "My New Playlist". We will add two of the tracks we found in a catalog search. You will need an access token since you are invoking this API on behalf of a user. You will need to submit the following information to the API:

  • the ID of the playlist you just created
  • the track IDs you would like to add
  • the access token

The general form of this API is:

curl -X PUT "https://partner.api.beatsmusic.com/v1/api/playlists/[YOUR_PLAYLIST_ID]/tracks?
    track_ids=[TRACK_ID]
    &track_ids=[TRACK_ID]
    &access_token=[YOUR_ACCESS_TOKEN]"

When we created the playlist earlier it had a playlist ID of pl151699877020041728. We will also use these track IDs from our previous search of the catalog: tr56470885 and tr51760477.

The API call to add those to tracks to "My New Playlist" is:

curl -X PUT "https://partner.api.beatsmusic.com/v1/api/playlists/pl151699877020041728/tracks?
    track_ids=tr56470885
    &track_ids=tr51760477
    &access_token=7a8tmgnc8zp53a8qeqpeqrgp"

 

Example Response

Open the Beats Music app on your mobile device. You will see that "My New Playlist" contains "Blood on the Tracks" by Phantom Creeps and "Blood on the Tracks" by Michael Gray!

Here is the API response indicating that you have successfully added the tracks to the playlist:

{"code": "OK"}

Docs Navigation