🎷 Spotify¢

Module: spotify.py

Provides methods to retrieve track and album metadata from search queries, IDs, URIs, or URLs.

class Spotify(CLIENT_ID: str, CLIENT_SECRET: str)ΒΆ

A class for interacting with the Spotify API to search and retrieve track and album metadata.

get_track(query: str, limit: int = 6) List[TrackMetadata]ΒΆ

Searches for tracks based on a query or Spotify ID/URI/URL and retrieves their metadata.

Parameters:
  • query (str) – The search query or Spotify ID/URI/URL for the track.

  • limit (int, optional) – Max number of tracks to retrieve (only applies to search by text). Defaults to 6.

Returns:

A list of track metadata.

Return type:

List[TrackMetadata]

Raises:
get_album(query: str, limit: int = 6, shuffle: bool = False) List[AlbumMetadata]ΒΆ

Searches for album based on a query or Spotify ID/URI/URL and retrieves their metadata.

Parameters:
  • query (str) – The search query or Spotify ID/URI/URL for the album.

  • limit (int, optional) – Max number of albums to retrieve (only applies to search by text). Defaults to 6.

  • shuffle (bool, optional) – Whether to shuffle the track list. Defaults to False.

Returns:

A list of album metadata with track listings.

Return type:

List[AlbumMetadata]

Raises: