Package-level declarations

Types

Link copied to clipboard

The type of Spotify authorization used to build an Api instance

Link copied to clipboard
typealias GenericSpotifyApi = SpotifyApi<*, *>

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

Link copied to clipboard

Spotify Api builder interface

Link copied to clipboard
Link copied to clipboard
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

Link copied to clipboard
class SpotifyApiBuilder(clientId: String?, clientSecret: String?, redirectUri: String?)

Spotify API builder

Link copied to clipboard
data class SpotifyApiOptions(var useCache: Boolean = true, var cacheLimit: Int? = 200, var automaticRefresh: Boolean = true, var retryWhenRateLimited: Boolean = true, var testTokenValidity: Boolean = false, var defaultLimit: Int = 50, var allowBulkRequests: Boolean = true, var requestTimeoutMillis: Long? = null, var json: Json = nonstrictJson, var refreshTokenProducer: suspend (GenericSpotifyApi) -> Token? = null, var onTokenRefresh: suspend (GenericSpotifyApi) -> Unit? = null, var requiredScopes: List<SpotifyScope>? = null, var proxyBaseUrl: String? = null, var retryOnInternalServerErrorTimes: Int? = 5, var enableDebugMode: Boolean = false, var httpResponseSubscriber: suspend (request: HttpRequest, response: HttpResponse) -> Unit? = null, var afterTokenRefresh: suspend (GenericSpotifyApi) -> Unit? = null)

API Utilities

Link copied to clipboard

An API instance created with application credentials, not through client authentication

Link copied to clipboard
class SpotifyAppApiBuilder(var credentials: SpotifyCredentials = SpotifyCredentials(), var authorization: SpotifyUserAuthorization = SpotifyUserAuthorization(), var options: SpotifyApiOptions = SpotifyApiOptions()) : ISpotifyAppApiBuilder

SpotifyAppApi builder for api creation using client authorization

Link copied to clipboard
open class SpotifyClientApi(clientId: String?, clientSecret: String?, var redirectUri: String?, token: Token, val 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

Link copied to clipboard
class SpotifyClientApiBuilder(var credentials: SpotifyCredentials = SpotifyCredentials(), var authorization: SpotifyUserAuthorization = SpotifyUserAuthorization(), var options: SpotifyApiOptions = SpotifyApiOptions(), var usesPkceAuth: Boolean? = null) : ISpotifyClientApiBuilder

SpotifyClientApi builder for api creation using client authorization

Link copied to clipboard

A holder for application-specific credentials

Link copied to clipboard
Link copied to clipboard
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. token is not refreshable and is only accessible for limited time.

Link copied to clipboard
open class SpotifyRestAction<T>

Provides a uniform interface to retrieve, whether synchronously or asynchronously, T from Spotify

Link copied to clipboard

Scopes provide Spotify users using third-party apps the confidence that only the information they choose to share will be shared, and nothing more.

Link copied to clipboard
class SpotifyUserAuthorization(var authorizationCode: String? = null, var tokenString: String? = null, var token: Token? = null, var refreshTokenString: String? = null, var pkceCodeVerifier: String? = null)

User-defined authorization parameters

Functions

Link copied to clipboard
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

Link copied to clipboard
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

Link copied to clipboard

A utility to get the pkce code challenge for a corresponding code verifier. Only available on JVM/Android

Link copied to clipboard
suspend fun refreshSpotifyClientToken(clientId: String, clientSecret: String?, refreshToken: String?, usesPkceAuth: Boolean): Token

Refresh a Spotify client token

Link copied to clipboard
fun refreshSpotifyClientTokenRestAction(clientId: String, clientSecret: String?, refreshToken: String?, usesPkceAuth: Boolean): SpotifyRestAction<Token>

Refresh a Spotify client token

Link copied to clipboard

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 block

fun spotifyAppApi(clientId: String?, clientSecret: String?, authorization: SpotifyUserAuthorization, block: SpotifyApiOptions.() -> Unit = {}): SpotifyAppApiBuilder
fun spotifyAppApi(clientId: String?, clientSecret: String?, token: Token, block: SpotifyApiOptions.() -> Unit = {}): SpotifyAppApiBuilder

Instantiate a new SpotifyAppApiBuilder using a Token

Link copied to clipboard

Instantiate a new SpotifyClientApiBuilder by providing a builder initialization block

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 block

fun spotifyClientApi(clientId: String?, clientSecret: String?, redirectUri: String?, authorization: SpotifyUserAuthorization, block: SpotifyApiOptions.() -> Unit = {}): SpotifyClientApiBuilder
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.

Link copied to clipboard
fun spotifyClientPkceApi(clientId: String?, redirectUri: String?, authorization: SpotifyUserAuthorization, block: SpotifyApiOptions.() -> Unit = {}): SpotifyClientApiBuilder
fun spotifyClientPkceApi(clientId: String?, redirectUri: String?, token: Token, block: SpotifyApiOptions.() -> Unit = {}): SpotifyClientApiBuilder
fun spotifyClientPkceApi(clientId: String?, redirectUri: String?, authorizationCode: String, pkceCodeVerifier: String): SpotifyClientApiBuilder
fun spotifyClientPkceApi(clientId: String?, redirectUri: String?, authorizationCode: String, pkceCodeVerifier: String, block: SpotifyApiOptions.() -> Unit): SpotifyClientApiBuilder

Instantiate a new SpotifyClientApiBuilder. This is for PKCE authorization.

Link copied to clipboard

Instantiate a new SpotifyImplicitGrantApi using a Spotify clientId, and token retrieved from the implicit grant flow.