PrivateAPI#

class minim.qobuz.PrivateAPI(*, app_id: str = None, app_secret: str = None, flow: str = None, browser: bool = False, user_agent: str = None, email: str = None, password: str = None, auth_token: str = None, overwrite: bool = False, save: bool = True)[source]#

Bases: object

Private Qobuz API client.

The private TIDAL API allows songs, collections (albums, playlists), and performers to be queried, and information about them to be retrieved. As there is no available official documentation for the private Qobuz API, its endpoints have been determined by watching HTTP network traffic.

Attention

As the private Qobuz API is not designed to be publicly accessible, this class can be disabled or removed at any time to ensure compliance with the Qobuz API Terms of Use.

While authentication is not necessary to search for and retrieve data from public content, it is required to access personal content and stream media (with an active Qobuz subscription). In the latter case, requests to the private Qobuz API endpoints must be accompanied by a valid user authentication token in the header.

Minim can obtain user authentication tokens via the password grant, but it is an inherently unsafe method of authentication since it has no mechanisms for multifactor authentication or brute force attack detection. As such, it is highly encouraged that you obtain a user authentication token yourself through the Qobuz Web Player or the Android, iOS, macOS, and Windows applications, and then provide it and its accompanying app ID and secret to this class’s constructor as keyword arguments. The app credentials can also be stored as QOBUZ_PRIVATE_APP_ID and QOBUZ_PRIVATE_APP_SECRET in the operating system’s environment variables, and they will automatically be retrieved.

Tip

The app credentials and user authentication token can be changed or updated at any time using set_flow() and set_auth_token(), respectively.

Minim also stores and manages user authentication tokens and their properties. When the password grant is used to acquire a user authentication token, it is automatically saved to the Minim configuration file to be loaded on the next instantiation of this class. This behavior can be disabled if there are any security concerns, like if the computer being used is a shared device.

Parameters:
app_idstr, keyword-only, optional

App ID. Required if an user authentication token is provided in auth_token.

app_secretstr, keyword-only, optional

App secret. Required if an user authentication token is provided in auth_token.

flowstr, keyword-only, optional

Authorization flow.

Valid values:

  • "password" for the password flow.

  • None for no authentication.

browserbool, keyword-only, default: False

Determines whether a web browser is opened with the Qobuz login page using the Playwright framework by Microsoft to complete the password flow. If False, the account email and password must be provided in email and password, respectively.

user_agentstr, keyword-only, optional

User agent information to send in the header of HTTP requests.

emailstr, keyword-only, optional

Account email address. Required if an user authentication token is not provided in auth_token and browser=False.

passwordstr, keyword-only, optional

Account password. Required if an user authentication token is not provided in auth_token and browser=False.

auth_tokenstr, keyword-only, optional

User authentication token. If provided here or found in the Minim configuration file, the authentication process is bypassed.

overwritebool, keyword-only, default: False

Determines whether to overwrite an existing user authentication token in the Minim configuration file.

savebool, keyword-only, default: True

Determines whether newly obtained user authentication tokens and their associated properties are stored to the Minim configuration file.

Attributes:
API_URLstr

URL for the Qobuz API.

WEB_URLstr

URL for the Qobuz Web Player.

Methods

add_playlist_tracks

Add tracks to a user playlist.

create_playlist

Create a user playlist.

delete_playlist

Delete a user playlist.

delete_playlist_tracks

Delete tracks from a user playlist.

favorite_items

Favorite albums, artists, and/or tracks.

favorite_playlist

Subscribe to a playlist.

get_album

Get Qobuz catalog information for a single album.

get_artist

Get Qobuz catalog information for a single artist.

get_collection_streams

Get audio stream data for all tracks in an album or a playlist.

get_curated_tracks

Get weekly curated tracks for the user.

get_favorites

Get the current user's favorite albums, artists, and tracks.

get_featured_albums

Get Qobuz catalog information for featured albums.

get_featured_playlists

Get Qobuz catalog information for featured playlists.

get_label

Get Qobuz catalog information for a record label.

get_playlist

Get Qobuz catalog information for a playlist.

get_profile

Get the current user's profile information.

get_purchases

Get the current user's purchases.

get_track

Get Qobuz catalog information for a track.

get_track_file_url

Get the file URL for a track.

get_track_performers

Get credits for a track.

get_track_stream

Get the audio stream data for a track.

