Toplists

class spotify.Toplist(session, type=None, region=None, canonical_username=None, callback=None, sp_toplistbrowse=None, add_ref=True)[source]

A Spotify toplist of artists, albums or tracks that are currently most popular worldwide or in a specific region.

Call the get_toplist() method on your Session instance to get a Toplist back.

type = None

A ToplistType instance that specifies what kind of toplist this is: top artists, top albums, or top tracks.

Changing this field has no effect on existing toplists.

canonical_username = None

If region is ToplistRegion.USER, then this field specifies which user the toplist is for.

Changing this field has no effect on existing toplists.

loaded_event = None

threading.Event that is set when the toplist is loaded.

region = None

Either a ToplistRegion instance, or a 2-letter ISO 3166-1 country code, that specifies the geographical region this toplist is for.

Changing this field has no effect on existing toplists.

is_loaded

Whether the toplist’s data is loaded yet.

load(timeout=None)[source]

Block until the user’s data is loaded.

After timeout seconds with no results Timeout is raised. If timeout is None the default timeout is used.

The method returns self to allow for chaining of calls.

error

An ErrorType associated with the toplist.

Check to see if there was problems creating the toplist.

backend_request_duration

The time in ms that was spent waiting for the Spotify backend to create the toplist.

Returns -1 if the request was served from local cache. Returns None if the toplist isn’t loaded yet.

tracks

The tracks in the toplist.

Will always return an empty list if the toplist isn’t loaded.

albums

The albums in the toplist.

Will always return an empty list if the toplist isn’t loaded.

artists

The artists in the toplist.

Will always return an empty list if the toplist isn’t loaded.

class spotify.ToplistRegion[source]
EVERYWHERE = <ToplistRegion.EVERYWHERE: 0>
USER = <ToplistRegion.USER: 1>
class spotify.ToplistType[source]
ALBUMS = <ToplistType.ALBUMS: 1>
ARTISTS = <ToplistType.ARTISTS: 0>
TRACKS = <ToplistType.TRACKS: 2>