pub trait BaseClient
where Self: Send + Sync + Default + Clone + Debug,
{
Show 49 methods // Required methods fn get_config(&self) -> &Config; fn get_http(&self) -> &HttpClient; fn get_creds(&self) -> &Credentials; fn get_token(&self) -> Arc<Mutex<Option<Token>>>; fn refetch_token(&self) -> ClientResult<Option<Token>>; // Provided methods fn api_url(&self, url: &str) -> String { ... } fn auth_url(&self, url: &str) -> String { ... } fn auto_reauth(&self) -> ClientResult<()> { ... } fn refresh_token(&self) -> ClientResult<()> { ... } fn write_token_cache(&self) -> ClientResult<()> { ... } fn fetch_access_token( &self, payload: &Form<'_>, headers: Option<&Headers> ) -> ClientResult<Token> { ... } fn track( &self, track_id: TrackId<'_>, market: Option<Market> ) -> ClientResult<FullTrack> { ... } fn tracks<'a>( &self, track_ids: impl IntoIterator<Item = TrackId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullTrack>> { ... } fn artist(&self, artist_id: ArtistId<'_>) -> ClientResult<FullArtist> { ... } fn artists<'a>( &self, artist_ids: impl IntoIterator<Item = ArtistId<'a>> + Send + 'a ) -> ClientResult<Vec<FullArtist>> { ... } fn artist_albums<'a>( &'a self, artist_id: ArtistId<'a>, include_groups: impl IntoIterator<Item = AlbumType> + Send + Copy + 'a, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedAlbum>> { ... } fn artist_albums_manual<'a>( &self, artist_id: ArtistId<'_>, include_groups: impl IntoIterator<Item = AlbumType> + Send + 'a, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedAlbum>> { ... } fn artist_top_tracks( &self, artist_id: ArtistId<'_>, market: Option<Market> ) -> ClientResult<Vec<FullTrack>> { ... } fn artist_related_artists( &self, artist_id: ArtistId<'_> ) -> ClientResult<Vec<FullArtist>> { ... } fn album( &self, album_id: AlbumId<'_>, market: Option<Market> ) -> ClientResult<FullAlbum> { ... } fn albums<'a>( &self, album_ids: impl IntoIterator<Item = AlbumId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullAlbum>> { ... } fn search( &self, q: &str, _type: SearchType, market: Option<Market>, include_external: Option<IncludeExternal>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<SearchResult> { ... } fn album_track<'a>( &'a self, album_id: AlbumId<'a>, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedTrack>> { ... } fn album_track_manual( &self, album_id: AlbumId<'_>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedTrack>> { ... } fn user(&self, user_id: UserId<'_>) -> ClientResult<PublicUser> { ... } fn playlist( &self, playlist_id: PlaylistId<'_>, fields: Option<&str>, market: Option<Market> ) -> ClientResult<FullPlaylist> { ... } fn user_playlist( &self, user_id: UserId<'_>, playlist_id: Option<PlaylistId<'_>>, fields: Option<&str> ) -> ClientResult<FullPlaylist> { ... } fn playlist_check_follow( &self, playlist_id: PlaylistId<'_>, user_ids: &[UserId<'_>] ) -> ClientResult<Vec<bool>> { ... } fn get_a_show( &self, id: ShowId<'_>, market: Option<Market> ) -> ClientResult<FullShow> { ... } fn get_several_shows<'a>( &self, ids: impl IntoIterator<Item = ShowId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<SimplifiedShow>> { ... } fn get_shows_episodes<'a>( &'a self, id: ShowId<'a>, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedEpisode>> { ... } fn get_shows_episodes_manual( &self, id: ShowId<'_>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedEpisode>> { ... } fn get_an_episode( &self, id: EpisodeId<'_>, market: Option<Market> ) -> ClientResult<FullEpisode> { ... } fn get_several_episodes<'a>( &self, ids: impl IntoIterator<Item = EpisodeId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullEpisode>> { ... } fn track_features( &self, track_id: TrackId<'_> ) -> ClientResult<AudioFeatures> { ... } fn tracks_features<'a>( &self, track_ids: impl IntoIterator<Item = TrackId<'a>> + Send + 'a ) -> ClientResult<Option<Vec<AudioFeatures>>> { ... } fn track_analysis( &self, track_id: TrackId<'_> ) -> ClientResult<AudioAnalysis> { ... } fn categories<'a>( &'a self, locale: Option<&'a str>, country: Option<Market> ) -> Paginator<'_, ClientResult<Category>> { ... } fn categories_manual( &self, locale: Option<&str>, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<Category>> { ... } fn category_playlists<'a>( &'a self, category_id: &'a str, country: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedPlaylist>> { ... } fn category_playlists_manual( &self, category_id: &str, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedPlaylist>> { ... } fn featured_playlists( &self, locale: Option<&str>, country: Option<Market>, timestamp: Option<DateTime<Utc>>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<FeaturedPlaylists> { ... } fn new_releases( &self, country: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedAlbum>> { ... } fn new_releases_manual( &self, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedAlbum>> { ... } fn recommendations<'a>( &self, attributes: impl IntoIterator<Item = RecommendationsAttribute> + Send + 'a, seed_artists: Option<impl IntoIterator<Item = ArtistId<'a>> + Send + 'a>, seed_genres: Option<impl IntoIterator<Item = &'a str> + Send + 'a>, seed_tracks: Option<impl IntoIterator<Item = TrackId<'a>> + Send + 'a>, market: Option<Market>, limit: Option<u32> ) -> ClientResult<Recommendations> { ... } fn playlist_items<'a>( &'a self, playlist_id: PlaylistId<'a>, fields: Option<&'a str>, market: Option<Market> ) -> Paginator<'_, ClientResult<PlaylistItem>> { ... } fn playlist_items_manual( &self, playlist_id: PlaylistId<'_>, fields: Option<&str>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<PlaylistItem>> { ... } fn user_playlists<'a>( &'a self, user_id: UserId<'a> ) -> Paginator<'_, ClientResult<SimplifiedPlaylist>> { ... } fn user_playlists_manual( &self, user_id: UserId<'_>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedPlaylist>> { ... }
}
Expand description

