Spotify API related operations
Spotipy client endpoints.
add_to_queue(track)
Add a track to the user's queue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
TrackData
|
Track to add |
required |
add_tracks_to_playlist(playlist_id, track_ids)
Add tracks to a user playlist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
playlist_id
|
str
|
URI of the target playlist |
required |
track_ids
|
list[str]
|
IDs for the tracks. |
required |
Source code in chopin/client/endpoints.py
create_user_playlist(user_id, name, description='Playlist created with Chopin')
Create a playlist in the user library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_id
|
str
|
ID of the user for which to add a playlist |
required |
name
|
str
|
Name for the playlist |
required |
description
|
str
|
Optional description for the playlist |
'Playlist created with Chopin'
|
Returns:
| Type | Description |
|---|---|
PlaylistData
|
Created playlist data. |
Source code in chopin/client/endpoints.py
get_album_tracks(album_id)
Get album tracks for the given album.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
album_id
|
str
|
The id of the album. |
required |
Returns:
| Type | Description |
|---|---|
list[TrackData]
|
A list of tracks from said album. |
Source code in chopin/client/endpoints.py
get_artist_top_tracks(artist, max_tracks=20)
Get an artist top tracks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist
|
ArtistData
|
current artist. |
required |
max_tracks
|
int
|
maximum number of tracks to find. |
20
|
Returns:
| Type | Description |
|---|---|
list[TrackData]
|
A list of track data. |
Source code in chopin/client/endpoints.py
get_current_user()
cached
get_currently_playing()
Get the track being played.
Returns:
| Type | Description |
|---|---|
TrackData | None
|
The track data of the track; or nothing if the user doesn't have an active listening session. |
Source code in chopin/client/endpoints.py
get_likes()
Get user liked tracks.
Returns:
| Type | Description |
|---|---|
list[TrackData]
|
The liked tracks. |
Source code in chopin/client/endpoints.py
get_named_playlist(name)
Find a user playlist based on its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
A string identifying the playlist name |
required |
Returns:
| Type | Description |
|---|---|
PlaylistData
|
The playlist data |
Raises:
| Type | Description |
|---|---|
ValueError
|
the playlist |
Source code in chopin/client/endpoints.py
get_playlist_tracks(playlist_id, release_date_range=None)
Get tracks of a given playlist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
playlist_id
|
str
|
The uri of the playlist. |
required |
release_date_range
|
tuple[date, date] | None
|
A date range; tracks to retrieve must have been released in this range. |
None
|
Returns:
| Type | Description |
|---|---|
list[TrackData]
|
A list of track uuids. |
Source code in chopin/client/endpoints.py
get_queue()
Get the current user's listening queue.
Returns:
| Type | Description |
|---|---|
list[TrackData]
|
The list of track data in the user's queue. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the user doesn't have an active (ie: doesn't have a track playing) |
Note
API Call has to be custom made, waiting for its implementation in Spotipy.
Source code in chopin/client/endpoints.py
get_top_artists(time_range, limit)
Get top artists for the current user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_range
|
Literal['short_term', 'medium_term', 'long_term']
|
The time scope of top artists |
required |
limit
|
int
|
A maximum number of artists to fetch |
required |
Returns:
| Type | Description |
|---|---|
list[ArtistData]
|
The user top artists for the given scope. |
Source code in chopin/client/endpoints.py
get_top_tracks(time_range, limit)
Get top tracks for the current user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time_range
|
Literal['short_term', 'medium_term', 'long_term']
|
The scope of the 'top' tracks. |
required |
limit
|
int
|
A maximum number of tracks to fetch |
required |
!!! note Time range is as follow: - short_term: last month - medium_term: last 6 months - long_term: all time
Note
There is a Spotify limit for a user's top tracks.
If limit is above, it will be reduced to the accepted number.
Returns:
| Type | Description |
|---|---|
list[TrackData]
|
The user top tracks for the given time scope. |
Source code in chopin/client/endpoints.py
get_user_playlists()
cached
Retrieve the playlists of the current user.
Returns:
| Type | Description |
|---|---|
list[PlaylistData]
|
A list of playlist data. |
Source code in chopin/client/endpoints.py
like_tracks(track_uris)
Add tracks to the user' library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track_uris
|
list[str]
|
Tracks to save. |
required |
replace_tracks_in_playlist(playlist_id, track_ids)
Replace tracks in a given playlist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
playlist_id
|
str
|
URI of the target playlist. All of its tracks will be removed! |
required |
track_ids
|
list[str]
|
New tracks to add in the playlist. |
required |
Source code in chopin/client/endpoints.py
search_artist(artist_name)
Search an artist.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
artist_name
|
str
|
Name of the artist |
required |
Returns:
| Type | Description |
|---|---|
ArtistData | None
|
Artist data, if found. |