Platform
Spicetify provides a vast collection of internal APIs used throughout the Spotify client. These APIs are used to interact with the Spotify client and modify its behavior.
Explore all available methods in DevTools:
Spicetify.PlatformUsage
Since these APIs differ between each version of the Spotify client, we cannot provide a complete list of all available APIs. Instead, we provide a list of APIs that may prove useful for extension developers and that have generally not changed much over the years.
ClipboardAPI
The Spotify client doesn’t allow users to copy directly from the client (say Ctrl + C), but it does provide an API to copy text to the clipboard.
interface ClipboardAPI { copy: (text: string) => Promise<void>; paste: () => Promise<string | undefined>;};copy
Copy text to clipboard.
| Parameter | Type | Description |
|---|---|---|
text | string | Text to copy. |
Example:
// Will be copied as "Hello World!"await Spicetify.Platform.ClipboardAPI.copy("Hello World!");
// Will be stringified to '{"0":0,"1":0,"2":0,"3":0}'await Spicetify.Platform.ClipboardAPI.copy(new Uint16Array(4));paste
Paste text from clipboard. Returns a string.
Example:
await Spicetify.Platform.ClipboardAPI.copy("Hello World!");await Spicetify.Platform.ClipboardAPI.paste(); // "Hello World!"
await Spicetify.Platform.ClipboardAPI.copy(new Uint16Array(4));await Spicetify.Platform.ClipboardAPI.paste(); // '{"0":0,"1":0,"2":0,"3":0}'History
Spotify has their own router API that allows you to navigate to different pages within the client. You can use it to navigate within your custom apps or push new pages to the history stack and display them for the users.
interface History { push: (path: Location | string) => void; replace: (path: Location | string) => void; goBack: () => void; goForward: () => void; listen: (listener: (location: Location) => void) => () => void; entries: Location[]; location: Location;};Their Location object is a simple object that contains the pathname of the current page as well as the relevant query parameters and state. It looks roughly like this:
interface Location { pathname: string; search: string; hash: string; state: Record<string, any>;};push
Push a new location to the history stack.
You can pass either a Location object or a pathname string to this method.
| Parameter | Type | Description |
|---|---|---|
path | Location | string | Location to push. |
Spicetify.Platform.History.push("/app/your-app");
Spicetify.Platform.History.push({ pathname: "/app/your-app", search: "?foo=bar", hash: "#baz", state: { foo: "bar" },});replace
Replace the current location in the history stack.
You can pass either a Location object or a pathname string to this method.
| Parameter | Type | Description |
|---|---|---|
path | Location | string | Location to replace. |
// Replace the current location with a new one.Spicetify.Platform.History.replace("/app/your-app");
Spicetify.Platform.History.replace({ pathname: "/app/your-app", search: "?foo=bar", hash: "#baz", state: { foo: "bar" },});goBack
Go back to the previous location in the history stack.
goForward
Go forward to the next location in the history stack.
listen
Listen to changes in the history stack. Fires whenever the user navigates to a new page.
| Parameter | Type | Description |
|---|---|---|
listener | (location: Location) => void | Callback to fire when the user navigates to a new page. |
Example:
Spicetify.Platform.History.listen((location) => { // Log the current pathname every time the user navigates to a new page. console.log(location.pathname);});entries
An array of all locations in the history stack.
location
The current location in the history stack.
LocalStorageAPI
Spotify provides a simple API to interact with the browser’s local storage. All keys are stored using the current user’s username as the namespace.
Inside localStorage, the keys are stored using the following format:
`${namespace}:${key}`interface LocalStorageAPI { items: Record<string, any>; namespace: string; getItem: (key: string) => any; setItem: (key: string, value: any) => void; clearItem: (key: string) => void;};items
An object containing all the keys and values stored in the local storage.
All keys in items are stored using the aforementioned format, with it’s value pair being the value stored in the local storage parsed using JSON.parse.
Example:
Spicetify.Platform.LocalStorageAPI.items; // { "username:foo": "bar" }namespace
The namespace used to store all keys in the local storage. Usually the current user’s username.
getItem
Get a value from the local storage. Returns a parsed value using JSON.parse.
| Parameter | Type | Description |
|---|---|---|
key | string | Key to get. |
Example:
// This is equivalent to Spicetify.Platform.LocalStorageAPI.items["username:foo"]// or localStorage.getItem("username:foo")Spicetify.Platform.LocalStorageAPI.getItem("foo"); // "bar"setItem
Set a value in the local storage. The value will be stringified using JSON.stringify.
| Parameter | Type | Description |
|---|---|---|
key | string | Key to set. |
value | any | Value to set. Can be any type. |
Example:
Spicetify.Platform.LocalStorageAPI.setItem("foo", { bar: "baz" });// localStorage.getItem("username:foo") === '{"bar":"baz"}'clearItem
Clear a value from the local storage.
| Parameter | Type | Description |
|---|---|---|
key | string | Key to clear. |
Example:
Spicetify.Platform.LocalStorageAPI.clearItem("foo");// localStorage.getItem("username:foo") === nullPlatformData
Contains data about the current platform, such as the current Spotify client version, operating system, and more.
interface PlatformData { app_platform: string; client_capabilities: Record<string, any>; client_version_triple: string; client_version_quadruple: string; client_version_quintuple: string; event_sender_context_information: Record<string, any>; os_name: string; os_version: string;}app_platform
The current Spotify client platform.
Example:
Spicetify.Platform.PlatformData.app_platform; // "win32"client_capabilities
An object containing the current client capabilities. This usually contains information relating to functionality inside the Spotify client, such as whether or not the client can autostart.
client_version_triple, client_version_quadruple, client_version_quintuple
The current Spotify client version. Usually in the format 1.2.8, 1.2.8.923, or 1.2.8.923.g4f94bf0d.
event_sender_context_information
An object containing information about the current operating system. Used for analytics throughout the Spotify client.
Example:
Spicetify.Platform.PlatformData.event_sender_context_information; // { "platform_type:"windows", "os_version": "10.0.19042" }This could also help you diagnose issues with your custom apps. For example, if you’re using a custom app on Windows and you’re getting an error, you can check the event_sender_context_information object to see if the platform_type is windows or macos.
os_name
The current operating system.
Example:
Spicetify.Platform.PlatformData.os_name; // "windows"os_version
The current operating system version.
Example:
Spicetify.Platform.PlatformData.os_version; // "10.0.19042"Session
Contains data about the current user session, such as the current user’s access token, locale, and more.
interface Session { accessToken: string; accessTokenExpirationTimestampMs: number; locale: string;}accessToken
The current user’s access token. This is used to authenticate requests to the Spotify API.
accessTokenExpirationTimestampMs
The timestamp in milliseconds when the current user’s access token expires.
locale
The current user’s locale.
Example:
Spicetify.Platform.Session.locale; // "en"Translations
Contains translation strings used throughout the current Spotify client.
interface Translations { [key: string]: string;}PlayerAPI
Contains methods to interact with the Spotify client’s player.
interface PlayerAPI { addToQueue: (items: ContextTrack[]) => Promise<void>; clearQueue: () => Promise<void>; pause: () => Promise<void>; play: (uri: ContextTrack, context, options = {}) => Promise<void>; removeFromQueue: (items: ContextTrack[]) => Promise<void>; resume: () => Promise<void>; seekBackward: (ms: number) => Promise<void>; seekBy: (ms: number) => Promise<void>; seekForward: (ms: number) => Promise<void>; seekTo: (ms: number) => Promise<void>; setRepeat: (mode: RepeatMode) => Promise<void>; setShuffle: (shuffle: boolean) => Promise<void>; setSpeed: (speed: number) => Promise<void>;}RepeatMode
Enum for the repeat mode.
enum RepeatMode { Off = 0, RepeatAll = 1, RepeatOne = 2,}addToQueue
Add items to the current user’s queue.
await Spicetify.Platform.PlayerAPI.addToQueue(items);| Parameter | Type | Description |
|---|---|---|
items | ContextTrack[] | Items to add to the queue. |
Example
// Add a track to the queue
// 505 - Arctic Monkeysconst track = { uri: "spotify:track:0BxE4FqsDD1Ot4YuBXwAPp" };
await Spicetify.Platform.PlayerAPI.addToQueue([track]);clearQueue
Clear the current user’s queue.
await Spicetify.Platform.PlayerAPI.clearQueue();pause
Pause the current user’s playback.
await Spicetify.Platform.PlayerAPI.pause();play
Start playback of a track.
await Spicetify.Platform.PlayerAPI.play(uri, context, options);| Parameter | Type | Description |
|---|---|---|
uri | ContextTrack | The track to play. |
context | Record<string, any> | The context of the track. Must be an object. |
options | Record<string, any> | undefined | Playback options. |
Example
// 505 - Arctic Monkeysconst track = { uri: "spotify:track:0BxE4FqsDD1Ot4YuBXwAPp" };
// Play the track// Spicetify.Player.playUri(track.uri);await Spicetify.Platform.PlayerAPI.play(track, {}, {});removeFromQueue
Remove items from the current user’s queue.
await Spicetify.Platform.PlayerAPI.removeFromQueue(items);| Parameter | Type | Description |
|---|---|---|
items | ContextTrack[] | Items to remove from the queue. |
Example
// Remove a track from the queue
// 505 - Arctic Monkeysconst track = { uri: "spotify:track:0BxE4FqsDD1Ot4YuBXwAPp" };
// Remove the track if it's in the queueawait Spicetify.Platform.PlayerAPI.removeFromQueue([track]);resume
Resume the current user’s playback.
await Spicetify.Platform.PlayerAPI.resume();seekBackward
Seek backward in the current user’s playback.
await Spicetify.Platform.PlayerAPI.seekBackward(ms);| Parameter | Type | Description |
|---|---|---|
ms | number | The number of milliseconds to seek backward. |
Example
// Seek backward 10 secondsawait Spicetify.Platform.PlayerAPI.seekBackward(10000);seekBy
Seek by a number of milliseconds in the current user’s playback.
If passed a negative number, it will seek backward.
await Spicetify.Platform.PlayerAPI.seekBy(ms);| Parameter | Type | Description |
|---|---|---|
ms | number | The number of milliseconds to seek by. |
Example
// Seek forward 10 secondsawait Spicetify.Platform.PlayerAPI.seekBy(10000);
// Seek backward 10 secondsawait Spicetify.Platform.PlayerAPI.seekBy(-10000);seekForward
Seek forward in the current user’s playback.
await Spicetify.Platform.PlayerAPI.seekForward(ms);| Parameter | Type | Description |
|---|---|---|
ms | number | The number of milliseconds to seek forward. |
Example
// Seek forward 10 secondsawait Spicetify.Platform.PlayerAPI.seekForward(10000);seekTo
Seek to a specific position in the current user’s playback.
await Spicetify.Platform.PlayerAPI.seekTo(ms);| Parameter | Type | Description |
|---|---|---|
ms | number | The position in milliseconds to seek to. |
Example
// Seek to 1 minuteawait Spicetify.Platform.PlayerAPI.seekTo(60000);setRepeat
Set the current user’s repeat mode.
await Spicetify.Platform.PlayerAPI.setRepeat(mode);| Parameter | Type | Description |
|---|---|---|
mode | RepeatMode | The repeat mode to set. |
Example
// Set repeat mode to repeat oneawait Spicetify.Platform.PlayerAPI.setRepeat(2);setShuffle
Set the current user’s shuffle mode.
await Spicetify.Platform.PlayerAPI.setShuffle(shuffle);| Parameter | Type | Description |
|---|---|---|
shuffle | boolean | Whether to enable shuffle mode. |
Example
// Enable shuffle modeawait Spicetify.Platform.PlayerAPI.setShuffle(true);setSpeed
Set the current user’s playback speed.
await Spicetify.Platform.PlayerAPI.setSpeed(speed);| Parameter | Type | Description |
|---|---|---|
speed | number | The playback speed to set. |
Example
// Set playback speed to 1.5xawait Spicetify.Platform.PlayerAPI.setSpeed(1.5);