Package com.adamratzman.spotify

Types

AuthorizationType
Link copied to clipboard
common
enum AuthorizationType : Enum<AuthorizationType>
The type of Spotify authorization used to build an Api instance
GenericSpotifyApi
Link copied to clipboard
common
typealias GenericSpotifyApi = SpotifyApi<*, *>

Represents a generic instance of the Spotify API client, with common functionality and information between implementations of the API

ISpotifyApiBuilder
Link copied to clipboard
common
interface ISpotifyApiBuilder<T : SpotifyApi<T, B>, B : ISpotifyApiBuilder<T, B>>
Spotify Api builder interface
ISpotifyAppApiBuilder
Link copied to clipboard
common
App Api builder interface
ISpotifyClientApiBuilder
Link copied to clipboard
common
Client interface exposing getAuthorizationUrl
SpotifyApi
Link copied to clipboard
common
sealed class SpotifyApi<T : SpotifyApi<T, B>, B : ISpotifyApiBuilder<T, B>>
Represents an instance of the Spotify API client, with common functionality and information between the SpotifyClientApi and SpotifyAppApi implementations of the API
SpotifyApiBuilder
Link copied to clipboard
common
class SpotifyApiBuilder(clientId: String?, clientSecret: String?, redirectUri: String?)
Spotify API builder
SpotifyApiOptions
Link copied to clipboard
common
data class SpotifyApiOptions(useCache: Boolean, cacheLimit: Int?, automaticRefresh: Boolean, retryWhenRateLimited: Boolean, enableLogger: Boolean, testTokenValidity: Boolean, defaultLimit: Int, allowBulkRequests: Boolean, requestTimeoutMillis: Long?, json: Json, refreshTokenProducer: suspend (GenericSpotifyApi) -> Token?, onTokenRefresh: suspend (GenericSpotifyApi) -> Unit?, requiredScopes: List<SpotifyScope>?, proxyBaseUrl: String?, retryOnInternalServerErrorTimes: Int?, enableDebugMode: Boolean, afterTokenRefresh: suspend (GenericSpotifyApi) -> Unit?)
API Utilities
SpotifyAppApi
Link copied to clipboard
common
class SpotifyAppApi : SpotifyApi<SpotifyAppApi, SpotifyAppApiBuilder>
An API instance created with application credentials, not through client authentication
SpotifyAppApiBuilder
Link copied to clipboard
common
class SpotifyAppApiBuilder(credentials: SpotifyCredentials, authorization: SpotifyUserAuthorization, options: SpotifyApiOptions) : ISpotifyAppApiBuilder
SpotifyAppApi builder for api creation using client authorization
SpotifyClientApi
Link copied to clipboard
common
open class SpotifyClientApi(clientId: String?, clientSecret: String?, redirectUri: String?, token: Token, usesPkceAuth: Boolean, enableDefaultTokenRefreshProducerIfNoneExists: Boolean, spotifyApiOptions: SpotifyApiOptions) : SpotifyApi<SpotifyClientApi, SpotifyClientApiBuilder>
An API instance created through client authentication, with access to private information managed through the scopes exposed in token
SpotifyClientApiBuilder
Link copied to clipboard
common
class SpotifyClientApiBuilder(credentials: SpotifyCredentials, authorization: SpotifyUserAuthorization, options: SpotifyApiOptions, usesPkceAuth: Boolean?) : ISpotifyClientApiBuilder
SpotifyClientApi builder for api creation using client authorization
SpotifyCredentials
Link copied to clipboard
common
class SpotifyCredentials
A holder for application-specific credentials
SpotifyException
Link copied to clipboard
common
sealed class SpotifyException : Exception
SpotifyImplicitGrantApi
Link copied to clipboard
common
class SpotifyImplicitGrantApi(clientId: String?, token: Token, spotifyApiOptions: SpotifyApiOptions) : SpotifyClientApi
An API instance created through implicit grant flow, with access to private information managed through the scopes exposed in token.
SpotifyScope
Link copied to clipboard
common
enum SpotifyScope : Enum<SpotifyScope>
Scopes provide Spotify users using third-party apps the confidence that only the information they choose to share will be shared, and nothing more.
SpotifyUserAuthorization
Link copied to clipboard
common
class SpotifyUserAuthorization(authorizationCode: String?, tokenString: String?, token: Token?, refreshTokenString: String?, pkceCodeVerifier: String?)
User-defined authorization parameters

Functions

