Spicetify Documentation
website·Indexed 34 days ago
https://spicetify.app/Developer documentation for Spicetify, a tool for customizing the Spotify client. Includes guides on creating extensions, custom apps, and themes, as well as a comprehensive API wrapper reference covering React components, URI validation, and internal Spotify CLI flags.
What's inside Spicetify
- Spicetify allows users to customize the Spotify client through three primary mechanisms: Themes (for visual styling, colors, and fonts), Extensions (for adding new features and functionality), and Custom Apps (for adding entirely new pages to the Spotify sidebar).
Overview of Spicetify.CosmosAsync
CosmosAsync is an asynchronous API wrapper used by the Spotify client to make requests to internal Spotify APIs (using protocols like
sp://,wg://, andhm://) as well as external URLs. It functions similarly tofetchoraxios, but automatically handles the inclusion of required headers and cookies (such as user session tokens). All responses are automatically parsed as JSON.Security Warning: Do not use
CosmosAsyncfor requests to untrusted external URLs, as it sends the user's session credentials. Use the standardfetchAPI for general external requests.// Internal Spotify endpoint await Spicetify.CosmosAsync.get("sp://desktop/v1/version"); // Spotify Web API endpoint await Spicetify.CosmosAsync.get("https://api.spotify.com/v1/me"); // External URL (Use fetch instead of CosmosAsync for security) await fetch("https://example.com");Overview of the Spicetify GraphQL API Wrapper
TheSpicetify.GraphQLwrapper is used to communicate with Spotify's internal GraphQL API endpoints. It is preferred over the standard Web API orCosmosAsyncfor tailored client operations, such as fetching track colors for the 'Now Playing View' or retrieving specific playlist resources. The wrapper abstracts the complexity of managingoperationName,variables, andextensions(specifically thesha256Hashused for persisted queries), providing a more readable and maintainable way to perform queries and mutations.Overview of Spicetify Custom Apps
Custom Apps are JavaScript applications that add entirely new pages to the Spotify sidebar. Unlike extensions, which modify existing behavior, custom apps create standalone experiences within the Spotify interface.Overview of Spicetify customization features
Spicetify is a toolkit for Spotify that provides four primary ways to customize the client:
- Themes: Community-made color schemes, layouts, and visual overhauls.
- Extensions: Additional functionality such as keyboard shortcuts, playback controls, and third-party service integrations.
- Custom Apps: New internal pages for features like lyrics and statistics.
- CLI: A command-line interface used to apply, backup, restore, and update customizations.
Access current player and track state
TheSpicetify.Player.dataproperty provides an object containing all current information about the active track and the player state. This is useful for retrieving the current track URI or other metadata.// Get current track URI const currentURI = Spicetify.Player.data?.item.uri; if (currentURI) { console.log(currentURI); }Manage local storage using the Spicetify LocalStorage wrapper
Spicetify provides aLocalStoragenamespace wrapper to simplify interactions with the browser'slocalStorage. It allows developers to store, retrieve, and delete string-based key-value pairs.namespace LocalStorage { function clear(): void; function get(key: string): string | null; function remove(key: string): void; function set(key: string, value: string): void; }Use the PlayerState type to track Spotify playback
ThePlayerStatetype provides a comprehensive snapshot of the current playback state in the Spicetify API wrapper. It includes information about the current track, playback position, playback status (playing, paused, buffering), queue state (previous and next tracks), and session metadata.type PlayerState = { timestamp: number; context_uri: string; context_url: string; context_restrictions: Record<string, string[]>; index?: { page: number; track: number; }; track?: ProvidedTrack; playback_id?: string; playback_quality?: { bitrate_level: string; hifi_status?: string; strategy?: string; target_bitrate_available?: boolean; target_bitrate_level?: string; }; playback_speed?: number; position_as_of_timestamp: number; duration: number; is_playing: boolean; is_paused: boolean; is_buffering: boolean; play_origin: { feature_identifier: string; feature_version: string; view_uri?: string; external_referrer?: string; referrer_identifier?: string; device_identifier?: string; }; options: { shuffling_context?: boolean; repeating_context?: boolean; repeating_track?: boolean; }; restrictions: Record<string, string[]>; suppressions: { providers: string[]; }; debug?: { log: string[]; }; prev_tracks?: ProvidedTrack[]; next_tracks?: ProvidedTrack[]; context_metadata: Metadata; page_metadata: Metadata; session_id: string; queue_revision?: string; };Understand Spotify URI and URL formats
Spotify resources (tracks, albums, playlists, users) are identified by URIs and URLs.
- URI Format:
spotify:<type>:<id>(e.g.,spotify:track:6rqhFgbbKwnb9MLmUQDhG6). The<id>is a base62 unique identifier. - URL Format:
https://open.spotify.com/<type>/<id>?query=parameters(e.g.,https://open.spotify.com/track/6rqhFgbbKwnb9MLmUQDhG6?si=...).
To manually copy a URI from the Spotify client: Right-click an item -> hover over
Share-> holdCtrl-> selectCopy Spotify URI.- URI Format:
Access internal Spotify APIs via Spicetify.Platform
Spicetify provides a wrapper around internal Spotify client APIs to modify client behavior. Because these APIs change between Spotify versions, developers should explore the full available set via the browser DevTools console usingSpicetify.Platform.// Run in DevTools to explore available methods Spicetify.PlatformRetrieve client and OS metadata via PlatformData
ThePlatformDataobject contains technical details about the current Spotify client and the host operating system, useful for version-specific logic or debugging.interface PlatformData { app_platform: string; // e.g., "win32" client_capabilities: Record<string, any>; client_version_triple: string; // e.g., "1.2.8" client_version_quadruple: string; client_version_quintuple: string; event_sender_context_information: Record<string, any>; os_name: string; // e.g., "windows" os_version: string; // e.g., "10.0.19042" } const os = Spicetify.Platform.PlatformData.os_name;Use Spicetify stock React components for custom UI
Spicetify exposes a namespaceSpicetify.ReactComponentcontaining a set of stock React components used by Spotify. These can be used to create custom UI elements that maintain the native Spotify look and feel.namespace ReactComponent { const ContextMenu: any; const RightClickMenu: any; const Menu: any; const MenuItem: any; const AlbumMenu: any; const PodcastShowMenu: any; const ArtistMenu: any; const PlaylistMenu: any; const TooltipWrapper: any; const IconComponent: any; const TextComponent: any; const ConfirmDialog: any; const PanelSkeleton: any; const PanelContent: any; const PanelHeader: any; const Toggle: any; const Slider: any; }