You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we look at the 2nd example, from the library usage perspective, it can be confusing. The API are supposed to return the same resources, but in some cases they return a "shallow" version, with fewer fields and if the user tries to access the missing ones, they'll get an AttributeError.
In the case of the album's artist, there are 2 ways of getting it:
Album.artist field
Album.get_artist() method
The first one doesn't make any API call to Deezer, however it returns an incomplete object with only the following fields: id, name, picture, picture_small, picture_medium, picture_big, picture_xl. The artist returned is missing a few fields which are type annotated as always present:
browniebroke
changed the title
Confusing shallow fields & full methods
Missing attributes when getting related resources: get_artist, get_tracks, get_albums, get_episodes...
Jul 24, 2022
The Deezer API returns fewer fields when retrieving a resource as a relation than when the resource is returned directly. Exampels include:
If we look at the 2nd example, from the library usage perspective, it can be confusing. The API are supposed to return the same resources, but in some cases they return a "shallow" version, with fewer fields and if the user tries to access the missing ones, they'll get an
AttributeError
.In the case of the album's artist, there are 2 ways of getting it:
Album.artist
fieldAlbum.get_artist()
methodThe first one doesn't make any API call to Deezer, however it returns an incomplete object with only the following fields:
id
,name
,picture
,picture_small
,picture_medium
,picture_big
,picture_xl
. The artist returned is missing a few fields which are type annotated as always present:deezer-python/deezer/resources.py
Lines 180 to 183 in 93e473a
The second way, using the method, returns a full object, at the cost of an extra API call.
It's a problem for a couple of reasons:
The text was updated successfully, but these errors were encountered: