SpotifyApiOptions

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

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

enableLogger

Set whether to enable to the exception logger

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.

Constructors

SpotifyApiOptions
Link copied to clipboard
common
fun SpotifyApiOptions(useCache: Boolean = true, cacheLimit: Int? = 200, automaticRefresh: Boolean = true, retryWhenRateLimited: Boolean = true, enableLogger: 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, afterTokenRefresh: suspend (GenericSpotifyApi) -> Unit? = null)
Set whether to cache requests.

Properties

afterTokenRefresh
Link copied to clipboard
common
var afterTokenRefresh: suspend (GenericSpotifyApi) -> Unit? = null
An optional block to execute after token refresh has been completed.
allowBulkRequests
Link copied to clipboard
common
var allowBulkRequests: Boolean = true
Allow splitting too-large requests into smaller, allowable api requests
automaticRefresh
Link copied to clipboard
common
var automaticRefresh: Boolean = true
Enable or disable automatic refresh of the Spotify access token
cacheLimit
Link copied to clipboard
common
var cacheLimit: Int? = 200
The maximum amount of cached requests allowed at one time.
defaultLimit
Link copied to clipboard
common
var defaultLimit: Int = 50
The default amount of objects to retrieve in one request
enableDebugMode
Link copied to clipboard
common
var enableDebugMode: Boolean = false
Whether to enable debug mode (false by default).
enableLogger
Link copied to clipboard
common
var enableLogger: Boolean = true
Set whether to enable to the exception logger
json
Link copied to clipboard
common
var json: Json
The Json serializer/deserializer instance
onTokenRefresh
Link copied to clipboard
common
var onTokenRefresh: suspend (GenericSpotifyApi) -> Unit? = null
Provide if you want to act on token refresh event
proxyBaseUrl
Link copied to clipboard
common
var proxyBaseUrl: String? = null
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).
refreshTokenProducer
Link copied to clipboard
common
var refreshTokenProducer: suspend (GenericSpotifyApi) -> Token? = null
Provide if you want to use your own logic when refreshing a Spotify token
requestTimeoutMillis
Link copied to clipboard
common
var requestTimeoutMillis: Long? = null
The maximum time, in milliseconds, before terminating an http request
requiredScopes
Link copied to clipboard
common
var requiredScopes: List<SpotifyScope>? = null
Scopes that your application requires to function (only applicable to SpotifyClientApi and SpotifyImplicitGrantApi).
retryOnInternalServerErrorTimes
Link copied to clipboard
common
var retryOnInternalServerErrorTimes: Int? = 5
Whether and how often to retry once if an internal server error (500..599) has been received.
retryWhenRateLimited
Link copied to clipboard
common
var retryWhenRateLimited: Boolean = true
Set whether to block the current thread and wait until the API can retry the request
testTokenValidity
Link copied to clipboard
common
var testTokenValidity: Boolean = false
After API creation, test whether the token is valid by performing a lightweight request
useCache
Link copied to clipboard
common
var useCache: Boolean = true
Set whether to cache requests.

Sources

common source
Link copied to clipboard