Library Endpoint Reference
Functions
- async check_user_saved_items(client: SpotanticClient, *, uris: Sequence[SpotifyItemURI]) APICallModel[CheckUserSavedItemsRequest, JsonAPIResponse, dict[SpotifyItemURI, bool]]
Check if one or more items are already saved in the current user’s library.
Accepts Spotify URIs for tracks, albums, episodes, shows, audiobooks, artists, users, and playlists.
- Parameters:
client –
SpotanticClientinstance.uris – A list of Spotify URIs for the items to check.
- Returns:
An object containing the request used to obtain the response, the retrieved data and parsed data as model.
- async remove_items_from_library(client: SpotanticClient, *, uris: Sequence[SpotifyItemURI]) APICallModel[RemoveItemsFromLibraryRequest, RawAPIResponse, NoneType]
Remove one or more items from the current user’s library.
Accepts Spotify URIs for tracks, albums, episodes, shows, audiobooks, users, and playlists.
- Parameters:
client –
SpotanticClientinstance.uris – A list of Spotify URIs for the items to be removed from the user’s library.
- Returns:
An object containing the request used to obtain the response and the response.
- async save_items_to_library(client: SpotanticClient, *, uris: Sequence[SpotifyItemURI]) APICallModel[SaveItemsToLibraryRequest, RawAPIResponse, NoneType]
Add one or more items to the current user’s library.
Accepts Spotify URIs for tracks, albums, episodes, shows, audiobooks, users, and playlists.
- Parameters:
client –
SpotanticClientinstance.uris – A list of the Spotify URIs for the items to be saved to the user’s library.
- Returns:
An object containing the request used to obtain the response and the response.
Request models
- class CheckUserSavedItemsRequest(*, required_scopes: set[AuthScope] = {AuthScope.PLAYLIST_READ_PRIVATE, AuthScope.USER_FOLLOW_READ, AuthScope.USER_LIBRARY_READ}, url: HttpUrl | None = None, endpoint: str | None = 'me/library/contains', method_type: HTTPMethod = <HTTPMethod.GET>, headers: RequestHeadersModel = <factory>, params: CheckUserSavedItemsRequestParams | None = None, body: None = None)
Bases:
RequestModel[CheckUserSavedItemsRequestParams, NoneType]Request model for Check User Saved Items endpoint.
- classmethod build(*, uris: Sequence[SpotifyItemURI]) CheckUserSavedItemsRequest
Builds a request model based on given parameters.
The function automatically determines the endpoint if it is not static. Also, it automatically assigns parameters to request query or body.
- Parameters:
uris – A list of Spotify URIs for the items to check.
- Returns:
Validated Request object.
- method_type: HTTPMethod
HTTP method for the request.
- class CheckUserSavedItemsRequestParams(*, uris: Annotated[Sequence[SpotifyItemURI], MaxLen(max_length=40), PlainSerializer(func=sequence_to_comma_separated_str, return_type=str, when_used=always)])
Bases:
BaseModelParams model for Check User Saved Items request.
- uris: Annotated[Sequence[SpotifyItemURI], Field(max_length=40), PlainSerializer(sequence_to_comma_separated_str, return_type=str)]
A list of Spotify URIs for the items to check.
- class RemoveItemsFromLibraryRequest(*, required_scopes: set[AuthScope] = {AuthScope.PLAYLIST_MODIFY_PUBLIC, AuthScope.USER_FOLLOW_MODIFY, AuthScope.USER_LIBRARY_MODIFY}, url: HttpUrl | None = None, endpoint: str | None = 'me/library', method_type: HTTPMethod = <HTTPMethod.DELETE>, headers: RequestHeadersModel = <factory>, params: RemoveItemsFromLibraryRequestParams | None = None, body: None = None)
Bases:
RequestModel[RemoveItemsFromLibraryRequestParams, NoneType]Request model for Remove Items From Library endpoint.
- classmethod build(*, uris: Sequence[SpotifyItemURI]) RemoveItemsFromLibraryRequest
Builds a request model based on given parameters.
The function automatically determines the endpoint if it is not static. Also, it automatically assigns parameters to request query or body.
- Parameters:
uris – A list of Spotify URIs for the items to be removed from the user’s library.
- Returns:
Validated Request object.
- method_type: HTTPMethod
HTTP method for the request.
- class RemoveItemsFromLibraryRequestParams(*, uris: Annotated[Sequence[SpotifyItemURI], MaxLen(max_length=40), PlainSerializer(func=sequence_to_comma_separated_str, return_type=str, when_used=always)])
Bases:
BaseModelParams model for Remove Items From Library request.
- uris: Annotated[Sequence[SpotifyItemURI], Field(max_length=40), PlainSerializer(sequence_to_comma_separated_str, return_type=str)]
A list of Spotify URIs for the items to be removed from the user’s library.
- class SaveItemsToLibraryRequest(*, required_scopes: set[AuthScope] = {AuthScope.PLAYLIST_MODIFY_PUBLIC, AuthScope.USER_FOLLOW_MODIFY, AuthScope.USER_LIBRARY_MODIFY}, url: HttpUrl | None = None, endpoint: str | None = 'me/library', method_type: HTTPMethod = <HTTPMethod.PUT>, headers: RequestHeadersModel = <factory>, params: SaveItemsToLibraryRequestParams | None = None, body: None = None)
Bases:
RequestModel[SaveItemsToLibraryRequestParams, NoneType]Request model for Save Items to Library endpoint.
- classmethod build(*, uris: Sequence[SpotifyItemURI]) SaveItemsToLibraryRequest
Builds a request model based on given parameters.
The function automatically determines the endpoint if it is not static. Also, it automatically assigns parameters to request query or body.
- Parameters:
uris – A list of the Spotify URIs for the items to be saved to the user’s library.
- Returns:
Validated Request object.
- method_type: HTTPMethod
HTTP method for the request.
- class SaveItemsToLibraryRequestParams(*, uris: Annotated[Sequence[SpotifyItemURI], MaxLen(max_length=40), PlainSerializer(func=sequence_to_comma_separated_str, return_type=str, when_used=always)])
Bases:
BaseModelParams model for Save Items to Library request.
- uris: Annotated[Sequence[SpotifyItemURI], Field(max_length=40), PlainSerializer(sequence_to_comma_separated_str, return_type=str)]
A list of the Spotify URIs for the items to be saved to the user’s library.