get_user_playlists

Get the current user's custom and favorite playlists.

move_playlist_tracks

Move tracks in a user playlist.

search

Search Qobuz for media and performers.

set_auth_token

Set the private Qobuz API user authentication token.

set_flow

Set the authorization flow.

unfavorite_items

Unfavorite albums, artists, and/or tracks.

unfavorite_playlist

Unsubscribe from a playlist.

update_playlist

Update the title, description, and/or privacy of a playlist owned by the current user.

update_playlist_position

Organize a user's playlists.

add_playlist_tracks(playlist_id: int | str, track_ids: int | str | list[int | str], *, duplicate: bool = False) dict[str, Any][source]#

Add tracks to a user playlist.

User authentication

Requires user authentication via the password flow.

Parameters:
playlist_idint or str

Qobuz user playlist ID.

Example: 17737508.

track_idsint, str, or list

Qobuz track ID(s).

Examples: "24393122,24393138" or [24393122, 24393138].

duplicatebool, keyword-only, default: False

Determines whether duplicate tracks should be added to the playlist.

Returns:
playliststr

Qobuz catalog information for the updated playlist.

create_playlist(name: str, *, description: str = None, public: bool = True, collaborative: bool = False) dict[str, Any][source]#

Create a user playlist.

User authentication

Requires user authentication via the password flow.

Parameters:
namestr

Qobuz playlist name.

descriptionstr, keyword-only, optional

Brief playlist description.

publicbool, keyword-only, default: True

Determines whether the playlist is public (True) or private (False).

collaborativebool, keyword-only, default: False

Determines whether the playlist is collaborative.

Returns:
playliststr

Qobuz catalog information for the newly created playlist.

delete_playlist(playlist_id: int | str) None[source]#

Delete a user playlist.

User authentication

Requires user authentication via the password flow.

Parameters:
playlist_idint or str

Qobuz user playlist ID.

Example: 17737508.

delete_playlist_tracks(playlist_id: int | str, playlist_track_ids: int | str | list[int | str]) dict[str, Any][source]#

Delete tracks from a user playlist.

User authentication

Requires user authentication via the password flow.

Parameters:
playlist_idint or str

Qobuz user playlist ID.

Example: 17737508.

playlist_track_idsint, str, or list

Qobuz playlist track ID(s).

Note

Playlist track IDs are not the same as track IDs. To get playlist track IDs, use get_playlist().

Returns:
playliststr

Qobuz catalog information for the updated playlist.

favorite_items(*, album_ids: str | list[str] = None, artist_ids: int | str | list[int | str] = None, track_ids: int | str | list[int | str] = None) None[source]#

Favorite albums, artists, and/or tracks.

User authentication

Requires user authentication via the password flow.

See also

For playlists, use favorite_playlist().

Parameters:
album_idsstr or list, keyword-only, optional

Qobuz album ID(s).

artist_idsint, str, or list, keyword-only, optional

Qobuz artist ID(s).

track_idsint, str, or list, keyword-only, optional

Qobuz track ID(s).

favorite_playlist(playlist_id: int | str) None[source]#

Subscribe to a playlist.

User authentication

Requires user authentication via the password flow.

Parameters:
playlist_idint or str

Qobuz playlist ID.

Example: 15732665.

get_album(album_id: str) dict[str, Any][source]#

Get Qobuz catalog information for a single album.

Parameters:
album_idstr

Qobuz album ID.

Example: "0060254735180".

Returns:
albumdict

Qobuz catalog information for a single album.

get_artist(artist_id: int | str, *, extras: str | list[str] = None, limit: int = None, offset: int = None) dict[str, Any][source]#

Get Qobuz catalog information for a single artist.

Parameters:
artist_idint or str

Qobuz artist ID.

extrasstr or list, keyword-only, optional

Specifies extra information about the artist to return.

Valid values: "albums", "tracks", "playlists", "tracks_appears_on", and "albums_with_last_release".

limitint, keyword-only, optional

The maximum number of extra items to return. Has no effect if extras=None.

Default: 25.

offsetint, keyword-only, optional

The index of the first extra item to return. Use with limit to get the next page of extra items. Has no effect if extras=None.

Default: 0.

Returns:
artistdict

Qobuz catalog information for a single artist.

get_collection_streams(id: int | str, type: str, *, format_id: int | str = 27) list[tuple[bytes, str]][source]#

