Player
API #
Implementation to make API calls with.
Parameters:
-
access_flow(AuthorizationCodeFlow | ClientCredentialsFlow) –Access flow to use for api requests.
get_playback_state #
Get information about the user's current playback state, including track or episode, progress, and active device.
Required Authorization Scope
Parameters:
-
market(str, default:MISSING) –Only get content available in that market. Must be an ISO 3166-1 alpha-2 country code.
Returns:
-
Player–Player information.
-
None–If there is no playback state.
transfer_playback #
Transfer playback to a new device and optionally begin playback.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
get_available_devices #
Get information about a user's available Spotify Connect devices. Some device models are not supported and will not be listed in the response.
Required Authorization Scope
Returns:
get_currently_playing_track #
get_currently_playing_track(*, market: MissingOr[str] = MISSING) -> PlayerTrack | None
Get the item currently being played on the user's Spotify account.
Required Authorization Scope
Parameters:
-
market(str, default:MISSING) –Only get content available in that market. Must be an ISO 3166-1 alpha-2 country code.
Returns:
-
PlayerTrack–The currently playing item.
-
None–If nothing is playing.
start_or_resume_playback #
start_or_resume_playback(*, device_id: MissingOr[str] = MISSING, context_uri: MissingOr[str] = MISSING, track_uris: MissingOr[list[str]] = MISSING, offset: MissingOr[int | str] = MISSING, position: MissingOr[timedelta] = MISSING) -> None
Start a new context or resume current playback on the user's active device.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
-
device_id(str, default:MISSING) –The ID of the device this command is targeting. Default: currently active device.
Note
Only one of
context_uriandtrack_urismay be supplied. -
context_uri(str, default:MISSING) –URI of an album, artist or playlist to play.
-
track_uris(list[str], default:MISSING) –URIs of track(s) to play
-
offset(int | str, default:MISSING) – -
position(timedelta, default:MISSING) –The position in the (first) item at which to start playback.
pause_playback #
Pause playback on the user's account.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
skip_to_next #
Skip to the next item in the user's queue.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
skip_to_previous #
Skip to the previous item in the user's queue.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
seek_to_position #
Seeks to the given position in the user's currently playing track.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
set_repeat_mode #
set_repeat_mode(state: RepeatState, *, device_id: MissingOr[str] = MISSING) -> None
Set the repeat mode for the user's playback.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
-
state(RepeatState) –The repeat state (off/track/context).
-
device_id(str, default:MISSING) –The ID of the device this command is targeting. Default: currently active device.
set_playback_volume #
Set the volume for the user's current playback device.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
set_playback_shuffle #
Set shuffle mode for user's playback.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
get_recently_played_tracks #
get_recently_played_tracks(*, limit: MissingOr[int] = MISSING, after: MissingOr[datetime] = MISSING, before: MissingOr[datetime] = MISSING) -> CursorPaginator[PlayHistory]
Get tracks from the current user's recently played tracks, starting with the most recently played track and going backwards in history.
Required Authorization Scope
Note
Currently doesn't support podcast episodes.
Parameters:
-
limit(int, default:20) –The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50.
Note
Only one of
afterandbeforemay be provided. -
after(datetime, default:MISSING) –Return all items after (but not including) this time.
-
before(datetime, default:MISSING) –Returns all items before (but not including) this time.
get_users_queue #
get_users_queue() -> Queue
add_item_to_playback_queue #
Add an item to the end of the user's current playback queue.
Required Authorization Scope
Premium
This endpoint only works for users who have Spotify Premium.
Parameters:
Player #
Information about the user's current playback state.
timestamp #
timestamp: datetime
Time when playback state was last changed (play, pause, skip, scrub, new song, etc.).
progress #
progress: timedelta | None = Field(alias='progress_ms')
Progress into the currently playing track or episode.
currently_playing_type #
currently_playing_type: PlayingType
The type of the currently playing item.
PlayerTrack #
Information about the user's currently playing item.
timestamp #
timestamp: datetime
Time when playback state was last changed (play, pause, skip, scrub, new song, etc.).
progress #
progress: timedelta | None = Field(alias='progress_ms')
Progress into the currently playing track or episode.
currently_playing_type #
currently_playing_type: PlayingType
The type of the currently playing item.
Device #
Information about a playback device.
id #
id: str | None
The device ID. This ID is unique and persistent to some extent. However, this is not guaranteed and any cached device id should periodically be cleared out and re-fetched as necessary.
is_restricted #
is_restricted: bool
Whether controlling this device is restricted. At present if this is True then no Web API commands will be accepted by this device.
name #
name: str
A human-readable name for the device. Some devices have a name that the user can configure (e.g. "Loudest speaker") and some devices have a generic name associated with the manufacturer or device model.
PlayHistory #
Queue #
Context #
Limited information about the currently playing item.
Actions #
Actions available to control playback.