[GH-ISSUE #322] How to get more than 100 track ids on using spotipy? #184

Closed
opened 2026-02-27 23:21:16 +03:00 by kerem · 5 comments
Owner

Originally created by @ghost on GitHub (Oct 2, 2018).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/322

I am trying to get do audio analyze similar to this guy: https://opendatascience.com/a-machine-learning-deep-dive-into-my-spotify-data/

However, when I try to do the same on mine machine, I could only get data from 100 tracks. Yet, I have 1000 tracks.

I tried to use the code from stack overflow: "using while loop and extends the list"

but, I am having a hard time to "extract" the song id from the playlist.

Does anyone know how to do this?

Originally created by @ghost on GitHub (Oct 2, 2018). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/322 I am trying to get do audio analyze similar to this guy: https://opendatascience.com/a-machine-learning-deep-dive-into-my-spotify-data/ However, when I try to do the same on mine machine, I could only get data from 100 tracks. Yet, I have 1000 tracks. I tried to use the code from stack overflow: "using while loop and extends the list" but, I am having a hard time to "extract" the song id from the playlist. Does anyone know how to do this?
kerem closed this issue 2026-02-27 23:21:17 +03:00
Author
Owner

@alexthescott commented on GitHub (Oct 4, 2018):

Assuming you have already created a Spotify object, you can use these two functions in conjunction to create an array of Ids from a playlist. Spotify uses a paging object which stores 100 tracks on a page, with URLs to the next and previous pages. I chose to create two functions to help "flip" the pages. I've run a program similar to this one (collecting URIs) and I was able to get through a playlist with 1600 songs. Let me know if you need anything else!

https://developer.spotify.com/documentation/web-api/reference/object-model/#paging-object

screen shot 2018-10-04 at 1 58 12 pm
<!-- gh-comment-id:427167106 --> @alexthescott commented on GitHub (Oct 4, 2018): Assuming you have already created a Spotify object, you can use these two functions in conjunction to create an array of Ids from a playlist. Spotify uses a paging object which stores 100 tracks on a page, with URLs to the next and previous pages. I chose to create two functions to help "flip" the pages. I've run a program similar to this one (collecting URIs) and I was able to get through a playlist with 1600 songs. Let me know if you need anything else! https://developer.spotify.com/documentation/web-api/reference/object-model/#paging-object <img width="423" alt="screen shot 2018-10-04 at 1 58 12 pm" src="https://user-images.githubusercontent.com/43523995/46502663-8ce02600-c7dd-11e8-85ee-5903d79baab2.png">
Author
Owner

@ghost commented on GitHub (Oct 5, 2018):

Thank you so much for the reply!

I understand whats the code trying to do, but once i implement it, i got this error.
But I don't understand what it mean.

spotipy

<!-- gh-comment-id:427244873 --> @ghost commented on GitHub (Oct 5, 2018): Thank you so much for the reply! I understand whats the code trying to do, but once i implement it, i got this error. But I don't understand what it mean. ![spotipy](https://user-images.githubusercontent.com/14981015/46516469-87abc700-c82f-11e8-8382-379d87afb5c8.PNG)
Author
Owner

@alexthescott commented on GitHub (Oct 5, 2018):

Sorry thats a JSON error on my part. Useful to print the entire track object to see what information it holds, but the code below solves your problem!

ids.append(track['track']['id'])

<!-- gh-comment-id:427247369 --> @alexthescott commented on GitHub (Oct 5, 2018): Sorry thats a JSON error on my part. Useful to print the entire track object to see what information it holds, but the code below solves your problem! ids.append(track['track']['id'])
Author
Owner

@ghost commented on GitHub (Oct 6, 2018):

Thank you!
try it on small playlist it works, but when I tried on the big playlist it gives me this error.

I am so new with python, so I don't really know what's going on.
spotipy

<!-- gh-comment-id:427539133 --> @ghost commented on GitHub (Oct 6, 2018): Thank you! try it on small playlist it works, but when I tried on the big playlist it gives me this error. I am so new with python, so I don't really know what's going on. ![spotipy](https://user-images.githubusercontent.com/14981015/46566515-876e0300-c8e5-11e8-9758-e079b027cf67.PNG)
Author
Owner

@alexthescott commented on GitHub (Oct 6, 2018):

Alright I just debugged a little and rewrote the paginating id request. I ran it on my playlist of 1600 and had no issues!

screen shot 2018-10-06 at 1 27 02 pm
<!-- gh-comment-id:427603954 --> @alexthescott commented on GitHub (Oct 6, 2018): Alright I just debugged a little and rewrote the paginating id request. I ran it on my playlist of 1600 and had no issues! <img width="396" alt="screen shot 2018-10-06 at 1 27 02 pm" src="https://user-images.githubusercontent.com/43523995/46575538-a8793700-c96b-11e8-9191-40e5d4e73b93.png">
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#184
No description provided.