Get audio stream data for all tracks in an album or a playlist.

Subscription

Full track playback information and lossless and Hi-Res audio is only available with an active Qobuz subscription.

Note

This method is provided for convenience and is not a private Qobuz API endpoint.

Parameters:
idint or str

Qobuz collection ID.

typestr

Collection type.

Valid values: "album" and "playlist".

format_idint, default: 27

Audio format ID that determines the maximum audio quality.

Valid values:

  • 5 for constant bitrate (320 kbps) MP3.

  • 6 for CD-quality (16-bit, 44.1 kHz) FLAC.

  • 7 for up to 24-bit, 96 kHz Hi-Res FLAC.

  • 27 for up to 24-bit, 192 kHz Hi-Res FLAC.

Returns:
streamslist

Audio stream data.

get_curated_tracks() list[dict[str, Any]][source]#

Get weekly curated tracks for the user.

User authentication

Requires user authentication via the password flow.

Parameters:
limitint, keyword-only, optional

The maximum number of tracks to return.

Default: 50.

offsetint, keyword-only, optional

The index of the first track to return. Use with limit to get the next page of tracks.

Default: 0.

Returns:
trackslist

Qobuz catalog information for the curated tracks.

get_favorites(type: str = None, *, limit: int = None, offset: int = None) dict[str, dict][source]#

Get the current user’s favorite albums, artists, and tracks.

User authentication

Requires user authentication via the password flow.

Parameters:
typestr

Media type to return. If not specified, all of the user’s favorite items are returned.

Valid values: "albums", "artists", and "tracks".

limitint, keyword-only, optional

The maximum number of favorited items to return.

Default: 50.

offsetint, keyword-only, optional

The index of the first favorited item to return. Use with limit to get the next page of favorited items.

Default: 0.

Returns:
favoritesdict

A dictionary containing Qobuz catalog information for the current user’s favorite items and the user’s ID and email.

Get Qobuz catalog information for featured albums.

Parameters:
typestr, default: "new-releases"

Feature type.

Valid values: "best-sellers", "editor-picks", "ideal-discography", "most-featured", "most-streamed", "new-releases", "new-releases-full", "press-awards", "recent-releases", "qobuzissims", "harmonia-mundi", "universal-classic", "universal-jazz", "universal-jeunesse", and "universal-chanson".

limitint, keyword-only, optional

The maximum number of albums to return.

Default: 50.

offsetint, keyword-only, optional

The index of the first album to return. Use with limit to get the next page of albums.

Default: 0.

Returns:
albumsdict

Qobuz catalog information for the albums.

Get Qobuz catalog information for featured playlists.

Parameters:
typestr, default: "editor-picks"

Feature type.

Valid values: "editor-picks" and "last-created".

limitint, keyword-only, optional

The maximum number of playlists to return.

Default: 50.

offsetint, keyword-only, optional

The index of the first playlist to return. Use with limit to get the next page of playlists.

Default: 0.

Returns:
playlistsdict

Qobuz catalog information for the playlists.

get_label(label_id: int | str, *, albums: bool = False, limit: int = None, offset: int = None) dict[str, Any][source]#

Get Qobuz catalog information for a record label.

Parameters:
label_idint or str

Qobuz record label ID.

Example: 1153.

albumsbool, keyword-only, default: False

Specifies whether information on the albums released by the record label is returned.

limitint, keyword-only, optional

The maximum number of albums to return. Has no effect if albums=False.

Default: 25.

offsetint, keyword-only, optional

The index of the first album to return. Use with limit to get the next page of albums. Has no effect if albums=False.

Default: 0.

Returns:
labeldict

Qobuz catalog information for the record label.

get_playlist(playlist_id: int | str, *, tracks: bool = True, limit: int = None, offset: int = None) dict[str, Any][source]#

Get Qobuz catalog information for a playlist.

Parameters:
playlist_idint or str

Qobuz playlist ID.

Example: 15732665.

tracksbool, keyword-only, default: True

Specifies whether information on the tracks in the playlist is returned.

limitint, keyword-only, optional

The maximum number of tracks to return. Has no effect if tracks=False.

Default: 50.

offsetint, keyword-only, optional

The index of the first track to return. Use with limit to get the next page of tracks. Has no effect if tracks=False.

Default: 0.

Returns:
playlistdict