getSpotifyAuthorizationUrl
Link copied to clipboard
common
fun getSpotifyAuthorizationUrl(vararg scopes: SpotifyScope, clientId: String, redirectUri: String, isImplicitGrantFlow: Boolean = false, shouldShowDialog: Boolean = false, state: String? = null): String
Get the authorization url for the provided clientId and redirectUri application settings, when attempting to authorize with specified scopes
getSpotifyPkceAuthorizationUrl
Link copied to clipboard
common
fun getSpotifyPkceAuthorizationUrl(vararg scopes: SpotifyScope, clientId: String, redirectUri: String, codeChallenge: String, state: String? = null): String
Get the PKCE authorization url for the provided clientId and redirectUri application settings, when attempting to authorize with specified scopes
getSpotifyPkceCodeChallenge
Link copied to clipboard
common
fun getSpotifyPkceCodeChallenge(codeVerifier: String): String
A utility to get the pkce code challenge for a corresponding code verifier.
refreshSpotifyClientToken
Link copied to clipboard
common
suspend fun refreshSpotifyClientToken(clientId: String, clientSecret: String?, refreshToken: String?, usesPkceAuth: Boolean): Token
Refresh a Spotify client token
spotifyAppApi
Link copied to clipboard
common
fun spotifyAppApi(block: SpotifyAppApiBuilder.() -> Unit): SpotifyAppApiBuilder
Instantiate a new SpotifyAppApiBuilder by providing a builder initialization block.
fun spotifyAppApi(clientId: String, clientSecret: String): SpotifyAppApiBuilder
Instantiate a new SpotifyAppApiBuilder using a Spotify clientId and clientSecret.
fun spotifyAppApi(clientId: String, clientSecret: String, block: SpotifyAppApiBuilder.() -> Unit = {}): SpotifyAppApiBuilder
Instantiate a new SpotifyAppApiBuilder using a Spotify clientId and clientSecret, with the ability to configure the api settings by providing a builder initialization blockUse case: I am using the client credentials flow.
fun spotifyAppApi(clientId: String?, clientSecret: String?, authorization: SpotifyUserAuthorization, block: SpotifyApiOptions.() -> Unit = {}): SpotifyAppApiBuilder
Instantiate a new SpotifyAppApiBuilder using a TokenUse case: I am using the client credentials flow.
fun spotifyAppApi(clientId: String?, clientSecret: String?, token: Token, block: SpotifyApiOptions.() -> Unit = {}): SpotifyAppApiBuilder
Instantiate a new SpotifyAppApiBuilder using a TokenUse case: I am using the client credentials flow.
spotifyClientApi
Link copied to clipboard
common
fun spotifyClientApi(block: SpotifyClientApiBuilder.() -> Unit): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder by providing a builder initialization blockNote: If trying to build SpotifyClientApi, you must provide client authorization in the SpotifyClientApiBuilder.authorization blockUse case: I am using the client authorization flow.
fun spotifyClientApi(clientId: String, clientSecret: String, redirectUri: String): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder using a Spotify clientId, clientSecret, and redirectUri.
fun spotifyClientApi(clientId: String, clientSecret: String, redirectUri: String, block: SpotifyClientApiBuilder.() -> Unit): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder using a Spotify clientId, clientSecret, and redirectUri, with the ability to configure the api settings by providing a builder initialization blockNote: If trying to build SpotifyClientApi, you must provide client authorization in the SpotifyClientApiBuilder.authorization blockUse case: I am using the client authorization flow.
fun spotifyClientApi(clientId: String?, clientSecret: String?, redirectUri: String?, authorization: SpotifyUserAuthorization, block: SpotifyApiOptions.() -> Unit = {}): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder using a Spotify clientId, clientSecret, and redirectUri, with an existing SpotifyUserAuthorization.
fun spotifyClientApi(clientId: String?, clientSecret: String?, redirectUri: String?, token: Token, block: SpotifyApiOptions.() -> Unit = {}): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder using a Spotify clientId, clientSecret, and redirectUri, with an existing SpotifyUserAuthorization.
spotifyClientPkceApi
Link copied to clipboard
common
fun spotifyClientPkceApi(clientId: String?, redirectUri: String?, authorization: SpotifyUserAuthorization, block: SpotifyApiOptions.() -> Unit = {}): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder.
fun spotifyClientPkceApi(clientId: String?, redirectUri: String?, token: Token, block: SpotifyApiOptions.() -> Unit = {}): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder.
fun spotifyClientPkceApi(clientId: String?, redirectUri: String?, authorizationCode: String, pkceCodeVerifier: String): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder.
fun spotifyClientPkceApi(clientId: String?, redirectUri: String?, authorizationCode: String, pkceCodeVerifier: String, block: SpotifyApiOptions.() -> Unit): SpotifyClientApiBuilder
Instantiate a new SpotifyClientApiBuilder.
spotifyImplicitGrantApi
Link copied to clipboard
common
fun spotifyImplicitGrantApi(clientId: String?, token: Token): SpotifyImplicitGrantApi
Instantiate a new SpotifyImplicitGrantApi using a Spotify clientId, and token retrieved from the implicit grant flow.
fun spotifyImplicitGrantApi(clientId: String?, token: Token, block: SpotifyApiOptions.() -> Unit): SpotifyImplicitGrantApi
Instantiate a new SpotifyImplicitGrantApi using a Spotify clientId, and token retrieved from the implicit grant flow.