Skip to content

Resources

Low-level namespaces — one per API object (client.track, client.album, …). Prefer High-level helpers for everyday use.

deezify.resources.album

Album resource — https://developers.deezer.com/api/album.

AlbumResource

Bases: Resource

Read an album and its connections; manage it in the user library.

Source code in deezify/resources/album.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class AlbumResource(Resource):
    """Read an album and its connections; manage it in the user library."""

    def get(self, album_id: int, **params: Any) -> Album:
        """Fetch one album by id (``GET /album/{id}``)."""
        return self._get(f"album/{album_id}", params=params or None)

    def fans(
        self, album_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[User]:
        """Fans of the album (``GET /album/{id}/fans``)."""
        return self._paginated(
            f"album/{album_id}/fans", params=self._page(None, index, limit)
        )

    def tracks(
        self, album_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[AlbumTrack]:
        """Tracks of the album (``GET /album/{id}/tracks``)."""
        return self._paginated(
            f"album/{album_id}/tracks", params=self._page(None, index, limit)
        )

    # -- library actions (need ``manage_library`` / ``delete_library``) ----
    def add_to_library(self, user_id: int | str, album_ids: list[int] | int) -> WriteResult:
        """Add album(s) to a user's library (``POST /user/{id}/albums``)."""
        ids = album_ids if isinstance(album_ids, list) else [album_ids]
        return bool(
            self._post(
                f"user/{user_id}/albums", data={"album_id": ",".join(map(str, ids))}
            )
        )

    def remove_from_library(self, user_id: int | str, album_id: int) -> WriteResult:
        """Remove an album from a user's library (``DELETE /user/{id}/albums``)."""
        return bool(
            self._delete(f"user/{user_id}/albums", params={"album_id": album_id})
        )

get(album_id, **params)

Fetch one album by id (GET /album/{id}).

Source code in deezify/resources/album.py
15
16
17
def get(self, album_id: int, **params: Any) -> Album:
    """Fetch one album by id (``GET /album/{id}``)."""
    return self._get(f"album/{album_id}", params=params or None)

fans(album_id, *, index=None, limit=None)

Fans of the album (GET /album/{id}/fans).

Source code in deezify/resources/album.py
19
20
21
22
23
24
25
def fans(
    self, album_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[User]:
    """Fans of the album (``GET /album/{id}/fans``)."""
    return self._paginated(
        f"album/{album_id}/fans", params=self._page(None, index, limit)
    )

tracks(album_id, *, index=None, limit=None)

Tracks of the album (GET /album/{id}/tracks).

Source code in deezify/resources/album.py
27
28
29
30
31
32
33
def tracks(
    self, album_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[AlbumTrack]:
    """Tracks of the album (``GET /album/{id}/tracks``)."""
    return self._paginated(
        f"album/{album_id}/tracks", params=self._page(None, index, limit)
    )

add_to_library(user_id, album_ids)

Add album(s) to a user's library (POST /user/{id}/albums).

Source code in deezify/resources/album.py
36
37
38
39
40
41
42
43
def add_to_library(self, user_id: int | str, album_ids: list[int] | int) -> WriteResult:
    """Add album(s) to a user's library (``POST /user/{id}/albums``)."""
    ids = album_ids if isinstance(album_ids, list) else [album_ids]
    return bool(
        self._post(
            f"user/{user_id}/albums", data={"album_id": ",".join(map(str, ids))}
        )
    )

remove_from_library(user_id, album_id)

Remove an album from a user's library (DELETE /user/{id}/albums).

Source code in deezify/resources/album.py
45
46
47
48
49
def remove_from_library(self, user_id: int | str, album_id: int) -> WriteResult:
    """Remove an album from a user's library (``DELETE /user/{id}/albums``)."""
    return bool(
        self._delete(f"user/{user_id}/albums", params={"album_id": album_id})
    )

deezify.resources.artist

Artist resource — https://developers.deezer.com/api/artist.

ArtistResource

Bases: Resource

Read an artist and every documented artist/* connection.

Source code in deezify/resources/artist.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class ArtistResource(Resource):
    """Read an artist and every documented ``artist/*`` connection."""

    def get(self, artist_id: int, **params: Any) -> Artist:
        """Fetch one artist by id (``GET /artist/{id}``)."""
        return self._get(f"artist/{artist_id}", params=params or None)

    def top(
        self, artist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Track]:
        """Top tracks of the artist (``GET /artist/{id}/top``)."""
        return self._paginated(
            f"artist/{artist_id}/top", params=self._page(None, index, limit)
        )

    def albums(
        self, artist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Album]:
        """Albums of the artist (``GET /artist/{id}/albums``)."""
        return self._paginated(
            f"artist/{artist_id}/albums", params=self._page(None, index, limit)
        )

    def fans(
        self, artist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[User]:
        """Fans of the artist (``GET /artist/{id}/fans``)."""
        return self._paginated(
            f"artist/{artist_id}/fans", params=self._page(None, index, limit)
        )

    def related(
        self, artist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Artist]:
        """Related artists (``GET /artist/{id}/related``)."""
        return self._paginated(
            f"artist/{artist_id}/related", params=self._page(None, index, limit)
        )

    def radio(
        self, artist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Track]:
        """Artist radio tracks (``GET /artist/{id}/radio``)."""
        return self._paginated(
            f"artist/{artist_id}/radio", params=self._page(None, index, limit)
        )

    def playlists(
        self, artist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Playlist]:
        """Playlists featuring the artist (``GET /artist/{id}/playlists``)."""
        return self._paginated(
            f"artist/{artist_id}/playlists", params=self._page(None, index, limit)
        )

    # -- favorites (need ``manage_library`` / ``delete_library``) -----------
    def add_favorite(self, user_id: int | str, artist_ids: list[int] | int) -> WriteResult:
        """Add artist(s) to favorites (``POST /user/{id}/artists``)."""
        ids = artist_ids if isinstance(artist_ids, list) else [artist_ids]
        return bool(
            self._post(
                f"user/{user_id}/artists", data={"artist_id": ",".join(map(str, ids))}
            )
        )

    def remove_favorite(self, user_id: int | str, artist_id: int) -> WriteResult:
        """Remove an artist from favorites (``DELETE /user/{id}/artists``)."""
        return bool(
            self._delete(f"user/{user_id}/artists", params={"artist_id": artist_id})
        )

get(artist_id, **params)

Fetch one artist by id (GET /artist/{id}).

Source code in deezify/resources/artist.py
15
16
17
def get(self, artist_id: int, **params: Any) -> Artist:
    """Fetch one artist by id (``GET /artist/{id}``)."""
    return self._get(f"artist/{artist_id}", params=params or None)

top(artist_id, *, index=None, limit=None)

Top tracks of the artist (GET /artist/{id}/top).

Source code in deezify/resources/artist.py
19
20
21
22
23
24
25
def top(
    self, artist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Track]:
    """Top tracks of the artist (``GET /artist/{id}/top``)."""
    return self._paginated(
        f"artist/{artist_id}/top", params=self._page(None, index, limit)
    )

albums(artist_id, *, index=None, limit=None)

Albums of the artist (GET /artist/{id}/albums).

Source code in deezify/resources/artist.py
27
28
29
30
31
32
33
def albums(
    self, artist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Album]:
    """Albums of the artist (``GET /artist/{id}/albums``)."""
    return self._paginated(
        f"artist/{artist_id}/albums", params=self._page(None, index, limit)
    )

fans(artist_id, *, index=None, limit=None)

Fans of the artist (GET /artist/{id}/fans).

Source code in deezify/resources/artist.py
35
36
37
38
39
40
41
def fans(
    self, artist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[User]:
    """Fans of the artist (``GET /artist/{id}/fans``)."""
    return self._paginated(
        f"artist/{artist_id}/fans", params=self._page(None, index, limit)
    )

related(artist_id, *, index=None, limit=None)

Related artists (GET /artist/{id}/related).

Source code in deezify/resources/artist.py
43
44
45
46
47
48
49
def related(
    self, artist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Artist]:
    """Related artists (``GET /artist/{id}/related``)."""
    return self._paginated(
        f"artist/{artist_id}/related", params=self._page(None, index, limit)
    )

radio(artist_id, *, index=None, limit=None)

Artist radio tracks (GET /artist/{id}/radio).

Source code in deezify/resources/artist.py
51
52
53
54
55
56
57
def radio(
    self, artist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Track]:
    """Artist radio tracks (``GET /artist/{id}/radio``)."""
    return self._paginated(
        f"artist/{artist_id}/radio", params=self._page(None, index, limit)
    )

playlists(artist_id, *, index=None, limit=None)

Playlists featuring the artist (GET /artist/{id}/playlists).

Source code in deezify/resources/artist.py
59
60
61
62
63
64
65
def playlists(
    self, artist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Playlist]:
    """Playlists featuring the artist (``GET /artist/{id}/playlists``)."""
    return self._paginated(
        f"artist/{artist_id}/playlists", params=self._page(None, index, limit)
    )

add_favorite(user_id, artist_ids)

Add artist(s) to favorites (POST /user/{id}/artists).

Source code in deezify/resources/artist.py
68
69
70
71
72
73
74
75
def add_favorite(self, user_id: int | str, artist_ids: list[int] | int) -> WriteResult:
    """Add artist(s) to favorites (``POST /user/{id}/artists``)."""
    ids = artist_ids if isinstance(artist_ids, list) else [artist_ids]
    return bool(
        self._post(
            f"user/{user_id}/artists", data={"artist_id": ",".join(map(str, ids))}
        )
    )

remove_favorite(user_id, artist_id)

Remove an artist from favorites (DELETE /user/{id}/artists).

Source code in deezify/resources/artist.py
77
78
79
80
81
def remove_favorite(self, user_id: int | str, artist_id: int) -> WriteResult:
    """Remove an artist from favorites (``DELETE /user/{id}/artists``)."""
    return bool(
        self._delete(f"user/{user_id}/artists", params={"artist_id": artist_id})
    )

deezify.resources.track

Track resource — https://developers.deezer.com/api/track.

TrackResource

Bases: Resource

Read tracks and manage personal tracks / playlist membership.

Source code in deezify/resources/track.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class TrackResource(Resource):
    """Read tracks and manage personal tracks / playlist membership."""

    def get(self, track_id: int, **params: Any) -> Track:
        """Fetch one track by id (``GET /track/{id}``)."""
        return self._get(f"track/{track_id}", params=params or None)

    # -- personal tracks -------------------------------------------------
    def update_personal(self, track_id: int, **fields: Any) -> WriteResult:
        """Update a personal (uploaded) track (``POST /track/{id}``)."""
        return bool(self._post(f"track/{track_id}", data=fields or None))

    def delete_personal(self, track_id: int) -> WriteResult:
        """Delete a personal track (``DELETE /track/{id}``)."""
        return bool(self._delete(f"track/{track_id}"))

    # -- favorites -------------------------------------------------------
    def add_favorite(self, user_id: int | str, track_ids: list[int] | int) -> WriteResult:
        """Add track(s) to favorites (``POST /user/{id}/tracks``)."""
        ids = track_ids if isinstance(track_ids, list) else [track_ids]
        return bool(
            self._post(
                f"user/{user_id}/tracks", data={"track_id": ",".join(map(str, ids))}
            )
        )

    def remove_favorite(self, user_id: int | str, track_id: int) -> WriteResult:
        """Remove a track from favorites (``DELETE /user/{id}/tracks``)."""
        return bool(
            self._delete(f"user/{user_id}/tracks", params={"track_id": track_id})
        )

get(track_id, **params)

Fetch one track by id (GET /track/{id}).

Source code in deezify/resources/track.py
13
14
15
def get(self, track_id: int, **params: Any) -> Track:
    """Fetch one track by id (``GET /track/{id}``)."""
    return self._get(f"track/{track_id}", params=params or None)

update_personal(track_id, **fields)

Update a personal (uploaded) track (POST /track/{id}).

Source code in deezify/resources/track.py
18
19
20
def update_personal(self, track_id: int, **fields: Any) -> WriteResult:
    """Update a personal (uploaded) track (``POST /track/{id}``)."""
    return bool(self._post(f"track/{track_id}", data=fields or None))

delete_personal(track_id)

Delete a personal track (DELETE /track/{id}).

Source code in deezify/resources/track.py
22
23
24
def delete_personal(self, track_id: int) -> WriteResult:
    """Delete a personal track (``DELETE /track/{id}``)."""
    return bool(self._delete(f"track/{track_id}"))

add_favorite(user_id, track_ids)

Add track(s) to favorites (POST /user/{id}/tracks).

Source code in deezify/resources/track.py
27
28
29
30
31
32
33
34
def add_favorite(self, user_id: int | str, track_ids: list[int] | int) -> WriteResult:
    """Add track(s) to favorites (``POST /user/{id}/tracks``)."""
    ids = track_ids if isinstance(track_ids, list) else [track_ids]
    return bool(
        self._post(
            f"user/{user_id}/tracks", data={"track_id": ",".join(map(str, ids))}
        )
    )

remove_favorite(user_id, track_id)

Remove a track from favorites (DELETE /user/{id}/tracks).

Source code in deezify/resources/track.py
36
37
38
39
40
def remove_favorite(self, user_id: int | str, track_id: int) -> WriteResult:
    """Remove a track from favorites (``DELETE /user/{id}/tracks``)."""
    return bool(
        self._delete(f"user/{user_id}/tracks", params={"track_id": track_id})
    )

deezify.resources.playlist

Playlist resource — https://developers.deezer.com/api/playlist.

PlaylistResource

Bases: Resource

Read playlists and manage their tracks.

Source code in deezify/resources/playlist.py
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
class PlaylistResource(Resource):
    """Read playlists and manage their tracks."""

    def get(self, playlist_id: int, **params: Any) -> Playlist:
        """Fetch one playlist by id (``GET /playlist/{id}``)."""
        return self._get(f"playlist/{playlist_id}", params=params or None)

    def fans(
        self, playlist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[User]:
        """Fans of the playlist (``GET /playlist/{id}/fans``)."""
        return self._paginated(
            f"playlist/{playlist_id}/fans", params=self._page(None, index, limit)
        )

    def tracks(
        self, playlist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[AlbumTrack]:
        """Tracks of the playlist (``GET /playlist/{id}/tracks``)."""
        return self._paginated(
            f"playlist/{playlist_id}/tracks", params=self._page(None, index, limit)
        )

    def radio(
        self, playlist_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Track]:
        """Recommended tracks for the playlist (``GET /playlist/{id}/radio``)."""
        return self._paginated(
            f"playlist/{playlist_id}/radio", params=self._page(None, index, limit)
        )

    # -- write actions (need ``manage_library`` / ``delete_library``) ------
    def update(self, playlist_id: int, **fields: Any) -> WriteResult:
        """Update playlist attributes such as title/description
        (``POST /playlist/{id}``)."""
        return bool(self._post(f"playlist/{playlist_id}", data=fields or None))

    def delete(self, playlist_id: int) -> WriteResult:
        """Delete a playlist (``DELETE /playlist/{id}``)."""
        return bool(self._delete(f"playlist/{playlist_id}"))

    def mark_seen(self, playlist_id: int) -> WriteResult:
        """Mark a playlist as seen (``POST /playlist/{id}/seen``)."""
        return bool(self._post(f"playlist/{playlist_id}/seen"))

    def add_tracks(self, playlist_id: int, track_ids: list[int] | int) -> WriteResult:
        """Append tracks (``POST /playlist/{id}/tracks``, ``songs=...``)."""
        ids = track_ids if isinstance(track_ids, list) else [track_ids]
        return bool(
            self._post(
                f"playlist/{playlist_id}/tracks",
                data={"songs": ",".join(map(str, ids))},
            )
        )

    def reorder_tracks(self, playlist_id: int, track_ids: list[int]) -> WriteResult:
        """Reorder tracks (``POST /playlist/{id}/tracks``, ``order=...``)."""
        return bool(
            self._post(
                f"playlist/{playlist_id}/tracks",
                data={"order": ",".join(map(str, track_ids))},
            )
        )

    def remove_tracks(self, playlist_id: int, track_ids: list[int] | int) -> WriteResult:
        """Remove tracks (``DELETE /playlist/{id}/tracks``, ``songs=...``)."""
        ids = track_ids if isinstance(track_ids, list) else [track_ids]
        return bool(
            self._delete(
                f"playlist/{playlist_id}/tracks",
                params={"songs": ",".join(map(str, ids))},
            )
        )

    # -- favorite playlists ------------------------------------------------
    def add_favorite(self, user_id: int | str, playlist_ids: list[int] | int) -> WriteResult:
        """Add playlist(s) to favorites (``POST /user/{id}/playlists``)."""
        ids = playlist_ids if isinstance(playlist_ids, list) else [playlist_ids]
        return bool(
            self._post(
                f"user/{user_id}/playlists",
                data={"playlist_id": ",".join(map(str, ids))},
            )
        )

    def remove_favorite(self, user_id: int | str, playlist_id: int) -> WriteResult:
        """Remove a playlist from favorites (``DELETE /user/{id}/playlists``)."""
        return bool(
            self._delete(
                f"user/{user_id}/playlists", params={"playlist_id": playlist_id}
            )
        )

    def order(self, *args: Any, **kwargs: Any) -> bool:  # pragma: no cover
        raise NotImplementedError(
            "Use reorder_tracks(playlist_id, track_ids) instead."
        )

    order_modes = tuple(_ORDER_MODES)

get(playlist_id, **params)

Fetch one playlist by id (GET /playlist/{id}).

Source code in deezify/resources/playlist.py
17
18
19
def get(self, playlist_id: int, **params: Any) -> Playlist:
    """Fetch one playlist by id (``GET /playlist/{id}``)."""
    return self._get(f"playlist/{playlist_id}", params=params or None)

fans(playlist_id, *, index=None, limit=None)

Fans of the playlist (GET /playlist/{id}/fans).

Source code in deezify/resources/playlist.py
21
22
23
24
25
26
27
def fans(
    self, playlist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[User]:
    """Fans of the playlist (``GET /playlist/{id}/fans``)."""
    return self._paginated(
        f"playlist/{playlist_id}/fans", params=self._page(None, index, limit)
    )

tracks(playlist_id, *, index=None, limit=None)

Tracks of the playlist (GET /playlist/{id}/tracks).

Source code in deezify/resources/playlist.py
29
30
31
32
33
34
35
def tracks(
    self, playlist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[AlbumTrack]:
    """Tracks of the playlist (``GET /playlist/{id}/tracks``)."""
    return self._paginated(
        f"playlist/{playlist_id}/tracks", params=self._page(None, index, limit)
    )

radio(playlist_id, *, index=None, limit=None)

Recommended tracks for the playlist (GET /playlist/{id}/radio).

Source code in deezify/resources/playlist.py
37
38
39
40
41
42
43
def radio(
    self, playlist_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Track]:
    """Recommended tracks for the playlist (``GET /playlist/{id}/radio``)."""
    return self._paginated(
        f"playlist/{playlist_id}/radio", params=self._page(None, index, limit)
    )

update(playlist_id, **fields)

Update playlist attributes such as title/description (POST /playlist/{id}).

Source code in deezify/resources/playlist.py
46
47
48
49
def update(self, playlist_id: int, **fields: Any) -> WriteResult:
    """Update playlist attributes such as title/description
    (``POST /playlist/{id}``)."""
    return bool(self._post(f"playlist/{playlist_id}", data=fields or None))

delete(playlist_id)

Delete a playlist (DELETE /playlist/{id}).

Source code in deezify/resources/playlist.py
51
52
53
def delete(self, playlist_id: int) -> WriteResult:
    """Delete a playlist (``DELETE /playlist/{id}``)."""
    return bool(self._delete(f"playlist/{playlist_id}"))

mark_seen(playlist_id)

Mark a playlist as seen (POST /playlist/{id}/seen).

Source code in deezify/resources/playlist.py
55
56
57
def mark_seen(self, playlist_id: int) -> WriteResult:
    """Mark a playlist as seen (``POST /playlist/{id}/seen``)."""
    return bool(self._post(f"playlist/{playlist_id}/seen"))

add_tracks(playlist_id, track_ids)

Append tracks (POST /playlist/{id}/tracks, songs=...).

Source code in deezify/resources/playlist.py
59
60
61
62
63
64
65
66
67
def add_tracks(self, playlist_id: int, track_ids: list[int] | int) -> WriteResult:
    """Append tracks (``POST /playlist/{id}/tracks``, ``songs=...``)."""
    ids = track_ids if isinstance(track_ids, list) else [track_ids]
    return bool(
        self._post(
            f"playlist/{playlist_id}/tracks",
            data={"songs": ",".join(map(str, ids))},
        )
    )

reorder_tracks(playlist_id, track_ids)

Reorder tracks (POST /playlist/{id}/tracks, order=...).

Source code in deezify/resources/playlist.py
69
70
71
72
73
74
75
76
def reorder_tracks(self, playlist_id: int, track_ids: list[int]) -> WriteResult:
    """Reorder tracks (``POST /playlist/{id}/tracks``, ``order=...``)."""
    return bool(
        self._post(
            f"playlist/{playlist_id}/tracks",
            data={"order": ",".join(map(str, track_ids))},
        )
    )

remove_tracks(playlist_id, track_ids)

Remove tracks (DELETE /playlist/{id}/tracks, songs=...).

Source code in deezify/resources/playlist.py
78
79
80
81
82
83
84
85
86
def remove_tracks(self, playlist_id: int, track_ids: list[int] | int) -> WriteResult:
    """Remove tracks (``DELETE /playlist/{id}/tracks``, ``songs=...``)."""
    ids = track_ids if isinstance(track_ids, list) else [track_ids]
    return bool(
        self._delete(
            f"playlist/{playlist_id}/tracks",
            params={"songs": ",".join(map(str, ids))},
        )
    )

add_favorite(user_id, playlist_ids)

Add playlist(s) to favorites (POST /user/{id}/playlists).

Source code in deezify/resources/playlist.py
89
90
91
92
93
94
95
96
97
def add_favorite(self, user_id: int | str, playlist_ids: list[int] | int) -> WriteResult:
    """Add playlist(s) to favorites (``POST /user/{id}/playlists``)."""
    ids = playlist_ids if isinstance(playlist_ids, list) else [playlist_ids]
    return bool(
        self._post(
            f"user/{user_id}/playlists",
            data={"playlist_id": ",".join(map(str, ids))},
        )
    )

remove_favorite(user_id, playlist_id)

Remove a playlist from favorites (DELETE /user/{id}/playlists).

Source code in deezify/resources/playlist.py
 99
100
101
102
103
104
105
def remove_favorite(self, user_id: int | str, playlist_id: int) -> WriteResult:
    """Remove a playlist from favorites (``DELETE /user/{id}/playlists``)."""
    return bool(
        self._delete(
            f"user/{user_id}/playlists", params={"playlist_id": playlist_id}
        )
    )

deezify.resources.podcast

Podcast + episode resources.

  • https://developers.deezer.com/api/podcast
  • https://developers.deezer.com/api/episode

PodcastResource

Bases: Resource

Read podcasts and manage podcast favorites.

Source code in deezify/resources/podcast.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class PodcastResource(Resource):
    """Read podcasts and manage podcast favorites."""

    def get(self, podcast_id: int, **params: Any) -> Podcast:
        """Fetch one podcast by id (``GET /podcast/{id}``)."""
        return self._get(f"podcast/{podcast_id}", params=params or None)

    def episodes(
        self, podcast_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Episode]:
        """Episodes of the podcast (``GET /podcast/{id}/episodes``)."""
        return self._paginated(
            f"podcast/{podcast_id}/episodes", params=self._page(None, index, limit)
        )

    def add_favorite(self, user_id: int | str, podcast_id: int) -> WriteResult:
        """Add a podcast to favorites (``POST /user/{id}/podcasts``)."""
        return bool(
            self._post(
                f"user/{user_id}/podcasts", data={"podcast_id": str(podcast_id)}
            )
        )

    def remove_favorite(self, user_id: int | str, podcast_id: int) -> WriteResult:
        """Remove a podcast from favorites (``DELETE /user/{id}/podcasts``)."""
        return bool(
            self._delete(
                f"user/{user_id}/podcasts", params={"podcast_id": podcast_id}
            )
        )

get(podcast_id, **params)

Fetch one podcast by id (GET /podcast/{id}).

Source code in deezify/resources/podcast.py
19
20
21
def get(self, podcast_id: int, **params: Any) -> Podcast:
    """Fetch one podcast by id (``GET /podcast/{id}``)."""
    return self._get(f"podcast/{podcast_id}", params=params or None)

episodes(podcast_id, *, index=None, limit=None)

Episodes of the podcast (GET /podcast/{id}/episodes).

Source code in deezify/resources/podcast.py
23
24
25
26
27
28
29
def episodes(
    self, podcast_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Episode]:
    """Episodes of the podcast (``GET /podcast/{id}/episodes``)."""
    return self._paginated(
        f"podcast/{podcast_id}/episodes", params=self._page(None, index, limit)
    )

add_favorite(user_id, podcast_id)

Add a podcast to favorites (POST /user/{id}/podcasts).

Source code in deezify/resources/podcast.py
31
32
33
34
35
36
37
def add_favorite(self, user_id: int | str, podcast_id: int) -> WriteResult:
    """Add a podcast to favorites (``POST /user/{id}/podcasts``)."""
    return bool(
        self._post(
            f"user/{user_id}/podcasts", data={"podcast_id": str(podcast_id)}
        )
    )

remove_favorite(user_id, podcast_id)

Remove a podcast from favorites (DELETE /user/{id}/podcasts).

Source code in deezify/resources/podcast.py
39
40
41
42
43
44
45
def remove_favorite(self, user_id: int | str, podcast_id: int) -> WriteResult:
    """Remove a podcast from favorites (``DELETE /user/{id}/podcasts``)."""
    return bool(
        self._delete(
            f"user/{user_id}/podcasts", params={"podcast_id": podcast_id}
        )
    )

EpisodeResource

Bases: Resource

Read episodes and manage bookmarks (offset 0–100).

Source code in deezify/resources/podcast.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
class EpisodeResource(Resource):
    """Read episodes and manage bookmarks (offset 0–100)."""

    def get(self, episode_id: int, **params: Any) -> Episode:
        """Fetch one episode by id (``GET /episode/{id}``)."""
        return self._get(f"episode/{episode_id}", params=params or None)

    def bookmark_info(self, episode_id: int) -> Bookmark:
        """Current bookmark (``GET /episode/{id}/bookmark``)."""
        return self._get(f"episode/{episode_id}/bookmark")

    def set_bookmark(self, episode_id: int, offset: int) -> WriteResult:
        """Set a bookmark (``POST /episode/{id}/bookmark``, offset 0–100)."""
        if not 0 <= offset <= 100:
            raise ValueError("offset must be between 0 and 100")
        return bool(
            self._post(f"episode/{episode_id}/bookmark", data={"offset": str(offset)})
        )

    def remove_bookmark(self, episode_id: int) -> WriteResult:
        """Remove the bookmark (``DELETE /episode/{id}/bookmark``)."""
        return bool(self._delete(f"episode/{episode_id}/bookmark"))

get(episode_id, **params)

Fetch one episode by id (GET /episode/{id}).

Source code in deezify/resources/podcast.py
51
52
53
def get(self, episode_id: int, **params: Any) -> Episode:
    """Fetch one episode by id (``GET /episode/{id}``)."""
    return self._get(f"episode/{episode_id}", params=params or None)

bookmark_info(episode_id)

Current bookmark (GET /episode/{id}/bookmark).

Source code in deezify/resources/podcast.py
55
56
57
def bookmark_info(self, episode_id: int) -> Bookmark:
    """Current bookmark (``GET /episode/{id}/bookmark``)."""
    return self._get(f"episode/{episode_id}/bookmark")

set_bookmark(episode_id, offset)

Set a bookmark (POST /episode/{id}/bookmark, offset 0–100).

Source code in deezify/resources/podcast.py
59
60
61
62
63
64
65
def set_bookmark(self, episode_id: int, offset: int) -> WriteResult:
    """Set a bookmark (``POST /episode/{id}/bookmark``, offset 0–100)."""
    if not 0 <= offset <= 100:
        raise ValueError("offset must be between 0 and 100")
    return bool(
        self._post(f"episode/{episode_id}/bookmark", data={"offset": str(offset)})
    )

remove_bookmark(episode_id)

Remove the bookmark (DELETE /episode/{id}/bookmark).

Source code in deezify/resources/podcast.py
67
68
69
def remove_bookmark(self, episode_id: int) -> WriteResult:
    """Remove the bookmark (``DELETE /episode/{id}/bookmark``)."""
    return bool(self._delete(f"episode/{episode_id}/bookmark"))

deezify.resources.user

User resource — https://developers.deezer.com/api/user.

user_id may be a numeric id or "me" (the access-token owner).

UserResource

Bases: Resource

Read profiles, favorites, flow, history and manage relationships.

Source code in deezify/resources/user.py
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
class UserResource(Resource):
    """Read profiles, favorites, flow, history and manage relationships."""

    def get(self, user_id: UserId = "me", **params: Any) -> User:
        """Fetch a user profile (``GET /user/{id}``)."""
        return self._get(f"user/{user_id}", params=params or None)

    def me(self, **params: Any) -> User:
        """Fetch the access-token owner's profile (``GET /user/me``)."""
        return self.get("me", **params)

    # -- generic connection helper --------------------------------------
    def _conn(
        self, user_id: UserId, name: str, *, index: int | None, limit: int | None
    ) -> PaginatedList[Any]:
        return self._paginated(
            f"user/{user_id}/{name}", params=self._page(None, index, limit)
        )

    def albums(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Album]:
        """Favorite albums (``GET /user/{id}/albums``)."""
        return self._conn(user_id, "albums", index=index, limit=limit)

    def artists(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Artist]:
        """Favorite artists (``GET /user/{id}/artists``)."""
        return self._conn(user_id, "artists", index=index, limit=limit)

    def tracks(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Track]:
        """Favorite tracks (``GET /user/{id}/tracks``)."""
        return self._conn(user_id, "tracks", index=index, limit=limit)

    def playlists(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Playlist]:
        """Playlists incl. private ones with permission (``GET /user/{id}/playlists``)."""
        return self._conn(user_id, "playlists", index=index, limit=limit)

    def podcasts(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Podcast]:
        """Favorite podcasts (``GET /user/{id}/podcasts``)."""
        return self._conn(user_id, "podcasts", index=index, limit=limit)

    def radios(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Radio]:
        """Favorite radios (``GET /user/{id}/radios``)."""
        return self._conn(user_id, "radios", index=index, limit=limit)

    def followings(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[User]:
        """Users this user follows (``GET /user/{id}/followings``)."""
        return self._conn(user_id, "followings", index=index, limit=limit)

    def followers(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[User]:
        """Followers of this user (``GET /user/{id}/followers``)."""
        return self._conn(user_id, "followers", index=index, limit=limit)

    def flow(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Track]:
        """Flow tracks (``GET /user/{id}/flow``)."""
        return self._conn(user_id, "flow", index=index, limit=limit)

    def history(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Track]:
        """Recently played tracks, needs ``listening_history``
        (``GET /user/{id}/history``)."""
        return self._conn(user_id, "history", index=index, limit=limit)

    def personal_songs(
        self, user_id: UserId = "me", *, index=None, limit=None
    ) -> PaginatedList[Track]:
        """Uploaded personal songs (``GET /user/{id}/personal_songs``)."""
        return self._conn(user_id, "personal_songs", index=index, limit=limit)

    def charts_albums(self, user_id: UserId = "me", **params: Any) -> Any:
        """``GET /user/{id}/charts/albums``."""
        return self._get(f"user/{user_id}/charts/albums", params=params or None)

    def charts_playlists(self, user_id: UserId = "me", **params: Any) -> Any:
        """``GET /user/{id}/charts/playlists``."""
        return self._get(f"user/{user_id}/charts/playlists", params=params or None)

    def charts_tracks(self, user_id: UserId = "me", **params: Any) -> Any:
        """``GET /user/{id}/charts/tracks``."""
        return self._get(f"user/{user_id}/charts/tracks", params=params or None)

    def recommendations(self, user_id: UserId = "me", kind: str | RecommendationKind = "tracks", **params: Any) -> Any:
        """Recommendations feed (``GET /user/{id}/recommendations/{kind}``).

        ``kind`` accepts a raw string or :class:`~deezify.enums.RecommendationKind`.
        """
        kind_str = RecommendationKind.coerce(kind, label="recommendation kind")
        return self._get(f"user/{user_id}/recommendations/{kind_str}", params=params or None)

    def user_chart(self, user_id: UserId = "me", kind: str | UserChartKind = "tracks", **params: Any) -> Any:
        """User chart feed (``GET /user/{id}/charts/{kind}``).

        ``kind`` accepts a raw string or :class:`~deezify.enums.UserChartKind`.
        """
        kind_str = UserChartKind.coerce(kind, label="user chart kind")
        return self._get(f"user/{user_id}/charts/{kind_str}", params=params or None)

    def permissions(self, user_id: UserId = "me") -> Any:
        """Permissions granted to the app (``GET /user/{id}/permissions``)."""
        return self._get(f"user/{user_id}/permissions")

    def options(self, user_id: UserId = "me", **params: Any) -> Options:
        """Alias of ``/options`` (``GET /user/{id}/options``)."""
        return self._get(f"user/{user_id}/options", params=params or None)

    # -- write actions ----------------------------------------------------
    def create_playlist(self, user_id: UserId, title: str) -> CreatePlaylistResult:
        """Create a playlist (``POST /user/{id}/playlists``, ``title=...``)."""
        if not title or not title.strip():
            raise ValueError("title must be a non-empty string")
        return self._post(f"user/{user_id}/playlists", data={"title": title})

    def follow(self, user_id: UserId, target_user_id: int) -> WriteResult:
        """Follow a user (``POST /user/{id}/followings``)."""
        return bool(
            self._post(
                f"user/{user_id}/followings", data={"user_id": str(target_user_id)}
            )
        )

    def unfollow(self, user_id: UserId, target_user_id: int) -> WriteResult:
        """Unfollow a user (``DELETE /user/{id}/followings``)."""
        return bool(
            self._delete(
                f"user/{user_id}/followings", params={"user_id": target_user_id}
            )
        )

    def add_notification(self, user_id: UserId, message: str) -> Any:
        """Push a notification into the user feed
        (``POST /user/{id}/notifications``)."""
        return self._post(f"user/{user_id}/notifications", data={"message": message})

get(user_id='me', **params)

Fetch a user profile (GET /user/{id}).

Source code in deezify/resources/user.py
24
25
26
def get(self, user_id: UserId = "me", **params: Any) -> User:
    """Fetch a user profile (``GET /user/{id}``)."""
    return self._get(f"user/{user_id}", params=params or None)

me(**params)

Fetch the access-token owner's profile (GET /user/me).

Source code in deezify/resources/user.py
28
29
30
def me(self, **params: Any) -> User:
    """Fetch the access-token owner's profile (``GET /user/me``)."""
    return self.get("me", **params)

albums(user_id='me', *, index=None, limit=None)

Favorite albums (GET /user/{id}/albums).

Source code in deezify/resources/user.py
40
41
42
def albums(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Album]:
    """Favorite albums (``GET /user/{id}/albums``)."""
    return self._conn(user_id, "albums", index=index, limit=limit)

artists(user_id='me', *, index=None, limit=None)

Favorite artists (GET /user/{id}/artists).

Source code in deezify/resources/user.py
44
45
46
def artists(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Artist]:
    """Favorite artists (``GET /user/{id}/artists``)."""
    return self._conn(user_id, "artists", index=index, limit=limit)

tracks(user_id='me', *, index=None, limit=None)

Favorite tracks (GET /user/{id}/tracks).

Source code in deezify/resources/user.py
48
49
50
def tracks(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Track]:
    """Favorite tracks (``GET /user/{id}/tracks``)."""
    return self._conn(user_id, "tracks", index=index, limit=limit)

playlists(user_id='me', *, index=None, limit=None)

Playlists incl. private ones with permission (GET /user/{id}/playlists).

Source code in deezify/resources/user.py
52
53
54
def playlists(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Playlist]:
    """Playlists incl. private ones with permission (``GET /user/{id}/playlists``)."""
    return self._conn(user_id, "playlists", index=index, limit=limit)

podcasts(user_id='me', *, index=None, limit=None)

Favorite podcasts (GET /user/{id}/podcasts).

Source code in deezify/resources/user.py
56
57
58
def podcasts(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Podcast]:
    """Favorite podcasts (``GET /user/{id}/podcasts``)."""
    return self._conn(user_id, "podcasts", index=index, limit=limit)

radios(user_id='me', *, index=None, limit=None)

Favorite radios (GET /user/{id}/radios).

Source code in deezify/resources/user.py
60
61
62
def radios(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Radio]:
    """Favorite radios (``GET /user/{id}/radios``)."""
    return self._conn(user_id, "radios", index=index, limit=limit)

followings(user_id='me', *, index=None, limit=None)

Users this user follows (GET /user/{id}/followings).

Source code in deezify/resources/user.py
64
65
66
def followings(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[User]:
    """Users this user follows (``GET /user/{id}/followings``)."""
    return self._conn(user_id, "followings", index=index, limit=limit)

followers(user_id='me', *, index=None, limit=None)

Followers of this user (GET /user/{id}/followers).

Source code in deezify/resources/user.py
68
69
70
def followers(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[User]:
    """Followers of this user (``GET /user/{id}/followers``)."""
    return self._conn(user_id, "followers", index=index, limit=limit)

flow(user_id='me', *, index=None, limit=None)

Flow tracks (GET /user/{id}/flow).

Source code in deezify/resources/user.py
72
73
74
def flow(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Track]:
    """Flow tracks (``GET /user/{id}/flow``)."""
    return self._conn(user_id, "flow", index=index, limit=limit)

history(user_id='me', *, index=None, limit=None)

Recently played tracks, needs listening_history (GET /user/{id}/history).

Source code in deezify/resources/user.py
76
77
78
79
def history(self, user_id: UserId = "me", *, index=None, limit=None) -> PaginatedList[Track]:
    """Recently played tracks, needs ``listening_history``
    (``GET /user/{id}/history``)."""
    return self._conn(user_id, "history", index=index, limit=limit)

personal_songs(user_id='me', *, index=None, limit=None)

Uploaded personal songs (GET /user/{id}/personal_songs).

Source code in deezify/resources/user.py
81
82
83
84
85
def personal_songs(
    self, user_id: UserId = "me", *, index=None, limit=None
) -> PaginatedList[Track]:
    """Uploaded personal songs (``GET /user/{id}/personal_songs``)."""
    return self._conn(user_id, "personal_songs", index=index, limit=limit)

charts_albums(user_id='me', **params)

GET /user/{id}/charts/albums.

Source code in deezify/resources/user.py
87
88
89
def charts_albums(self, user_id: UserId = "me", **params: Any) -> Any:
    """``GET /user/{id}/charts/albums``."""
    return self._get(f"user/{user_id}/charts/albums", params=params or None)

charts_playlists(user_id='me', **params)

GET /user/{id}/charts/playlists.

Source code in deezify/resources/user.py
91
92
93
def charts_playlists(self, user_id: UserId = "me", **params: Any) -> Any:
    """``GET /user/{id}/charts/playlists``."""
    return self._get(f"user/{user_id}/charts/playlists", params=params or None)

charts_tracks(user_id='me', **params)

GET /user/{id}/charts/tracks.

Source code in deezify/resources/user.py
95
96
97
def charts_tracks(self, user_id: UserId = "me", **params: Any) -> Any:
    """``GET /user/{id}/charts/tracks``."""
    return self._get(f"user/{user_id}/charts/tracks", params=params or None)

recommendations(user_id='me', kind='tracks', **params)

Recommendations feed (GET /user/{id}/recommendations/{kind}).

kind accepts a raw string or :class:~deezify.enums.RecommendationKind.

Source code in deezify/resources/user.py
 99
100
101
102
103
104
105
def recommendations(self, user_id: UserId = "me", kind: str | RecommendationKind = "tracks", **params: Any) -> Any:
    """Recommendations feed (``GET /user/{id}/recommendations/{kind}``).

    ``kind`` accepts a raw string or :class:`~deezify.enums.RecommendationKind`.
    """
    kind_str = RecommendationKind.coerce(kind, label="recommendation kind")
    return self._get(f"user/{user_id}/recommendations/{kind_str}", params=params or None)

user_chart(user_id='me', kind='tracks', **params)

User chart feed (GET /user/{id}/charts/{kind}).

kind accepts a raw string or :class:~deezify.enums.UserChartKind.

Source code in deezify/resources/user.py
107
108
109
110
111
112
113
def user_chart(self, user_id: UserId = "me", kind: str | UserChartKind = "tracks", **params: Any) -> Any:
    """User chart feed (``GET /user/{id}/charts/{kind}``).

    ``kind`` accepts a raw string or :class:`~deezify.enums.UserChartKind`.
    """
    kind_str = UserChartKind.coerce(kind, label="user chart kind")
    return self._get(f"user/{user_id}/charts/{kind_str}", params=params or None)

permissions(user_id='me')

Permissions granted to the app (GET /user/{id}/permissions).

Source code in deezify/resources/user.py
115
116
117
def permissions(self, user_id: UserId = "me") -> Any:
    """Permissions granted to the app (``GET /user/{id}/permissions``)."""
    return self._get(f"user/{user_id}/permissions")

options(user_id='me', **params)

Alias of /options (GET /user/{id}/options).

Source code in deezify/resources/user.py
119
120
121
def options(self, user_id: UserId = "me", **params: Any) -> Options:
    """Alias of ``/options`` (``GET /user/{id}/options``)."""
    return self._get(f"user/{user_id}/options", params=params or None)

create_playlist(user_id, title)

Create a playlist (POST /user/{id}/playlists, title=...).

Source code in deezify/resources/user.py
124
125
126
127
128
def create_playlist(self, user_id: UserId, title: str) -> CreatePlaylistResult:
    """Create a playlist (``POST /user/{id}/playlists``, ``title=...``)."""
    if not title or not title.strip():
        raise ValueError("title must be a non-empty string")
    return self._post(f"user/{user_id}/playlists", data={"title": title})

follow(user_id, target_user_id)

Follow a user (POST /user/{id}/followings).

Source code in deezify/resources/user.py
130
131
132
133
134
135
136
def follow(self, user_id: UserId, target_user_id: int) -> WriteResult:
    """Follow a user (``POST /user/{id}/followings``)."""
    return bool(
        self._post(
            f"user/{user_id}/followings", data={"user_id": str(target_user_id)}
        )
    )

unfollow(user_id, target_user_id)

Unfollow a user (DELETE /user/{id}/followings).

Source code in deezify/resources/user.py
138
139
140
141
142
143
144
def unfollow(self, user_id: UserId, target_user_id: int) -> WriteResult:
    """Unfollow a user (``DELETE /user/{id}/followings``)."""
    return bool(
        self._delete(
            f"user/{user_id}/followings", params={"user_id": target_user_id}
        )
    )

add_notification(user_id, message)

Push a notification into the user feed (POST /user/{id}/notifications).

Source code in deezify/resources/user.py
146
147
148
149
def add_notification(self, user_id: UserId, message: str) -> Any:
    """Push a notification into the user feed
    (``POST /user/{id}/notifications``)."""
    return self._post(f"user/{user_id}/notifications", data={"message": message})

deezify.resources.search

Search resource — https://developers.deezer.com/api/search.

Supports plain search, per-type search, advanced field syntax (artist:"..." album:"..." track:"..." label:"..." dur_min:... etc.), strict fuzzy toggle and order sorting.

SearchResource

Bases: Resource

Full-text and advanced search across the Deezer catalogue.

Source code in deezify/resources/search.py
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
class SearchResource(Resource):
    """Full-text and advanced search across the Deezer catalogue."""

    def _search(
        self,
        path: str,
        query: str,
        *,
        strict: bool | None = None,
        order: str | SearchOrder | None = None,
        index: int | None = None,
        limit: int | None = None,
    ) -> PaginatedList[Track]:
        if not query or not query.strip():
            raise ValueError("query must be a non-empty string")
        order_str = coerce_optional_enum(SearchOrder, order, label="order")
        params: dict[str, Any] = {"q": query}
        if strict is not None:
            params["strict"] = "on" if strict else "off"
        if order_str is not None:
            params["order"] = order_str
        return self._paginated(path, params=self._page(params, index, limit))

    def all(
        self, query: str, *, strict: bool | None = None,
        order: str | SearchOrder | None = None,
        index: int | None = None, limit: int | None = None,
    ) -> PaginatedList[Track]:
        """Cross-type search (``GET /search?q=...``)."""
        return self._search("search", query, strict=strict, order=order,
                            index=index, limit=limit)

    def tracks(self, query: str, **kwargs: Any) -> PaginatedList[Track]:
        """Search tracks (``GET /search/track?q=...``)."""
        return self._search("search/track", query, **kwargs)

    def albums(self, query: str, **kwargs: Any) -> PaginatedList[Album]:
        """Search albums (``GET /search/album?q=...``)."""
        return self._search("search/album", query, **kwargs)

    def artists(self, query: str, **kwargs: Any) -> PaginatedList[Artist]:
        """Search artists (``GET /search/artist?q=...``)."""
        return self._search("search/artist", query, **kwargs)

    def playlists(self, query: str, **kwargs: Any) -> PaginatedList[Playlist]:
        """Search playlists (``GET /search/playlist?q=...``)."""
        return self._search("search/playlist", query, **kwargs)

    def podcasts(self, query: str, **kwargs: Any) -> PaginatedList[Podcast]:
        """Search podcasts (``GET /search/podcast?q=...``)."""
        return self._search("search/podcast", query, **kwargs)

    def radios(self, query: str, **kwargs: Any) -> PaginatedList[Radio]:
        """Search radios (``GET /search/radio?q=...``)."""
        return self._search("search/radio", query, **kwargs)

    def users(self, query: str, **kwargs: Any) -> PaginatedList[User]:
        """Search users (``GET /search/user?q=...``)."""
        return self._search("search/user", query, **kwargs)

    def advanced(self, path: str = "search", *, strict: bool | None = None,
                 order: str | SearchOrder | None = None, index: int | None = None,
                 limit: int | None = None, **fields: Any) -> PaginatedList[Track]:
        """Advanced field search, e.g. ``advanced(artist="Daft Punk")``.

        ``path`` may be ``"search"`` or any ``"search/<type>"`` endpoint.
        """
        return self._search(path, build_advanced_query(**fields), strict=strict,
                            order=order, index=index, limit=limit)

    def history(
        self, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Track]:
        """Authenticated user's search history (``GET /search/history``)."""
        return self._paginated(
            "search/history", params=self._page(None, index, limit)
        )

all(query, *, strict=None, order=None, index=None, limit=None)

Cross-type search (GET /search?q=...).

Source code in deezify/resources/search.py
67
68
69
70
71
72
73
74
def all(
    self, query: str, *, strict: bool | None = None,
    order: str | SearchOrder | None = None,
    index: int | None = None, limit: int | None = None,
) -> PaginatedList[Track]:
    """Cross-type search (``GET /search?q=...``)."""
    return self._search("search", query, strict=strict, order=order,
                        index=index, limit=limit)

tracks(query, **kwargs)

Search tracks (GET /search/track?q=...).

Source code in deezify/resources/search.py
76
77
78
def tracks(self, query: str, **kwargs: Any) -> PaginatedList[Track]:
    """Search tracks (``GET /search/track?q=...``)."""
    return self._search("search/track", query, **kwargs)

albums(query, **kwargs)

Search albums (GET /search/album?q=...).

Source code in deezify/resources/search.py
80
81
82
def albums(self, query: str, **kwargs: Any) -> PaginatedList[Album]:
    """Search albums (``GET /search/album?q=...``)."""
    return self._search("search/album", query, **kwargs)

artists(query, **kwargs)

Search artists (GET /search/artist?q=...).

Source code in deezify/resources/search.py
84
85
86
def artists(self, query: str, **kwargs: Any) -> PaginatedList[Artist]:
    """Search artists (``GET /search/artist?q=...``)."""
    return self._search("search/artist", query, **kwargs)

playlists(query, **kwargs)

Search playlists (GET /search/playlist?q=...).

Source code in deezify/resources/search.py
88
89
90
def playlists(self, query: str, **kwargs: Any) -> PaginatedList[Playlist]:
    """Search playlists (``GET /search/playlist?q=...``)."""
    return self._search("search/playlist", query, **kwargs)

podcasts(query, **kwargs)

Search podcasts (GET /search/podcast?q=...).

Source code in deezify/resources/search.py
92
93
94
def podcasts(self, query: str, **kwargs: Any) -> PaginatedList[Podcast]:
    """Search podcasts (``GET /search/podcast?q=...``)."""
    return self._search("search/podcast", query, **kwargs)

radios(query, **kwargs)

Search radios (GET /search/radio?q=...).

Source code in deezify/resources/search.py
96
97
98
def radios(self, query: str, **kwargs: Any) -> PaginatedList[Radio]:
    """Search radios (``GET /search/radio?q=...``)."""
    return self._search("search/radio", query, **kwargs)

users(query, **kwargs)

Search users (GET /search/user?q=...).

Source code in deezify/resources/search.py
100
101
102
def users(self, query: str, **kwargs: Any) -> PaginatedList[User]:
    """Search users (``GET /search/user?q=...``)."""
    return self._search("search/user", query, **kwargs)

advanced(path='search', *, strict=None, order=None, index=None, limit=None, **fields)

Advanced field search, e.g. advanced(artist="Daft Punk").

path may be "search" or any "search/<type>" endpoint.

Source code in deezify/resources/search.py
104
105
106
107
108
109
110
111
112
def advanced(self, path: str = "search", *, strict: bool | None = None,
             order: str | SearchOrder | None = None, index: int | None = None,
             limit: int | None = None, **fields: Any) -> PaginatedList[Track]:
    """Advanced field search, e.g. ``advanced(artist="Daft Punk")``.

    ``path`` may be ``"search"`` or any ``"search/<type>"`` endpoint.
    """
    return self._search(path, build_advanced_query(**fields), strict=strict,
                        order=order, index=index, limit=limit)

history(*, index=None, limit=None)

Authenticated user's search history (GET /search/history).

Source code in deezify/resources/search.py
114
115
116
117
118
119
120
def history(
    self, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Track]:
    """Authenticated user's search history (``GET /search/history``)."""
    return self._paginated(
        "search/history", params=self._page(None, index, limit)
    )

build_advanced_query(**fields)

Build an advanced-search q string from field keywords.

String values containing spaces are quoted, e.g. build_advanced_query(artist="Aloe Blacc", track="I Need A Dollar") → 'artist:"Aloe Blacc" track:"I Need A Dollar"'.

Source code in deezify/resources/search.py
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
def build_advanced_query(**fields: Any) -> str:
    """Build an advanced-search ``q`` string from field keywords.

    String values containing spaces are quoted, e.g.
    ``build_advanced_query(artist="Aloe Blacc", track="I Need A Dollar")`` →
    ``'artist:"Aloe Blacc" track:"I Need A Dollar"'``.
    """
    parts: list[str] = []
    for key, value in fields.items():
        if value is None:
            continue
        name = SearchField.coerce(key.lower(), label="advanced-search field")
        text = str(value)
        if isinstance(value, str) and (" " in text or '"' in text):
            text = '"{}"'.format(text.replace('"', ""))
        parts.append(f"{name}:{text}")
    return " ".join(parts)

deezify.resources.catalog

Radio, genre, chart, editorial, infos and options resources.

RadioResource

Bases: Resource

Radios — https://developers.deezer.com/api/radio.

Source code in deezify/resources/catalog.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class RadioResource(Resource):
    """Radios — https://developers.deezer.com/api/radio."""

    def get(self, radio_id: int, **params: Any) -> Radio:
        return self._get(f"radio/{radio_id}", params=params or None)

    def list(self, **params: Any) -> PaginatedList[Radio]:
        """All radios (``GET /radio``)."""
        return self._paginated("radio", params=params or None)

    def genres(
        self, radio_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Radio]:
        return self._paginated(
            f"radio/{radio_id}/genres", params=self._page(None, index, limit)
        )

    def top(
        self, radio_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Radio]:
        """Top radios (``GET /radio/top``; default 25)."""
        path = "radio/top" if not radio_id else f"radio/{radio_id}/top"
        return self._paginated(path, params=self._page(None, index, limit))

    def tracks(
        self, radio_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Track]:
        """First tracks of a radio (``GET /radio/{id}/tracks``)."""
        return self._paginated(
            f"radio/{radio_id}/tracks", params=self._page(None, index, limit)
        )

    def lists(
        self, radio_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Radio]:
        """Personal (MIX) radios (``GET /radio/lists``)."""
        path = "radio/lists" if not radio_id else f"radio/{radio_id}/lists"
        return self._paginated(path, params=self._page(None, index, limit))

    def add_favorite(self, user_id: int | str, radio_id: int) -> WriteResult:
        return bool(
            self._post(f"user/{user_id}/radios", data={"radio_id": str(radio_id)})
        )

    def remove_favorite(self, user_id: int | str, radio_id: int) -> WriteResult:
        return bool(
            self._delete(f"user/{user_id}/radios", params={"radio_id": radio_id})
        )

list(**params)

All radios (GET /radio).

Source code in deezify/resources/catalog.py
21
22
23
def list(self, **params: Any) -> PaginatedList[Radio]:
    """All radios (``GET /radio``)."""
    return self._paginated("radio", params=params or None)

top(radio_id=0, *, index=None, limit=None)

Top radios (GET /radio/top; default 25).

Source code in deezify/resources/catalog.py
32
33
34
35
36
37
def top(
    self, radio_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Radio]:
    """Top radios (``GET /radio/top``; default 25)."""
    path = "radio/top" if not radio_id else f"radio/{radio_id}/top"
    return self._paginated(path, params=self._page(None, index, limit))

tracks(radio_id, *, index=None, limit=None)

First tracks of a radio (GET /radio/{id}/tracks).

Source code in deezify/resources/catalog.py
39
40
41
42
43
44
45
def tracks(
    self, radio_id: int, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Track]:
    """First tracks of a radio (``GET /radio/{id}/tracks``)."""
    return self._paginated(
        f"radio/{radio_id}/tracks", params=self._page(None, index, limit)
    )

lists(radio_id=0, *, index=None, limit=None)

Personal (MIX) radios (GET /radio/lists).

Source code in deezify/resources/catalog.py
47
48
49
50
51
52
def lists(
    self, radio_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Radio]:
    """Personal (MIX) radios (``GET /radio/lists``)."""
    path = "radio/lists" if not radio_id else f"radio/{radio_id}/lists"
    return self._paginated(path, params=self._page(None, index, limit))

GenreResource

Bases: Resource

Genres — https://developers.deezer.com/api/genre.

Source code in deezify/resources/catalog.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
class GenreResource(Resource):
    """Genres — https://developers.deezer.com/api/genre."""

    def get(self, genre_id: int, **params: Any) -> Genre:
        return self._get(f"genre/{genre_id}", params=params or None)

    def list(self, **params: Any) -> PaginatedList[Genre]:
        """All genres (``GET /genre``)."""
        return self._paginated("genre", params=params or None)

    def artists(
        self, genre_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Artist]:
        return self._paginated(
            f"genre/{genre_id}/artists", params=self._page(None, index, limit)
        )

    def podcasts(
        self, genre_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Podcast]:
        return self._paginated(
            f"genre/{genre_id}/podcasts", params=self._page(None, index, limit)
        )

    def radios(
        self, genre_id: int, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Radio]:
        return self._paginated(
            f"genre/{genre_id}/radios", params=self._page(None, index, limit)
        )

list(**params)

All genres (GET /genre).

Source code in deezify/resources/catalog.py
71
72
73
def list(self, **params: Any) -> PaginatedList[Genre]:
    """All genres (``GET /genre``)."""
    return self._paginated("genre", params=params or None)

ChartResource

Bases: Resource

Charts — https://developers.deezer.com/api/chart.

Note: /chart and /chart/{id} return a bundle dict with tracks/albums/artists/playlists/podcasts sub-objects (each holding data/total), not a flat list. The tracks() / albums() / ... helpers below therefore fetch the bundle once and return the corresponding sub-list as a :class:PaginatedList, so client.chart.tracks(limit=10) behaves like every other collection.

Source code in deezify/resources/catalog.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
class ChartResource(Resource):
    """Charts — https://developers.deezer.com/api/chart.

    Note: ``/chart`` and ``/chart/{id}`` return a *bundle* dict with
    ``tracks``/``albums``/``artists``/``playlists``/``podcasts`` sub-objects
    (each holding ``data``/``total``), not a flat list. The ``tracks()`` /
    ``albums()`` / ... helpers below therefore fetch the bundle once and
    return the corresponding sub-list as a :class:`PaginatedList`, so
    ``client.chart.tracks(limit=10)`` behaves like every other collection.
    """

    def get(self, chart_id: int = 0, **params: Any) -> Chart:
        """Global chart bundle (``GET /chart``) or genre bundle
        (``GET /chart/{id}``)."""
        path = "chart" if not chart_id else f"chart/{chart_id}"
        return self._get(path, params=params or None)

    def _sublist(
        self, chart_id: int, name: str, *, index: int | None, limit: int | None
    ) -> Any:
        import inspect

        path = "chart" if not chart_id else f"chart/{chart_id}"
        bundle = self._get(path, params=self._page(None, index, limit) or None)
        if inspect.isawaitable(bundle):
            return self._asublist(bundle, path, name, index=index, limit=limit)
        if isinstance(bundle, dict) and isinstance(bundle.get(name), dict):
            return PaginatedList(bundle[name])
        # Fallback: some deployments expose /chart/<kind> list endpoints.
        kind_path = f"{path}/{name}"
        try:
            return self._paginated(kind_path, params=self._page(None, index, limit))
        except Exception:
            return PaginatedList(bundle.get(name, []) if isinstance(bundle, dict) else [])

    async def _asublist(
        self, bundle: Any, path: str, name: str, *, index: int | None, limit: int | None
    ) -> PaginatedList[Any]:
        import inspect

        if inspect.isawaitable(bundle):
            bundle = await bundle
        if isinstance(bundle, dict) and isinstance(bundle.get(name), dict):
            return PaginatedList(bundle[name])
        kind_path = f"{path}/{name}"
        try:
            result = self._paginated(kind_path, params=self._page(None, index, limit))
            return await result if inspect.isawaitable(result) else result
        except Exception:
            return PaginatedList(bundle.get(name, []) if isinstance(bundle, dict) else [])

    def tracks(
        self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[ChartTrack]:
        """Top tracks (from the chart bundle's ``tracks`` sub-list)."""
        return self._sublist(chart_id, "tracks", index=index, limit=limit)

    def albums(
        self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Album]:
        """Top albums (from the chart bundle's ``albums`` sub-list)."""
        return self._sublist(chart_id, "albums", index=index, limit=limit)

    def artists(
        self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Artist]:
        """Top artists (from the chart bundle's ``artists`` sub-list)."""
        return self._sublist(chart_id, "artists", index=index, limit=limit)

    def playlists(
        self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Playlist]:
        """Top playlists (from the chart bundle's ``playlists`` sub-list)."""
        return self._sublist(chart_id, "playlists", index=index, limit=limit)

    def podcasts(
        self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Podcast]:
        """Top podcasts (from the chart bundle's ``podcasts`` sub-list)."""
        return self._sublist(chart_id, "podcasts", index=index, limit=limit)

get(chart_id=0, **params)

Global chart bundle (GET /chart) or genre bundle (GET /chart/{id}).

Source code in deezify/resources/catalog.py
108
109
110
111
112
def get(self, chart_id: int = 0, **params: Any) -> Chart:
    """Global chart bundle (``GET /chart``) or genre bundle
    (``GET /chart/{id}``)."""
    path = "chart" if not chart_id else f"chart/{chart_id}"
    return self._get(path, params=params or None)

tracks(chart_id=0, *, index=None, limit=None)

Top tracks (from the chart bundle's tracks sub-list).

Source code in deezify/resources/catalog.py
148
149
150
151
152
def tracks(
    self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[ChartTrack]:
    """Top tracks (from the chart bundle's ``tracks`` sub-list)."""
    return self._sublist(chart_id, "tracks", index=index, limit=limit)

albums(chart_id=0, *, index=None, limit=None)

Top albums (from the chart bundle's albums sub-list).

Source code in deezify/resources/catalog.py
154
155
156
157
158
def albums(
    self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Album]:
    """Top albums (from the chart bundle's ``albums`` sub-list)."""
    return self._sublist(chart_id, "albums", index=index, limit=limit)

artists(chart_id=0, *, index=None, limit=None)

Top artists (from the chart bundle's artists sub-list).

Source code in deezify/resources/catalog.py
160
161
162
163
164
def artists(
    self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Artist]:
    """Top artists (from the chart bundle's ``artists`` sub-list)."""
    return self._sublist(chart_id, "artists", index=index, limit=limit)

playlists(chart_id=0, *, index=None, limit=None)

Top playlists (from the chart bundle's playlists sub-list).

Source code in deezify/resources/catalog.py
166
167
168
169
170
def playlists(
    self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Playlist]:
    """Top playlists (from the chart bundle's ``playlists`` sub-list)."""
    return self._sublist(chart_id, "playlists", index=index, limit=limit)

podcasts(chart_id=0, *, index=None, limit=None)

Top podcasts (from the chart bundle's podcasts sub-list).

Source code in deezify/resources/catalog.py
172
173
174
175
176
def podcasts(
    self, chart_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Podcast]:
    """Top podcasts (from the chart bundle's ``podcasts`` sub-list)."""
    return self._sublist(chart_id, "podcasts", index=index, limit=limit)

EditorialResource

Bases: Resource

Editorial picks — https://developers.deezer.com/api/editorial.

Source code in deezify/resources/catalog.py
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
class EditorialResource(Resource):
    """Editorial picks — https://developers.deezer.com/api/editorial."""

    def get(self, editorial_id: int = 0, **params: Any) -> Editorial:
        path = "editorial" if not editorial_id else f"editorial/{editorial_id}"
        return self._get(path, params=params or None)

    def list(self, **params: Any) -> PaginatedList[Editorial]:
        """All editorial choices (``GET /editorial``)."""
        return self._paginated("editorial", params=params or None)

    def selection(
        self, editorial_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Album]:
        path = (
            "editorial/selection"
            if not editorial_id
            else f"editorial/{editorial_id}/selection"
        )
        return self._paginated(path, params=self._page(None, index, limit))

    def charts(
        self, editorial_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> EditorialCharts:
        """Top track/album/artist/playlist bundle for an editorial."""
        path = (
            "editorial/charts" if not editorial_id else f"editorial/{editorial_id}/charts"
        )
        return self._get(path, params=self._page(None, index, limit) or None)

    def releases(
        self, editorial_id: int = 0, *, index: int | None = None, limit: int | None = None
    ) -> PaginatedList[Album]:
        """New releases per genre (``GET /editorial/{id}/releases``)."""
        path = (
            "editorial/releases"
            if not editorial_id
            else f"editorial/{editorial_id}/releases"
        )
        return self._paginated(path, params=self._page(None, index, limit))

list(**params)

All editorial choices (GET /editorial).

Source code in deezify/resources/catalog.py
186
187
188
def list(self, **params: Any) -> PaginatedList[Editorial]:
    """All editorial choices (``GET /editorial``)."""
    return self._paginated("editorial", params=params or None)

charts(editorial_id=0, *, index=None, limit=None)

Top track/album/artist/playlist bundle for an editorial.

Source code in deezify/resources/catalog.py
200
201
202
203
204
205
206
207
def charts(
    self, editorial_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> EditorialCharts:
    """Top track/album/artist/playlist bundle for an editorial."""
    path = (
        "editorial/charts" if not editorial_id else f"editorial/{editorial_id}/charts"
    )
    return self._get(path, params=self._page(None, index, limit) or None)

releases(editorial_id=0, *, index=None, limit=None)

New releases per genre (GET /editorial/{id}/releases).

Source code in deezify/resources/catalog.py
209
210
211
212
213
214
215
216
217
218
def releases(
    self, editorial_id: int = 0, *, index: int | None = None, limit: int | None = None
) -> PaginatedList[Album]:
    """New releases per genre (``GET /editorial/{id}/releases``)."""
    path = (
        "editorial/releases"
        if not editorial_id
        else f"editorial/{editorial_id}/releases"
    )
    return self._paginated(path, params=self._page(None, index, limit))

InfosResource

Bases: Resource

Country/API information — https://developers.deezer.com/api/infos.

Source code in deezify/resources/catalog.py
221
222
223
224
225
class InfosResource(Resource):
    """Country/API information — https://developers.deezer.com/api/infos."""

    def get(self, **params: Any) -> Infos:
        return self._get("infos", params=params or None)

OptionsResource

Bases: Resource

Current-user streaming options — https://developers.deezer.com/api/options.

Source code in deezify/resources/catalog.py
228
229
230
231
232
class OptionsResource(Resource):
    """Current-user streaming options — https://developers.deezer.com/api/options."""

    def get(self, **params: Any) -> Options:
        return self._get("options", params=params or None)

deezify.resources.oembed

oEmbed resource — https://developers.deezer.com/api/oembed.

OEmbedResource

Bases: Resource

Embedded-player metadata for public Deezer URLs.

Compatible URLs: deezer.com album / episode / playlist / show / track pages and deezer.page.link short links.

Source code in deezify/resources/oembed.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class OEmbedResource(Resource):
    """Embedded-player metadata for public Deezer URLs.

    Compatible URLs: ``deezer.com`` album / episode / playlist / show /
    track pages and ``deezer.page.link`` short links.
    """

    def get(
        self,
        url: str,
        *,
        maxwidth: int | None = None,
        maxheight: int | None = None,
        autoplay: bool | None = None,
        radius: bool | None = None,
        tracklist: bool | None = None,
        format: str | OEmbedFormat = "json",  # noqa: A002 - mirrors the API param name
    ) -> OEmbed:
        """Fetch the oEmbed document (``GET /oembed?url=...``)."""
        if not url or not url.strip():
            raise ValueError("url must be a non-empty Deezer URL")
        fmt = OEmbedFormat.coerce(format, label="format")
        params: dict[str, Any] = {"url": url, "format": fmt}
        if maxwidth is not None:
            params["maxwidth"] = maxwidth
        if maxheight is not None:
            params["maxheight"] = maxheight
        if autoplay is not None:
            params["autoplay"] = str(bool(autoplay)).lower()
        if radius is not None:
            params["radius"] = str(bool(radius)).lower()
        if tracklist is not None:
            params["tracklist"] = str(bool(tracklist)).lower()
        result = self._get("oembed", params=params)
        if fmt == "xml":
            from ..errors import DeezerTransportError

            raise DeezerTransportError(
                "oEmbed format='xml' is not decoded by this SDK; use format='json'"
            )
        return result

get(url, *, maxwidth=None, maxheight=None, autoplay=None, radius=None, tracklist=None, format='json')

Fetch the oEmbed document (GET /oembed?url=...).

Source code in deezify/resources/oembed.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def get(
    self,
    url: str,
    *,
    maxwidth: int | None = None,
    maxheight: int | None = None,
    autoplay: bool | None = None,
    radius: bool | None = None,
    tracklist: bool | None = None,
    format: str | OEmbedFormat = "json",  # noqa: A002 - mirrors the API param name
) -> OEmbed:
    """Fetch the oEmbed document (``GET /oembed?url=...``)."""
    if not url or not url.strip():
        raise ValueError("url must be a non-empty Deezer URL")
    fmt = OEmbedFormat.coerce(format, label="format")
    params: dict[str, Any] = {"url": url, "format": fmt}
    if maxwidth is not None:
        params["maxwidth"] = maxwidth
    if maxheight is not None:
        params["maxheight"] = maxheight
    if autoplay is not None:
        params["autoplay"] = str(bool(autoplay)).lower()
    if radius is not None:
        params["radius"] = str(bool(radius)).lower()
    if tracklist is not None:
        params["tracklist"] = str(bool(tracklist)).lower()
    result = self._get("oembed", params=params)
    if fmt == "xml":
        from ..errors import DeezerTransportError

        raise DeezerTransportError(
            "oEmbed format='xml' is not decoded by this SDK; use format='json'"
        )
    return result