[GH-ISSUE #351] artist_albums() does not return all albums of an artist #202

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

Originally created by @flotux2 on GitHub (Feb 4, 2019).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/351

Hi,

from the example script artist_albums.py I used the following code snippet to get all albums from an artist:

albums = []
results = sp.artist_albums(artist['id'], album_type='album')
albums.extend(results['items'])
while results['next']:
    results = sp.next(results)
    albums.extend(results['items'])

albums.sort(key=lambda album:album['name'].lower())
for album in albums:
    name = album['name']
    print((' ' + name))

I noticed that that will not return all albums of the artist. In my case there are over 60 albums available inside the Spotify app but in my Python script artis_album() return only 41 albums. I already experimented with the album_type and limit parameters. But that doesn't help.

Any idea how to get alle albums of an artist?

Thanks and kind regards
Florian

Originally created by @flotux2 on GitHub (Feb 4, 2019). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/351 Hi, from the example script artist_albums.py I used the following code snippet to get all albums from an artist: albums = [] results = sp.artist_albums(artist['id'], album_type='album') albums.extend(results['items']) while results['next']: results = sp.next(results) albums.extend(results['items']) albums.sort(key=lambda album:album['name'].lower()) for album in albums: name = album['name'] print((' ' + name)) I noticed that that will not return all albums of the artist. In my case there are over 60 albums available inside the Spotify app but in my Python script artis_album() return only 41 albums. I already experimented with the album_type and limit parameters. But that doesn't help. Any idea how to get alle albums of an artist? Thanks and kind regards Florian
kerem closed this issue 2026-02-27 23:21:22 +03:00
Author
Owner

@ritiek commented on GitHub (Feb 4, 2019):

Could you provide the Spotify URL of the artist you are trying to fetch albums of?

<!-- gh-comment-id:460269634 --> @ritiek commented on GitHub (Feb 4, 2019): Could you provide the Spotify URL of the artist you are trying to fetch albums of?
Author
Owner

@flotux2 commented on GitHub (Feb 4, 2019):

The URL is:

https://open.spotify.com/artist/0jRC2uXx4hEpqNrBDJdY7l?si=7oAzQqiVQD6smYAljwkRqQ

The artist's name is "Conni", the protagonist of a famous German radio play for children. 😉

<!-- gh-comment-id:460337847 --> @flotux2 commented on GitHub (Feb 4, 2019): The URL is: https://open.spotify.com/artist/0jRC2uXx4hEpqNrBDJdY7l?si=7oAzQqiVQD6smYAljwkRqQ The artist's name is "Conni", the protagonist of a famous German radio play for children. 😉
Author
Owner

@flotux2 commented on GitHub (Feb 4, 2019):

The strange thing is that I can get all the albums with the Spotify Web API console. I get the maximium 50 results due to the limit and see the link to the next results.

spotify web api console

<!-- gh-comment-id:460429599 --> @flotux2 commented on GitHub (Feb 4, 2019): The strange thing is that I can get all the albums with the Spotify Web API console. I get the maximium 50 results due to the limit and see the link to the next results. ![spotify web api console](https://user-images.githubusercontent.com/23209679/52239976-04c77580-28d0-11e9-862f-492db70eb63f.png)
Author
Owner

@ritiek commented on GitHub (Feb 5, 2019):

That is weird. I tried the same code as you and was able to fetch 60 albums:

Code
import spotipy
import spotipy.oauth2 as oauth2

CLIENT_ID = 'CLIENT_ID'
CLIENT_SECRET = 'CLIENT_SECRET'

credentials = oauth2.SpotifyClientCredentials(
        client_id=CLIENT_ID,
        client_secret=CLIENT_SECRET)

token = credentials.get_access_token()
sp = spotipy.Spotify(auth=token)

artist = sp.artist("https://open.spotify.com/artist/0jRC2uXx4hEpqNrBDJdY7l")

albums = []
results = sp.artist_albums(artist['id'], album_type='album')
albums.extend(results['items'])
while results['next']:
    results = sp.next(results)
    albums.extend(results['items'])

albums.sort(key=lambda album:album['name'].lower())
for album in albums:
    name = album['name']
    print((' ' + name))

print(len(albums))

Output
 57: Conni und die Nacht im Museum
 58: Conni geht zum Kinderarzt (neu)/Conni besucht Oma und Opa
 Conni & Co - Das Original-Hörspiel zum Kinofilm
 Conni & Co 2 - Das Geheimnis des T-Rex - Das Original-Hörspiel zum Kinofilm
 Conni auf dem Bauernhof / Conni und das neue Baby
 Conni auf dem Reiterhof
 Conni backt Pizza / Conni lernt Rad fahren
 Conni bekommt eine Katze / Conni hat Geburtstag
 Conni bekommt Taschengeld / Conni verkleidet sich
 Conni feiert Geburtstag
 Conni feiert Weihnachten / Conni fährt Ski
 Conni geht auf Klassenfahrt
 Conni geht einkaufen / Conni und der Läusealarm
 Conni geht verloren / Conni in den Bergen
 Conni geht zelten / Conni lernt reiten
 Conni geht zum Film
 Conni geht zur Zahnärztin / Conni ist wütend
 Conni hilft Papa / Conni streitet sich mit Julia
 Conni im Krankenhaus / Conni tanzt
 Conni in der großen Stadt
 Conni ist krank / Conni beim Frisör
 Conni kommt in den Kindergarten (neu) / Conni geht aufs Töpfchen
 Conni kommt in den Kindergarten / Conni macht das Seepferdchen
 Conni kommt in die Schule (neu) / Conni backt Pfannkuchen
 Conni kommt in die Schule / Conni geht zum Arzt
 Conni lernt backen / Conni hilft Mama
 Conni löst einen kniffligen Fall
 Conni macht einen Ausflug / Conni geht auf Reisen
 Conni reist ans Mittelmeer
 Conni rettet die Tiere
 Conni rettet Oma
 Conni schläft im Kindergarten / Conni geht in den Zoo
 Conni und das Familienfest
 Conni und das ganz spezielle Weihnachtsfest
 Conni und das Geheimnis der Koi
 Conni und das große Bergabenteuer
 Conni und das Hochzeitsfest
 Conni und das Kinderfest / Conni im Zirkus
 Conni und das Klassencamp
 Conni und das neue Fohlen
 Conni und das Ponyabenteuer
 Conni und das tanzende Pony
 Conni und der Dinoknochen
 Conni und der Ferienzirkus
 Conni und der große Schnee
 Conni und der Liebesbrief
 Conni und der Osterhase / Conni spielt Fußball
 Conni und der verschwundene Hund
 Conni und die Burg der Vampire
 Conni und die Detektive
 Conni und die große Eiszeit
 Conni und die Jungs von nebenan
 Conni und die Katzenliebe
 Conni und die Nixen
 Conni und die verflixte 13
 Conni und die wilden Tiere
 Conni und ihr Lieblingspony / Conni läuft Laterne
 Conni zieht um / Conni macht Musik
 Conni übernachtet bei Julia / Conni geht nicht mit Fremden mit
 Connis erster Flug / Conni geht zum Zahnarzt
60
<!-- gh-comment-id:460466263 --> @ritiek commented on GitHub (Feb 5, 2019): That is weird. I tried the same code as you and was able to fetch 60 albums: <details> <summary>Code</summary> ```python import spotipy import spotipy.oauth2 as oauth2 CLIENT_ID = 'CLIENT_ID' CLIENT_SECRET = 'CLIENT_SECRET' credentials = oauth2.SpotifyClientCredentials( client_id=CLIENT_ID, client_secret=CLIENT_SECRET) token = credentials.get_access_token() sp = spotipy.Spotify(auth=token) artist = sp.artist("https://open.spotify.com/artist/0jRC2uXx4hEpqNrBDJdY7l") albums = [] results = sp.artist_albums(artist['id'], album_type='album') albums.extend(results['items']) while results['next']: results = sp.next(results) albums.extend(results['items']) albums.sort(key=lambda album:album['name'].lower()) for album in albums: name = album['name'] print((' ' + name)) print(len(albums)) ``` </details> <br> <details> <summary>Output</summary> ``` 57: Conni und die Nacht im Museum 58: Conni geht zum Kinderarzt (neu)/Conni besucht Oma und Opa Conni & Co - Das Original-Hörspiel zum Kinofilm Conni & Co 2 - Das Geheimnis des T-Rex - Das Original-Hörspiel zum Kinofilm Conni auf dem Bauernhof / Conni und das neue Baby Conni auf dem Reiterhof Conni backt Pizza / Conni lernt Rad fahren Conni bekommt eine Katze / Conni hat Geburtstag Conni bekommt Taschengeld / Conni verkleidet sich Conni feiert Geburtstag Conni feiert Weihnachten / Conni fährt Ski Conni geht auf Klassenfahrt Conni geht einkaufen / Conni und der Läusealarm Conni geht verloren / Conni in den Bergen Conni geht zelten / Conni lernt reiten Conni geht zum Film Conni geht zur Zahnärztin / Conni ist wütend Conni hilft Papa / Conni streitet sich mit Julia Conni im Krankenhaus / Conni tanzt Conni in der großen Stadt Conni ist krank / Conni beim Frisör Conni kommt in den Kindergarten (neu) / Conni geht aufs Töpfchen Conni kommt in den Kindergarten / Conni macht das Seepferdchen Conni kommt in die Schule (neu) / Conni backt Pfannkuchen Conni kommt in die Schule / Conni geht zum Arzt Conni lernt backen / Conni hilft Mama Conni löst einen kniffligen Fall Conni macht einen Ausflug / Conni geht auf Reisen Conni reist ans Mittelmeer Conni rettet die Tiere Conni rettet Oma Conni schläft im Kindergarten / Conni geht in den Zoo Conni und das Familienfest Conni und das ganz spezielle Weihnachtsfest Conni und das Geheimnis der Koi Conni und das große Bergabenteuer Conni und das Hochzeitsfest Conni und das Kinderfest / Conni im Zirkus Conni und das Klassencamp Conni und das neue Fohlen Conni und das Ponyabenteuer Conni und das tanzende Pony Conni und der Dinoknochen Conni und der Ferienzirkus Conni und der große Schnee Conni und der Liebesbrief Conni und der Osterhase / Conni spielt Fußball Conni und der verschwundene Hund Conni und die Burg der Vampire Conni und die Detektive Conni und die große Eiszeit Conni und die Jungs von nebenan Conni und die Katzenliebe Conni und die Nixen Conni und die verflixte 13 Conni und die wilden Tiere Conni und ihr Lieblingspony / Conni läuft Laterne Conni zieht um / Conni macht Musik Conni übernachtet bei Julia / Conni geht nicht mit Fremden mit Connis erster Flug / Conni geht zum Zahnarzt 60 ``` </details>
Author
Owner

@flotux2 commented on GitHub (Feb 5, 2019):

Hi ritiek,

thanks a lot for sharing your code. With this code I get all the albums like you got. So obviously there was an error in my code.

Kind regards
Florian

<!-- gh-comment-id:460745874 --> @flotux2 commented on GitHub (Feb 5, 2019): Hi ritiek, thanks a lot for sharing your code. With this code I get all the albums like you got. So obviously there was an error in my code. Kind regards Florian
Author
Owner

@stephanebruckert commented on GitHub (Jan 1, 2020):

Thanks @ritiek

<!-- gh-comment-id:570077917 --> @stephanebruckert commented on GitHub (Jan 1, 2020): Thanks @ritiek
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#202
No description provided.