This trait implements the basic endpoints from the Spotify API that may be accessed without user authorization, including parts of the authentication flow that are shared, and the endpoints.

Required Methods§

source

fn get_config(&self) -> &Config

source

fn get_http(&self) -> &HttpClient

source

fn get_creds(&self) -> &Credentials

source

fn get_token(&self) -> Arc<Mutex<Option<Token>>>

Note that the token is wrapped by a Mutex in order to allow interior mutability. This is required so that the entire client doesn’t have to be mutable (the token is accessed to from every endpoint).

source

fn refetch_token(&self) -> ClientResult<Option<Token>>

Refetch the current access token given a refresh token.

Provided Methods§

source

fn api_url(&self, url: &str) -> String

Returns the absolute URL for an endpoint in the API.

source

fn auth_url(&self, url: &str) -> String

Returns the absolute URL for an authentication step in the API.

source

fn auto_reauth(&self) -> ClientResult<()>

Re-authenticate the client automatically if it’s configured to do so, which uses the refresh token to obtain a new access token.

source

fn refresh_token(&self) -> ClientResult<()>

Refreshes the current access token given a refresh token. The obtained token will be saved internally.

source

fn write_token_cache(&self) -> ClientResult<()>

Updates the cache file at the internal cache path.

This should be used whenever it’s possible to, even if the cached token isn’t configured, because this will already check Config::token_cached and do nothing in that case already.

source

