Spotify Extension#

The Spotify extension is a QoL extension that helps in searching for and queueing tracks from Spotify URL’s or ID’s. To get started create a SpotifyClient and pass in your credentials. You then pass this to your Node(s). An example:

import wavelink
from wavelink.ext import spotify

async def create_nodes(...):
    await wavelink.NodePool.create_node(...,
                                        spotify_client=spotify.SpotifyClient(client_id=..., client_secret=...))

Once your Node has a SpotifyClient attached, you can use await to search for an appropriate YouTube Track.


Searching for a singular track:

# If an ID is passed you must provide a spotify.SpotifySearchType
# In this case type=spotify.SpotifySearchType.track
# This is not needed with full URL's

track = await"SPOTIFY_TRACK_URL_OR_ID", return_first=True)

Searching for an album (Flattened to a list):

# If an ID is passed you must provide a spotify.SpotifySearchType
# In this case type=spotify.SpotifySearchType.album
# This is not needed with full URL's

tracks = await"SPOTIFY_ALBUM_URL_OR_ID")

Searching for an album (As an async iterator):

async for track in spotify.SpotifyTrack.iterator(query="SPOTIFY_ALBUM_URL_OR_ID", type=spotify.SpotifySearchType.album)

Searching for a playlist (With PartialTrack’s):

# Partial tracks makes queueing large playlists or albums super fast...
# Partial tracks only have limited information until they are played...

async for partial in spotify.SpotifyTrack.iterator(query="SPOTIFY_PLAYLIST_URL_OR_ID", partial_tracks=True):

Decoding a Spotify URL:

# Useful for determining the type of search and the ID...
# If the URL decoded is an unusable type e.g artist, spotify.SpotifySearchType.unusable will be returned...
# If the URL is not a valid Spotify URL, None is returned.

decoded = spotify.decode_url("SPOTIFY_URL")
if decoded is not None:
    print(decoded['type'], decoded['id'])


wavelink.ext.spotify.decode_url(url: str) Optional[dict]#

Check whether the given URL is a valid Spotify URL and return it’s type and ID.


url (str) – The URL to check.


An mapping of SpotifySearchType and Spotify ID. Type will be either track, album or playlist. If type is not track, album or playlist, a special unusable type is returned.

Could return None if the URL is invalid.

Return type



from wavelink.ext import spotify


decoded = spotify.decode_url("")

if decoded and decoded['type'] is spotify.SpotifySearchType.track:
    track = await["id"], type=decoded["type"])
class wavelink.ext.spotify.SpotifyClient(*, client_id: str, client_secret: str)#

Spotify client passed to Nodes for searching via Spotify.

  • client_id (str) – Your spotify application client ID.

  • client_secret (str) – Your spotify application secret.

class wavelink.ext.spotify.SpotifySearchType(value)#

An enum specifying which type to search for with a given Spotify ID.


Default search type. Unless specified otherwise this will always be the search type.


Search for an album.


Search for a playlist.

class wavelink.ext.spotify.SpotifyTrack(id: str, info: dict)#

A track retrieved via YouTube with a Spotify URL/ID.

classmethod coroutine convert(ctx: Context, argument: str) ST#

Converter which searches for and returns the first track.

Used as a type hint in a command.

classmethod iterator(*, query: str, limit: Optional[int] = None, type: SpotifySearchType = SpotifySearchType.playlist, node: Optional[Node] = MISSING, partial_tracks: bool = False)#

An async iterator version of search.

This can be useful when searching for large playlists or albums with Spotify.

  • query (str) – The Spotify URL or ID to search for. Must be of type Playlist or Album.

  • limit (Optional[int]) – Limit the amount of tracks returned.

  • type (SpotifySearchType) – The type of search. Must be either playlist or album. Defaults to playlist.

  • node (Optional[Node]) – An optional node to use when querying for tracks. Defaults to best available.

  • partial_tracks (Optional[bool]) – Whether or not to create wavelink.tracks.PartialTrack objects for search at playtime. This can make queuing large albums or playlists considerably faster, but with less information. Defaults to False.


async for track in spotify.SpotifyTrack.iterator(query=..., type=spotify.SpotifySearchType.playlist):
classmethod coroutine search(query: str, *, type: SpotifySearchType = SpotifySearchType.track, node: Node = MISSING, return_first: bool = False) Union[ST, None, List[ST]]#

This function is a coroutine.

Search for tracks with the given query.

  • query (str) – The song to search for.

  • type (Optional[spotify.SpotifySearchType]) – An optional enum value to use when searching with Spotify. Defaults to track.

  • node (Optional[wavelink.Node]) – An optional Node to use to make the search with.

  • return_first (Optional[bool]) – An optional bool which when set to True will return only the first track found. Defaults to False.


Return type

Union[Optional[Track], List[Track]]

exception wavelink.ext.spotify.SpotifyRequestError(status: int, reason: Optional[str] = None)#

Base error for Spotify requests.


The status code returned from the request.




The reason the request failed. Could be None.