[GH-ISSUE #299] Stop at 50 tracks #170

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

Originally created by @ghost on GitHub (Jun 17, 2018).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/299

I have tried to see information with Unleashed album by Two Steps From Well and I don't know why the items are only 50 if the songs are 56. (Sorry for my english)

Originally created by @ghost on GitHub (Jun 17, 2018). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/299 I have tried to see information with Unleashed album by Two Steps From Well and I don't know why the items are only 50 if the songs are 56. (Sorry for my english)
kerem 2026-02-27 23:21:11 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@ritiek commented on GitHub (Jun 19, 2018):

Spotify API returns the first page and each page contains maximum 50 songs. To fetch rest of the songs, you need fetch more pages.

I do something like this to workaround this problem: github.com/ritiek/spotify-downloader@0a3b7bd7d8/core/spotify_tools.py (L162-L181)

So, you might have to structure your code something like this:

while True:
    for track in tracks['items']:
        # do stuff with track
        print(track)
    # 1 page = 50 results
    # check if there are more pages
    if track['next']:
        tracks = spotify.next(tracks)
    # if no more pages, exit while loop
    else:
        break

If you're still facing problems, share your code here and we'll try to figure out. Remember to remove your credentials.

(P.S. Your english is pretty good :)

<!-- gh-comment-id:398373071 --> @ritiek commented on GitHub (Jun 19, 2018): Spotify API returns the first page and each page contains maximum 50 songs. To fetch rest of the songs, you need fetch more pages. I do something like this to workaround this problem: https://github.com/ritiek/spotify-downloader/blob/0a3b7bd7d84fd0622fdca01413d8a82f57d44fe3/core/spotify_tools.py#L162-L181 So, you might have to structure your code something like this: ```python while True: for track in tracks['items']: # do stuff with track print(track) # 1 page = 50 results # check if there are more pages if track['next']: tracks = spotify.next(tracks) # if no more pages, exit while loop else: break ``` If you're still facing problems, share your code here and we'll try to figure out. Remember to remove your credentials. (P.S. Your english is pretty good :)
Author
Owner

@ghost commented on GitHub (Jun 20, 2018):

Thanks very much for the answer, maybe you will be happy know that I have used your spotify-dowloader some time ago.

<!-- gh-comment-id:398735924 --> @ghost commented on GitHub (Jun 20, 2018): Thanks very much for the answer, maybe you will be happy know that I have used your spotify-dowloader some time ago.
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#170
No description provided.