fn fetch_access_token( &self, payload: &Form<'_>, headers: Option<&Headers> ) -> ClientResult<Token>

Sends a request to Spotify for an access token.

source

fn track( &self, track_id: TrackId<'_>, market: Option<Market> ) -> ClientResult<FullTrack>

Returns a single track given the track’s ID, URI or URL.

Parameters:

  • track_id - a spotify URI, URL or ID

Reference

source

fn tracks<'a>( &self, track_ids: impl IntoIterator<Item = TrackId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullTrack>>

Returns a list of tracks given a list of track IDs, URIs, or URLs.

Parameters:

  • track_ids - a list of spotify URIs, URLs or IDs
  • market - an ISO 3166-1 alpha-2 country code or the string from_token.

Reference

source

fn artist(&self, artist_id: ArtistId<'_>) -> ClientResult<FullArtist>

Returns a single artist given the artist’s ID, URI or URL.

Parameters:

  • artist_id - an artist ID, URI or URL

Reference

source

fn artists<'a>( &self, artist_ids: impl IntoIterator<Item = ArtistId<'a>> + Send + 'a ) -> ClientResult<Vec<FullArtist>>

Returns a list of artists given the artist IDs, URIs, or URLs.

Parameters:

  • artist_ids - a list of artist IDs, URIs or URLs

Reference

source

fn artist_albums<'a>( &'a self, artist_id: ArtistId<'a>, include_groups: impl IntoIterator<Item = AlbumType> + Send + Copy + 'a, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedAlbum>>

Get Spotify catalog information about an artist’s albums.

Parameters:

  • artist_id - the artist ID, URI or URL
  • include_groups - a list of album type like ‘album’, ‘single’ that will be used to filter response. if not supplied, all album types will be returned.
  • market - limit the response to one particular country.
  • limit - the number of albums to return
  • offset - the index of the first album to return

See Self::artist_albums_manual for a manually paginated version of this.

Reference

source

fn artist_albums_manual<'a>( &self, artist_id: ArtistId<'_>, include_groups: impl IntoIterator<Item = AlbumType> + Send + 'a, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedAlbum>>

The manually paginated version of Self::artist_albums.

source

fn artist_top_tracks( &self, artist_id: ArtistId<'_>, market: Option<Market> ) -> ClientResult<Vec<FullTrack>>

Get Spotify catalog information about an artist’s top 10 tracks by country.

Parameters:

  • artist_id - the artist ID, URI or URL
  • market - limit the response to one particular country.

Reference

Get Spotify catalog information about artists similar to an identified artist. Similarity is based on analysis of the Spotify community’s listening history.

Parameters:

  • artist_id - the artist ID, URI or URL

Reference

source

fn album( &self, album_id: AlbumId<'_>, market: Option<Market> ) -> ClientResult<FullAlbum>

Returns a single album given the album’s ID, URIs or URL.

Parameters:

  • album_id - the album ID, URI or URL

Reference

source

fn albums<'a>( &self, album_ids: impl IntoIterator<Item = AlbumId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullAlbum>>

Returns a list of albums given the album IDs, URIs, or URLs.

Parameters:

  • albums_ids - a list of album IDs, URIs or URLs

Reference

source

fn search( &self, q: &str, _type: SearchType, market: Option<Market>, include_external: Option<IncludeExternal>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<SearchResult>

Search for an Item. Get Spotify catalog information about artists, albums, tracks or playlists that match a keyword string.

Parameters:

  • q - the search query
  • limit - the number of items to return
  • offset - the index of the first item to return
  • type - the type of item to return. One of ‘artist’, ‘album’, ‘track’, ‘playlist’, ‘show’ or ‘episode’
  • market - An ISO 3166-1 alpha-2 country code or the string from_token.
  • include_external: Optional.Possible values: audio. If include_external=audio is specified the response will include any relevant audio content that is hosted externally.

Reference

source

fn album_track<'a>( &'a self, album_id: AlbumId<'a>, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedTrack>>

Get Spotify catalog information about an album’s tracks.

Parameters:

  • album_id - the album ID, URI or URL
  • limit - the number of items to return
  • offset - the index of the first item to return

See Self::album_track_manual for a manually paginated version of this.

Reference

source

fn album_track_manual( &self, album_id: AlbumId<'_>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedTrack>>

The manually paginated version of Self::album_track.

source

fn user(&self, user_id: UserId<'_>) -> ClientResult<PublicUser>

Gets basic profile information about a Spotify User.

Parameters:

  • user - the id of the usr

Reference

source

fn playlist( &self, playlist_id: PlaylistId<'_>, fields: Option<&str>, market: Option<Market> ) -> ClientResult<FullPlaylist>

Get full details about Spotify playlist.

Parameters:

  • playlist_id - the id of the playlist
  • market - an ISO 3166-1 alpha-2 country code or the string from_token.

Reference

source

fn user_playlist( &self, user_id: UserId<'_>, playlist_id: Option<PlaylistId<'_>>, fields: Option<&str> ) -> ClientResult<FullPlaylist>

Gets playlist of a user.

Parameters:

  • user_id - the id of the user
  • playlist_id - the id of the playlist
  • fields - which fields to return

Reference

source

fn playlist_check_follow( &self, playlist_id: PlaylistId<'_>, user_ids: &[UserId<'_>] ) -> ClientResult<Vec<bool>>

Check to see if the given users are following the given playlist.

Parameters:

  • playlist_id - the id of the playlist
  • user_ids - the ids of the users that you want to check to see if they follow the playlist. Maximum: 5 ids.

Reference

source

fn get_a_show( &self, id: ShowId<'_>, market: Option<Market> ) -> ClientResult<FullShow>

Get Spotify catalog information for a single show identified by its unique Spotify ID.

Path Parameters:

  • id: The Spotify ID for the show.

Query Parameters

  • market(Optional): An ISO 3166-1 alpha-2 country code or the string from_token.

Reference

source

fn get_several_shows<'a>( &self, ids: impl IntoIterator<Item = ShowId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<SimplifiedShow>>

Get Spotify catalog information for multiple shows based on their Spotify IDs.

Query Parameters

  • ids(Required) A comma-separated list of the Spotify IDs for the shows. Maximum: 50 IDs.
  • market(Optional) An ISO 3166-1 alpha-2 country code or the string from_token.

Reference

source

fn get_shows_episodes<'a>( &'a self, id: ShowId<'a>, market: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedEpisode>>

Get Spotify catalog information about an show’s episodes. Optional parameters can be used to limit the number of episodes returned.

Path Parameters

  • id: The Spotify ID for the show.

Query Parameters

  • limit: Optional. The maximum number of episodes to return. Default: 20. Minimum: 1. Maximum: 50.
  • offset: Optional. The index of the first episode to return. Default: 0 (the first object). Use with limit to get the next set of episodes.
  • market: Optional. An ISO 3166-1 alpha-2 country code or the string from_token.

See Self::get_shows_episodes_manual for a manually paginated version of this.

Reference

source

fn get_shows_episodes_manual( &self, id: ShowId<'_>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedEpisode>>

The manually paginated version of Self::get_shows_episodes.

source

fn get_an_episode( &self, id: EpisodeId<'_>, market: Option<Market> ) -> ClientResult<FullEpisode>

Get Spotify catalog information for a single episode identified by its unique Spotify ID.

Path Parameters

  • id: The Spotify ID for the episode.

Query Parameters

  • market: Optional. An ISO 3166-1 alpha-2 country code or the string from_token.

Reference

source

fn get_several_episodes<'a>( &self, ids: impl IntoIterator<Item = EpisodeId<'a>> + Send + 'a, market: Option<Market> ) -> ClientResult<Vec<FullEpisode>>

Get Spotify catalog information for multiple episodes based on their Spotify IDs.

Query Parameters

  • ids: Required. A comma-separated list of the Spotify IDs for the episodes. Maximum: 50 IDs.
  • market: Optional. An ISO 3166-1 alpha-2 country code or the string from_token.

Reference

source

fn track_features(&self, track_id: TrackId<'_>) -> ClientResult<AudioFeatures>

Get audio features for a track

Parameters:

  • track - track URI, URL or ID

Reference

source

fn tracks_features<'a>( &self, track_ids: impl IntoIterator<Item = TrackId<'a>> + Send + 'a ) -> ClientResult<Option<Vec<AudioFeatures>>>

Get Audio Features for Several Tracks

Parameters:

  • tracks a list of track URIs, URLs or IDs

Reference

source

fn track_analysis(&self, track_id: TrackId<'_>) -> ClientResult<AudioAnalysis>

Get Audio Analysis for a Track

Parameters:

  • track_id - a track URI, URL or ID

Reference

source

fn categories<'a>( &'a self, locale: Option<&'a str>, country: Option<Market> ) -> Paginator<'_, ClientResult<Category>>

Get a list of new album releases featured in Spotify

Parameters:

  • country - An ISO 3166-1 alpha-2 country code or string from_token.
  • locale - The desired language, consisting of an ISO 639 language code and an ISO 3166-1 alpha-2 country code, joined by an underscore.
  • limit - The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50
  • offset - The index of the first item to return. Default: 0 (the first object). Use with limit to get the next set of items.

See Self::categories_manual for a manually paginated version of this.

Reference

source

fn categories_manual( &self, locale: Option<&str>, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<Category>>

The manually paginated version of Self::categories.

source

fn category_playlists<'a>( &'a self, category_id: &'a str, country: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedPlaylist>>

Get a list of playlists in a category in Spotify

Parameters:

  • category_id - The category id to get playlists from.
  • country - An ISO 3166-1 alpha-2 country code or the string from_token.
  • limit - The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50
  • offset - The index of the first item to return. Default: 0 (the first object). Use with limit to get the next set of items.

See Self::category_playlists_manual for a manually paginated version of this.

Reference

source

fn category_playlists_manual( &self, category_id: &str, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedPlaylist>>

The manually paginated version of Self::category_playlists.

source

fn featured_playlists( &self, locale: Option<&str>, country: Option<Market>, timestamp: Option<DateTime<Utc>>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<FeaturedPlaylists>

Get a list of Spotify featured playlists.

Parameters:

  • locale - The desired language, consisting of a lowercase ISO 639 language code and an uppercase ISO 3166-1 alpha-2 country code, joined by an underscore.
  • country - An ISO 3166-1 alpha-2 country code or the string from_token.
  • timestamp - A timestamp in ISO 8601 format: yyyy-MM-ddTHH:mm:ss. Use this parameter to specify the user’s local time to get results tailored for that specific date and time in the day
  • limit - The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50
  • offset - The index of the first item to return. Default: 0 (the first object). Use with limit to get the next set of items.

Reference

source

fn new_releases( &self, country: Option<Market> ) -> Paginator<'_, ClientResult<SimplifiedAlbum>>

Get a list of new album releases featured in Spotify.

Parameters:

  • country - An ISO 3166-1 alpha-2 country code or string from_token.
  • limit - The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 50
  • offset - The index of the first item to return. Default: 0 (the first object). Use with limit to get the next set of items.

See Self::new_releases_manual for a manually paginated version of this.

Reference

source

fn new_releases_manual( &self, country: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedAlbum>>

The manually paginated version of Self::new_releases.

source

fn recommendations<'a>( &self, attributes: impl IntoIterator<Item = RecommendationsAttribute> + Send + 'a, seed_artists: Option<impl IntoIterator<Item = ArtistId<'a>> + Send + 'a>, seed_genres: Option<impl IntoIterator<Item = &'a str> + Send + 'a>, seed_tracks: Option<impl IntoIterator<Item = TrackId<'a>> + Send + 'a>, market: Option<Market>, limit: Option<u32> ) -> ClientResult<Recommendations>

Get Recommendations Based on Seeds

Parameters:

  • attributes - restrictions on attributes for the selected tracks, such as min_acousticness or target_duration_ms.
  • seed_artists - a list of artist IDs, URIs or URLs
  • seed_tracks - a list of artist IDs, URIs or URLs
  • seed_genres - a list of genre names. Available genres for
  • market - An ISO 3166-1 alpha-2 country code or the string from_token. If provided, all results will be playable in this country.
  • limit - The maximum number of items to return. Default: 20. Minimum: 1. Maximum: 100
  • min/max/target_<attribute> - For the tuneable track attributes listed in the documentation, these values provide filters and targeting on results.

Reference

source

fn playlist_items<'a>( &'a self, playlist_id: PlaylistId<'a>, fields: Option<&'a str>, market: Option<Market> ) -> Paginator<'_, ClientResult<PlaylistItem>>

Get full details of the items of a playlist owned by a user.

Parameters:

  • playlist_id - the id of the playlist
  • fields - which fields to return
  • limit - the maximum number of tracks to return
  • offset - the index of the first track to return
  • market - an ISO 3166-1 alpha-2 country code or the string from_token.

See Self::playlist_items_manual for a manually paginated version of this.

Reference

source

fn playlist_items_manual( &self, playlist_id: PlaylistId<'_>, fields: Option<&str>, market: Option<Market>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<PlaylistItem>>

The manually paginated version of Self::playlist_items.

source

fn user_playlists<'a>( &'a self, user_id: UserId<'a> ) -> Paginator<'_, ClientResult<SimplifiedPlaylist>>

Gets playlists of a user.

Parameters:

  • user_id - the id of the usr
  • limit - the number of items to return
  • offset - the index of the first item to return

See Self::user_playlists_manual for a manually paginated version of this.

Reference

source

fn user_playlists_manual( &self, user_id: UserId<'_>, limit: Option<u32>, offset: Option<u32> ) -> ClientResult<Page<SimplifiedPlaylist>>

The manually paginated version of Self::user_playlists.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl BaseClient for AuthCodePkceSpotify

This client has access to the base methods.

source§

impl BaseClient for AuthCodeSpotify

This client has access to the base methods.

source§

impl BaseClient for ClientCredsSpotify

This client has access to the base methods.