SpotifyApiOptions

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)(source)

API Utilities

Parameters

useCache

Set whether to cache requests. Default: true

cacheLimit

The maximum amount of cached requests allowed at one time. Null means no limit

automaticRefresh

Enable or disable automatic refresh of the Spotify access token

retryWhenRateLimited

Set whether to block the current thread and wait until the API can retry the request

testTokenValidity

After API creation, test whether the token is valid by performing a lightweight request

defaultLimit

The default amount of objects to retrieve in one request

json

The Json serializer/deserializer instance

allowBulkRequests

Allow splitting too-large requests into smaller, allowable api requests

requestTimeoutMillis

The maximum time, in milliseconds, before terminating an http request

refreshTokenProducer

Provide if you want to use your own logic when refreshing a Spotify token

onTokenRefresh

Provide if you want to act on token refresh event

requiredScopes

Scopes that your application requires to function (only applicable to SpotifyClientApi and SpotifyImplicitGrantApi).

proxyBaseUrl

Provide if you have a proxy base URL that you would like to use instead of the Spotify API base (https://api.spotify.com/v1).

retryOnInternalServerErrorTimes

Whether and how often to retry once if an internal server error (500..599) has been received. Set to 0 to avoid retrying at all, or set to null to keep retrying until success.

enableDebugMode

Whether to enable debug mode (false by default). With debug mode, all response JSON will be outputted to console.

afterTokenRefresh

An optional block to execute after token refresh has been completed.

httpResponseSubscriber

An optional suspending method to subscribe to successful http responses.

Constructors

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

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var httpResponseSubscriber: suspend (request: HttpRequest, response: HttpResponse) -> Unit?
Link copied to clipboard
var json: Json
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard