API Reference
tidalapi.session
- class tidalapi.session.Session(config=<tidalapi.session.Config object>)[source]
Object for interacting with the TIDAL api and
- access_token = None
The TIDAL access token, this is what you use with load_oauth_session
- expiry_time = None
A
datetime
object containing the date the access token will expire
- refresh_token = None
A refresh token for retrieving a new access token through refresh_token
- token_type = None
The type of access token, e.g. Bearer
- session_id = None
The id for a TIDAL session, you also need this to use load_oauth_session
- country_code = None
- convert_type(search, search_type='identifier', output='identifier', case=Case.pascal, suffix=True)[source]
- load_session(session_id, country_code=None, user_id=None)[source]
Establishes TIDAL login details using a previous session id. May return true if the session-id is invalid/expired, you should verify the login afterwards.
- Parameters:
session_id – The UUID of the session you want to use.
country_code – (Optional) Two-letter country code.
user_id – (Optional) The number identifier of the user.
- Returns:
False if we know the session_id is incorrect, otherwise True
- load_oauth_session(token_type, access_token, refresh_token=None, expiry_time=None)[source]
Login to TIDAL using details from a previous OAuth login, automatically refreshes expired access tokens if refresh_token is supplied as well.
- Parameters:
token_type – The type of token, e.g. Bearer
access_token – The access token received from an oauth login or refresh
refresh_token – (Optional) A refresh token that lets you get a new access token after it has expired
expiry_time – (Optional) The datetime the access token will expire
- Returns:
True if we believe the log in was successful, otherwise false.
- login(username, password)[source]
Logs in to the TIDAL api.
- Parameters:
username – The TIDAL username
password – The password to your TIDAL account
- Returns:
Returns true if we think the login was successful.
- login_oauth_simple(function=<built-in function print>)[source]
Login to TIDAL using a remote link. You can select what function you want to use to display the link
- Parameters:
function – The function you want to display the link with
- Raises:
TimeoutError: If the login takes too long
- login_oauth()[source]
Login to TIDAL with a remote link for limited input devices. The function will return everything you need to log in through a web browser, and will return an future that will run until login.
- Returns:
A
LinkLogin
object containing all the data needed to log in remotely, and aconcurrent.futures.Future
that will poll until the login is completed, or until the link expires.- Raises:
TimeoutError: If the login takes too long
- token_refresh(refresh_token)[source]
Retrieves a new access token using the specified parameters, updating the current access token
- Parameters:
refresh_token – The refresh token retrieved when using the OAuth login.
- Returns:
True if we believe the token was successfully refreshed, otherwise False
- search(query, models=None, limit=50, offset=0)[source]
Searches TIDAL with the specified query, you can also specify what models you want to search for. While you can set the offset, there aren’t more than 300 items available in a search.
- Parameters:
- Returns:
Returns a dictionary of the different models, with the dictionary values containing the search results. The dictionary also contains a ‘top_hit’ result for the most relevant result, limited to the specified types
- playlist(playlist_id=None)[source]
Function to create a playlist object with access to the session instance in a smoother way. Calls
tidalapi.Playlist(session=session, playlist_id=playlist_id)
internally- Parameters:
playlist_id – (Optional) The TIDAL id of the playlist. You may want access to the methods without an id.
- Returns:
Returns a
Playlist
object that has access to the session instance used.
- track(track_id=None, with_album=False)[source]
Function to create a Track object with access to the session instance in a smoother way. Calls
tidalapi.Track(session=session, track_id=track_id)
internally
- video(video_id=None)[source]
Function to create a Video object with access to the session instance in a smoother way. Calls
tidalapi.Video(session=session, video_id=video_id)
internally- Parameters:
video_id – (Optional) The TIDAL id of the Video. You may want access to the methods without an id.
- Returns:
Returns a
Video
object that has access to the session instance used.
- artist(artist_id=None)[source]
Function to create a Artist object with access to the session instance in a smoother way. Calls
tidalapi.Artist(session=session, artist_id=artist_id)
internally- Parameters:
artist_id – (Optional) The TIDAL id of the Artist. You may want access to the methods without an id.
- Returns:
Returns a
Artist
object that has access to the session instance used.
- album(album_id=None)[source]
Function to create a Album object with access to the session instance in a smoother way. Calls
tidalapi.Album(session=session, album_id=album_id)
internally- Parameters:
album_id – (Optional) The TIDAL id of the Album. You may want access to the methods without an id.
- Returns:
Returns a
Album
object that has access to the session instance used.
- mix(mix_id=None)[source]
Function to create a mix object with access to the session instance smoothly Calls
tidalapi.Mix(session=session, mix_id=mix_id)
internally- Parameters:
mix_id – (Optional) The TIDAL id of the Mix. You may want access to the mix methods without an id.
- Returns:
Returns a
Mix
object that has access to the session instance used.
- get_user(user_id=None)[source]
Function to create a User object with access to the session instance in a smoother way. Calls
tidalapi.User(session=session, user_id=user_id)
internally- Parameters:
user_id – (Optional) The TIDAL id of the User. You may want access to the methods without an id.
- Returns:
Returns a
User
object that has access to the session instance used.
- home()[source]
Retrieves the Home page, as seen on https://listen.tidal.com
- Returns:
A
Page
object with thePageCategory
list from the home page
- explore()[source]
Retrieves the Explore page, as seen on https://listen.tidal.com/view/pages/explore
- Returns:
A
Page
object with thePageCategory
list from the explore page
- videos()[source]
Retrieves the
Videos
page, as seen on https://listen.tidal.com/view/pages/videos- Returns:
A
Page
object with a<.PageCategory>
list from the videos page
- genres()[source]
Retrieves the global Genre page, as seen on https://listen.tidal.com/view/pages/genre_page
- Returns:
A
Page
object with thePageCategory
list from the genre page
- local_genres()[source]
Retrieves the local Genre page, as seen on https://listen.tidal.com/view/pages/genre_page_local
- moods()[source]
Retrieves the mood page, as seen on https://listen.tidal.com/view/pages/moods
- mixes()[source]
Retrieves the current users mixes, as seen on https://listen.tidal.com/view/pages/my_collection_my_mixes
- Returns:
A list of
Mix
- class tidalapi.session.Config(quality=Quality.high, video_quality=VideoQuality.high, item_limit=1000, alac=True)[source]
Configuration for TIDAL services.
The maximum item_limit is 10000, and some endpoints have a maximum of 100 items, which will be shown in the docs. In cases where the maximum is 100 items, you will have to use offsets to get more than 100 items. Note that changing the ALAC option requires you to log in again, and for you to create a new config object IMPORTANT: ALAC=false will mean that video streams turn into audio-only streams.
Additionally, num_videos will turn into num_tracks in playlists.
- class tidalapi.session.Quality(value)[source]
An enumeration.
- lossless = 'LOSSLESS'
- high = 'HIGH'
- low = 'LOW'
- master = 'HI_RES'
- class tidalapi.session.VideoQuality(value)[source]
An enumeration.
- high = 'HIGH'
- medium = 'MEDIUM'
- low = 'LOW'
- class tidalapi.session.LinkLogin(json)[source]
The data required for logging in to TIDAL using a remote link, json is the data returned from TIDAL
- expires_in = None
Amount of seconds until the code expires
- user_code = None
The code the user should enter at the uri
- verification_uri = None
The link the user has to visit
- verification_uri_complete = None
The link the user has to visit, with the code already included
tidalapi.artist
A module containing information and functions related to TIDAL artists.
- class tidalapi.artist.Artist(session, artist_id)[source]
- name = None
- roles = None
- role = None
- picture = None
- user_date_added = None
- id = None
- parse_artists(json_obj)[source]
Parses a TIDAL artist, replaces the current artist object. Made for use inside of the python tidalapi module.
- Parameters:
json_obj – Json data returned from api.tidal.com containing an artist
- Returns:
Returns a copy of the original :exc:’Artist’: object
- get_albums(limit=None, offset=0)[source]
Queries TIDAL for the artists albums.
- Returns:
A list of
Albums
- get_albums_ep_singles(limit=None, offset=0)[source]
Queries TIDAL for the artists extended plays and singles.
- Returns:
A list of
Albums
- get_albums_other(limit=None, offset=0)[source]
Queries TIDAL for albums the artist has appeared on as a featured artist.
- Returns:
A list of
Albums
- get_top_tracks(limit=None, offset=0)[source]
Queries TIDAL for the artists tracks, sorted by popularity.
- Returns:
A list of
Tracks
- get_videos(limit=None, offset=0)[source]
Queries tidal for the artists videos.
- Returns:
A list of
Videos
- get_bio()[source]
Queries TIDAL for the artists biography
- Returns:
A string containing the bio, as well as identifiers to other TIDAL objects inside the bio.
- get_radio()[source]
Queries TIDAL for the artist radio, which is a mix of tracks that are similar to what the artist makes.
- Returns:
A list of
Tracks
- image(dimensions)[source]
A url to an artist picture
- Parameters:
dimensions (int) – The width and height that you want from the image
- Returns:
A url to the image.
Valid resolutions: 160x160, 320x320, 480x480, 750x750
- page()[source]
Retrieve the artist page as seen on https://listen.tidal.com/artist/$id
- Returns:
A
Page
containing all the categories from the page, e.g. tracks, influencers and credits
tidalapi.user
A module containing classes and functions related to tidal users.
User
is a class with user information.
Favorites
is class with a users favorites.
- class tidalapi.user.User(session, user_id)[source]
A class containing various information about a TIDAL user.
The attributes of this class are pretty varied. ID is the only attribute you can rely on being set. If you initialized a specific user, you will get id, first_name, last_name, and picture_id. If parsed as a playlist creator, you will get an ID and a name, if the creator isn’t an artist, name will be ‘user’. If the parsed user is the one logged in, for example in session.user, you will get the remaining attributes, and id.
- id = -1
- class tidalapi.user.FetchedUser(session, user_id)[source]
Bases:
User
- first_name = None
- last_name = None
- picture_id = None
- class tidalapi.user.LoggedInUser(session, user_id)[source]
Bases:
FetchedUser
- username = None
- email = None
- created = None
- newsletter = None
- accepted_eula = None
- gender = None
- date_of_birth = None
- facebook_uid = None
- apple_uid = None
- playlists()[source]
Get the playlists created by the user.
- Returns:
Returns a list of
Playlist
objects containing the playlists.
- class tidalapi.user.Favorites(session, user_id)[source]
An object containing a users favourites. This is the “music library” of the user labled “my collection” by Tidal
- add_album(album_id)[source]
Adds an album to the users favorites.
- Parameters:
album_id – TIDAL’s identifier of the album.
- Returns:
A boolean indicating whether the request was successful or not.
- add_artist(artist_id)[source]
Adds an artist to the users favorites.
- Parameters:
artist_id – TIDAL’s identifier of the artist
- Returns:
A boolean indicating whether the request was successful or not.
- add_playlist(playlist_id)[source]
Adds a playlist to the users favorites.
- Parameters:
playlist_id – TIDAL’s identifier of the playlist.
- Returns:
A boolean indicating whether the request was successful or not.
- add_track(track_id)[source]
Adds a track to the users favorites.
- Parameters:
track_id – TIDAL’s identifier of the track.
- Returns:
A boolean indicating whether the request was successful or not.
- add_video(video_id)[source]
Adds a video to the users favorites.
- Parameters:
video_id – TIDAL’s identifier of the video.
- Returns:
A boolean indicating whether the request was successful or not.
- remove_artist(artist_id)[source]
Removes a track from the users favorites.
- Parameters:
artist_id – TIDAL’s identifier of the artist.
- Returns:
A boolean indicating whether the request was successful or not.
- remove_album(album_id)[source]
Removes an album from the users favorites.
- Parameters:
album_id – TIDAL’s identifier of the album
- Returns:
A boolean indicating whether the request was successful or not.
- remove_playlist(playlist_id)[source]
Removes a playlist from the users favorites.
- Parameters:
playlist_id – TIDAL’s identifier of the playlist.
- Returns:
A boolean indicating whether the request was successful or not.
- remove_track(track_id)[source]
Removes a track from the users favorites.
- Parameters:
track_id – TIDAL’s identifier of the track.
- Returns:
A boolean indicating whether the request was successful or not.
- remove_video(video_id)[source]
Removes a video from the users favorites.
- Parameters:
video_id – TIDAL’s identifier of the video.
- Returns:
A boolean indicating whether the request was successful or not.
tidalapi.playlist
A module containing things related to TIDAL playlists.
- class tidalapi.playlist.Playlist(session, playlist_id)[source]
An object containing various data about a playlist and methods to work with them.
- name = None
- num_tracks = -1
- num_videos = -1
- creator = None
- description = None
- duration = -1
- last_updated = None
- created = None
- type = None
- public = False
- popularity = -1
- promoted_artists = None
- last_item_added_at = None
- picture = None
- square_picture = None
- user_date_added = None
- id = None
- parse(json_obj)[source]
Parses a playlist from tidal, replaces the current playlist object.
- Parameters:
json_obj – Json data returned from api.tidal.com containing a playlist
- Returns:
Returns a copy of the original :exc:’Playlist’: object
- tracks(limit=None, offset=0)[source]
Gets the playlists̈́’ tracks from TIDAL.
- Parameters:
limit – The amount of items you want returned.
offset – The index of the first item you want included.
- Returns:
A list of
Tracks
tidalapi.album
- class tidalapi.album.Album(session, album_id)[source]
Contains information about a TIDAL album.
If the album is created from a media object, this object will only contain the id, name, cover and video cover. TIDAL does this to reduce the network load.
- name = None
- cover = None
- video_cover = None
- duration = -1
- available = False
- num_tracks = -1
- num_videos = -1
- num_volumes = -1
- tidal_release_date = None
- release_date = None
- copyright = None
- version = None
- explicit = True
- universal_product_number = -1
- popularity = -1
- user_date_added = None
- artists = None
- artist = None
- id = None
- property year
Convenience function to get the year using
available_release_date
- Returns:
An
int
containing the year the track was released
- property available_release_date
Get the release date if it’s available, otherwise get the day it was released on TIDAL
- Returns:
A
datetime.datetime
object with the release date, or the tidal release date, can be None
- tracks(limit=None, offset=0)[source]
Returns the tracks in classes album.
- Parameters:
limit – The amount of items you want returned.
offset – The position of the first item you want to include.
- Returns:
A list of the
Tracks
in the album.
- image(dimensions, default='https://tidal.com/browse/assets/images/defaultImages/defaultAlbumImage.png')[source]
A url to an album image cover
- Parameters:
dimensions (int) – The width and height that you want from the image
- Returns:
A url to the image.
Valid resolutions: 80x80, 160x160, 320x320, 640x640, 1280x1280
- video(dimensions)[source]
Creates a url to an mp4 video cover for the album.
Valid resolutions: 80x80, 160x160, 320x320, 640x640, 1280x1280
- Parameters:
dimensions (int) – The width an height of the video
- Returns:
A url to an mp4 of the video cover.
- page()[source]
Retrieve the album page as seen on https://listen.tidal.com/album/$id
- Returns:
A
Page
containing the different categories, e.g. similar artists and albums
- review() str [source]
Retrieve the album review
- Returns:
A
str
containing the album review, with wimp links- Raises:
requests.HTTPError
if there isn’t a review yet
tidalapi.media
A module containing information about various media types.
- class tidalapi.media.Media(session, media_id=None)[source]
Base class for generic media, specifically
Track
andVideo
This class includes data used by both of the subclasses, and a function to parse both of them.
The date_added attribute is only relevant for playlists. For the release date of the actual media, use the release date of the album.
- name = None
- duration = -1
- available = True
- tidal_release_date = None
- user_date_added = None
- track_num = -1
- volume_num = 1
- explicit = False
- popularity = -1
- artist = None
- artist_roles = None
For the artist credit page
- artists = None
- type = None
- album = None
- id = None
- class tidalapi.media.Track(session, media_id=None)[source]
Bases:
Media
An object containing information about a track.
- replay_gain = None
- peak = None
- isrc = None
- audio_quality = None
- version = None
- copyright = None
- lyrics()[source]
Retrieves the lyrics for a song
- Returns:
A
Lyrics
object containing the lyrics- Raises:
A
requests.HTTPError
if there aren’t any lyrics
tidalapi.genre
tidalapi.page
Module for parsing TIDAL’s pages format found at https://listen.tidal.com/v1/pages
- class tidalapi.page.Page(session, title)[source]
A page from the https://listen.tidal.com/view/pages/ endpoint
The
categories
field will the most complete information However it is an iterable that goes through all the visible items on the page as well, in the natural reading order- categories = None
- title = ''
- class tidalapi.page.PageCategory(session)[source]
- type = None
- title = None
- description = ''
- requests = None
- session = None
- show_more()[source]
Get the full list of items on their own
Page
from aPageCategory
- Returns:
A
Page
more of the items in the category, None if there aren’t any
- class tidalapi.page.FeaturedItems(session)[source]
Bases:
PageCategory
Items that have been featured by TIDAL
- items = None
- class tidalapi.page.PageLinks(session)[source]
Bases:
PageCategory
A list of
PageLink
to other parts of TIDAL- items = None
- class tidalapi.page.ItemList(session)[source]
Bases:
PageCategory
A list of items from TIDAL, can be a list of mixes, for example, or a list of playlists and mixes in some cases
- items = None
tidalapi.mix
A module containing functions relating to TIDAL mixes.
- class tidalapi.mix.MixType(value)[source]
An enum to track all the different types of mixes
- video_daily = 'VIDEO_DAILY_MIX'
- daily = 'DAILY_MIX'
- discovery = 'DISCOVERY_MIX'
- new_release = 'NEW_RELEASE_MIX'
- track = 'TRACK_MIX'
- artist = 'ARTIST_MIX'
- songwriter = 'SONGWRITER_MIX'
- producter = 'PRODUCER_MIX'
- history_alltime = 'HISTORY_ALLTIME_MIX'
- history_monthly = 'HISTORY_MONTHLY_MIX'
- history_yearly = 'HISTORY_YEARLY_MIX'
- class tidalapi.mix.Mix(session, mix_id)[source]
A mix from TIDAL, e.g. the listen.tidal.com/view/pages/my_collection_my_mixes
These get used for many things, like artist/track radio’s, recommendations, and historical plays
- id = ''
- title = ''
- sub_title = ''
- sharing_images = None
- mix_type = None
- content_behaviour = ''
- short_subtitle = ''
- get(mix_id=None)[source]
Returns information about a mix, and also replaces the mix object used to call this function.
- Parameters:
mix_id – TIDAL’s identifier of the mix
- Returns:
A
Mix
object containing all the information about the mix