Qobuz catalog information for the playlist.

get_profile() dict[str, Any][source]#

Get the current user’s profile information.

User authentication

Requires user authentication via the password flow.

Returns:
profiledict

A dictionary containing the current user’s profile information.

get_purchases(type: str = 'albums', *, limit: int = None, offset: int = None) dict[str, Any][source]#

Get the current user’s purchases.

User authentication

Requires user authentication via the password flow.

Parameters:
typestr, default: "albums"

Media type.

Valid values: "albums" and "tracks".

limitint, keyword-only, optional

The maximum number of albums or tracks to return.

Default: 50.

offsetint, keyword-only, optional

The index of the first album or track to return. Use with limit to get the next page of albums or tracks.

Default: 0.

Returns:
purchasesdict

A dictionary containing Qobuz catalog information for the current user’s purchases.

get_track(track_id: int | str) dict[str, Any][source]#

Get Qobuz catalog information for a track.

Parameters:
track_idint or str

Qobuz track ID.

Example: 24393138.

Returns:
trackdict

Qobuz catalog information for the track.

get_track_file_url(track_id: int | str, format_id: int | str = 27) dict[str, Any][source]#

Get the file URL for a track.

Subscription

Full track playback information and lossless and Hi-Res audio is only available with an active Qobuz subscription.

Parameters:
track_idint or str

Qobuz track ID.

Example: 24393138.

format_idint or str, default: 27

Audio format ID that determines the maximum audio quality.

Valid values:

  • 5 for constant bitrate (320 kbps) MP3.

  • 6 for CD-quality (16-bit, 44.1 kHz) FLAC.

  • 7 for up to 24-bit, 96 kHz Hi-Res FLAC.

  • 27 for up to 24-bit, 192 kHz Hi-Res FLAC.

Returns:
urldict

A dictionary containing the URL and track information, such as the audio format, bit depth, etc.

get_track_performers(track_id: int | str = None, *, performers: str = None, roles: list[str] | set[str] = None) dict[str, list][source]#

Get credits for a track.

Note

This method is provided for convenience and is not a private Qobuz API endpoint.

Parameters:
track_idint or str, optional

Qobuz track ID. Required if performers is not provided.

Example: 24393138.

performersstr, keyword-only, optional

An unformatted string containing the track credits obtained from calling get_track().

roleslist or set, keyword-only, optional

Role filter. The special "Composers" filter will combine the "Composer", "ComposerLyricist", "Lyricist", and "Writer" roles.

Valid values: "MainArtist", "FeaturedArtist", "Producer", "Co-Producer", "Mixer", "Composers" ("Composer", "ComposerLyricist", "Lyricist", "Writer"), "MusicPublisher", etc.

Returns:
creditsdict

A dictionary containing the track contributors, with their roles (in snake case) being the keys.

get_track_stream(track_id: int | str, *, format_id: int | str = 27) tuple[bytes, str][source]#

Get the audio stream data for a track.

Subscription

Full track playback information and lossless and Hi-Res audio is only available with an active Qobuz subscription.

Note

This method is provided for convenience and is not a private Qobuz API endpoint.

Parameters:
track_idint or str

Qobuz track ID.

Example: 24393138.

format_idint, default: 27

Audio format ID that determines the maximum audio quality.

Valid values:

  • 5 for constant bitrate (320 kbps) MP3.

  • 6 for CD-quality (16-bit, 44.1 kHz) FLAC.

  • 7 for up to 24-bit, 96 kHz Hi-Res FLAC.

  • 27 for up to 24-bit, 192 kHz Hi-Res FLAC.

Returns:
streambytes

Audio stream data.

mime_typestr

Audio stream MIME type.

get_user_playlists(*, limit: int = None, offset: int = None) dict[str, Any][source]#

Get the current user’s custom and favorite playlists.

User authentication

Requires user authentication via the password flow.

Parameters:
limitint, keyword-only, optional

The maximum number of playlists to return.

Default: 500.

offsetint, keyword-only, optional

The index of the first playlist to return. Use with limit to get the next page of playlists.

Default: 0.

Returns:
playlistsdict

Qobuz catalog information for the current user’s custom and favorite playlists.

move_playlist_tracks(playlist_id: int | str, playlist_track_ids: int | str | list[int | str], insert_before: int) dict[str, Any][source]#

Move tracks in a user playlist.

User authentication

