Why can't I view more than 50 tracks in the Tracks API?
Closed this issue · 2 comments
Using the web-api, I cannot get more than 50 tracks when getting the user's saved tracks. The documentation makes it clear that the limit is 50, so I was wondering if there is any alternative way to access this information?
Use the offset
field to start past 50.
If you don't specify an offset, it defaults to zero, so repeated calls will always return the same first 50.
The request format you're looking for is https://api.spotify.com/v1/me/tracks?offset=X
where X is the next batch of songs you want. For example, https://api.spotify.com/v1/me/tracks?offset=50
, followed by https://api.spotify.com/v1/me/tracks?offset=100
, etc
edit:
Sorry for snooping, but I found this function in your monthly_music's server script that seems to be the likely culprit:
Your app.get('/view_songs')
function sets up the following object:
var authOptions = {
url: 'https://api.spotify.com/v1/me/tracks?market=US&offset=50&limit=50',
headers: {
'Authorization': "Bearer " + access_token,
'Content-Type': "application/json",
'Accept': "application/json"
}
};
Like discussed above, your url
string doesn't take into account that offset
needs to be a variable instead of a constant. At the moment it is hard coded to 50, instead of adjusted when needed.