Manage Tracks in User’s Profile
Explore how to manage tracks in a Spotify user's profile by using PUT requests to save tracks and DELETE requests to remove them. Understand the required parameters and how to handle responses for successful or unsuccessful operations.
Overview
In this lesson, we'll use two types of HTTP requests. One is used to save a track to a user profile, whereas the other is used to remove a track from a user profile.
The base URL https://api.spotify.com/v1/me/tracks is used to save or delete tracks to the current user's profile. The PUT request saves the track, whereas a DELETE request removes the specified track from the user profile.
Request parameters
This endpoint has the following query parameter.
Query parameter | Category | Type | Description |
| Required | String | This contains the IDs of the tracks we want to save in the current user's profile. These IDs are separated by a comma(,). We can save a maximum of 20 tracks with one call. |
The table below contains the body parameter of this endpoint.
Body parameter | Category | Type | Description |
| Optional | String | This contains the IDs of the tracks we want to save or delete from the current user's profile. These IDs are separated by a comma(,). We can save or delete a maximum of 50 tracks with one call using this parameter. If we use the |
Save tracks to a user profile
Let's look at how to use this endpoint to save tracks to a user profile. The code below shows how to use this endpoint with the query parameter ids.
Response fields
In case of a successful request, the response of this endpoint doesn't have any content and contains only status_code (200). If the request is unsuccessful, we'll get a message in response that tells us why the request was unsuccessful.
Remove a track from a user profile
Let's look at how to use this endpoint to remove tracks. The code below shows how to send a DELETE request to delete a track from a user profile. We're using the body parameter id instead of the query parameter to send the ID of the track.
Response fields
In case of a successful request, the response of this endpoint doesn't have any content and contains only status_code (200). In response to an unsuccessful request, we get a message in the response, that tells us what went wrong.