Requires user authentication via the password flow.

Parameters:
playlist_idint or str

Qobuz user playlist ID.

Example: 17737508.

playlist_track_idsint, str, or list

Qobuz playlist track ID(s).

Note

Playlist track IDs are not the same as track IDs. To get playlist track IDs, use get_playlist().

insert_beforeint

Position to which to move the tracks specified in track_ids.

Returns:
playliststr

Qobuz catalog information for the updated playlist.

search(query: str, type: str = None, *, hi_res: bool = False, new_release: bool = False, strict: bool = False, limit: int = 10, offset: int = 0) dict[str, Any][source]#

Search Qobuz for media and performers.

Parameters:
querystr

Search query.

typestr, keyword-only, optional

Category to search in. If specified, only matching releases and tracks will be returned.

Valid values: "MainArtist", "Composer", "Performer", "ReleaseName", and "Label".

hi_resbool, keyword-only, False

High-resolution audio only.

new_releasebool, keyword-only, False

New releases only.

strictbool, keyword-only, False

Enable exact word or phrase matching.

limitint, keyword-only, default: 10

Maximum number of results to return.

offsetint, keyword-only, default: 0

Index of the first result to return. Use with limit to get the next page of search results.

Returns:
resultsdict

Search results.

set_auth_token(auth_token: str = None, *, email: str = None, password: str = None) None[source]#

Set the private Qobuz API user authentication token.

Parameters:
auth_tokenstr, optional

User authentication token.

emailstr, keyword-only, optional

Account email address.

passwordstr, keyword-only, optional

Account password.

set_flow(flow: str, *, app_id: str = None, app_secret: str = None, auth_token: str = None, browser: bool = False, save: bool = True) None[source]#

Set the authorization flow.

Parameters:
flowstr, keyword-only, optional

Authorization flow.

Valid values:

  • "password" for the password flow.

  • None for no authentication.

app_idstr, keyword-only, optional

App ID. Required if an user authentication token is provided in auth_token.

app_secretstr, keyword-only, optional

App secret. Required if an user authentication token is provided in auth_token.

auth_tokenstr, keyword-only, optional

User authentication token.

browserbool, keyword-only, default: False

Determines whether a web browser is opened with the Qobuz login page using the Playwright framework by Microsoft to complete the password flow.

savebool, keyword-only, default: True

Determines whether to save the newly obtained access tokens and their associated properties to the Minim configuration file.

unfavorite_items(*, album_ids: str | list[str] = None, artist_ids: int | str | list[int | str] = None, track_ids: int | str | list[int | str] = None) None[source]#

Unfavorite albums, artists, and/or tracks.

User authentication

Requires user authentication via the password flow.

See also

For playlists, use unfavorite_playlist().

Parameters:
album_idsstr or list, keyword-only, optional

Qobuz album ID(s).

artist_idsint, str, or list, keyword-only, optional

Qobuz artist ID(s).

track_idsint, str, or list, keyword-only, optional

Qobuz track ID(s).

unfavorite_playlist(playlist_id: int | str) None[source]#

Unsubscribe from a playlist.

User authentication

Requires user authentication via the password flow.

Parameters:
playlist_idint or str

Qobuz playlist ID.

Example: 15732665.

update_playlist(playlist_id: int | str, *, name: str = None, description: str = None, public: bool = None, collaborative: bool = None) dict[str, Any][source]#

Update the title, description, and/or privacy of a playlist owned by the current user.

User authentication

Requires user authentication via the password flow.

Parameters:
playlist_idint or str

Qobuz user playlist ID.

Example: 17737508.

namestr, keyword-only, optional

Qobuz playlist name.

descriptionstr, keyword-only, optional

Brief playlist description.

publicbool, keyword-only, optional

Determines whether the playlist is public (True) or private (False).

collaborativebool, keyword-only, optional

Determines whether the playlist is collaborative.

Returns:
playliststr

Qobuz catalog information for the updated playlist.

update_playlist_position(from_playlist_id: int | str, to_playlist_id: int | str) None[source]#

Organize a user’s playlists.

User authentication

Requires user authentication via the password flow.

Parameters:
from_playlist_idint or str

Qobuz user playlist ID of playlist to move.

Example: 17737508.

to_playlist_idint or str

Qobuz user playlist ID of playlist to swap with that in from_playlist_id.

Example: 17737509.