├── .gitattributes ├── LICENSE ├── README.md ├── index.js ├── package.json ├── tsconfig.json └── typings ├── album.d.ts ├── artist.d.ts ├── audiobook.d.ts ├── browse.d.ts ├── episode.d.ts ├── global.d.ts ├── index.d.ts ├── player.d.ts ├── playlist.d.ts ├── show.d.ts ├── track.d.ts └── user.d.ts /.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-language=Typescript text=auto eol=lf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Spotify-Api.JS ❄ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spotify Types 2 | 3 | **Module Documentation Reference:** https://spotify-api.js.org/apiTypes/
4 | **Spotify Object Index Reference:** https://developer.spotify.com/documentation/web-api/reference/#objects-index 5 | 6 | All the typings for the various Spotify API Object typings written in typescript. You can view the Spotify web api reference for all the objects [here](https://developer.spotify.com/documentation/web-api/reference/#objects-index). 7 | 8 | This is a typings modules made for [Spotify-api.js](https://github.com/spotify-api/spotify-api.js) v9. This can also be used separately just for typescript debugging when working with Spotify API. This package can be even used in deno using the cdn urls. 9 | 10 | ```ts 11 | import { SearchContent } from "spotify-types"; 12 | import axios, { AxiosResponse } from "axios"; 13 | 14 | const response: AxiosResponse = await axios.get('https://api.spotify.com/v1/search', { 15 | headers: { "Authorization": "Bearer " + process.env.SPOTIFY_TOKEN }, 16 | params: { 17 | q: "search query", 18 | type: "track", 19 | market: "US" 20 | } 21 | }); 22 | ``` -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spotify-types", 3 | "version": "2.0.0", 4 | "description": "All the typings for the various Spotify API Object typings written in typescript.", 5 | "main": "index.js", 6 | "types": "typings/index.d.ts", 7 | "keywords": [ 8 | "spotify", 9 | "spotify-api.js", 10 | "spotify-api-types", 11 | "spotify-types", 12 | "spotify-api" 13 | ], 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/spotify-api/spotify-types" 17 | }, 18 | "scripts": { 19 | "build": "npx tsc --project tsconfig.json" 20 | }, 21 | "author": "science_spot_codes", 22 | "license": "MIT" 23 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "noImplicitAny": false, 5 | "strictNullChecks": true, 6 | "esModuleInterop":true, 7 | "target": "ES2018", 8 | "module": "commonjs", 9 | "allowJs": true, 10 | "moduleResolution": "node", 11 | "lib": ["es2018", "dom"], 12 | "rootDir": "./typings", 13 | "strict": true 14 | }, 15 | "include": ["typings"] 16 | } -------------------------------------------------------------------------------- /typings/album.d.ts: -------------------------------------------------------------------------------- 1 | import { Artist, SimplifiedArtist } from "./artist"; 2 | import { SimplifiedTrack } from "./track"; 3 | import { Copyright, ExternalID, ExternalUrl, Image, Restriction, Saved, Paging } from "./global"; 4 | 5 | /** 6 | * The types of album. 7 | */ 8 | export type AlbumType = 'single' | 'album' | 'compilation'; 9 | 10 | /** 11 | * The groups of album. 12 | */ 13 | export type AlbumGroup = AlbumType | 'appears_on'; 14 | 15 | /** 16 | * The saved album object. 17 | */ 18 | export type SavedAlbum = Saved<'album', Album> 19 | 20 | /** 21 | * The spotify object containing the complete details of the Spotify Album. 22 | */ 23 | export interface Album extends Omit { 24 | /** The artists of the album. */ 25 | artists: Artist[]; 26 | /** The copyright statements of the album. */ 27 | copyrights: Copyright[]; 28 | /** Known external IDs for the album. */ 29 | external_ids: ExternalID; 30 | /** A list of the genres used to classify the album. For example: “Prog Rock” , “Post-Grunge”. (If not yet classified, the array is empty.) */ 31 | genres: string[]; 32 | /** The label for the album. */ 33 | label: string; 34 | /** The popularity of the album. The value will be between 0 and 100, with 100 being the most popular. The popularity is calculated from the popularity of the album’s individual tracks. */ 35 | popularity: number; 36 | /** The tracks of the album. The object index says this is an array but the value returns as a Paging object so here is an union might be fixed in upcomming versions. */ 37 | tracks: SimplifiedTrack[] | Paging; 38 | } 39 | 40 | /** 41 | * The spotify object containing the simplified details of the Spotify Album. 42 | */ 43 | export interface SimplifiedAlbum { 44 | /** The field is present when getting an artist’s albums. */ 45 | album_group?: AlbumGroup; 46 | /** The type of album. */ 47 | album_type: AlbumType; 48 | /** The artists of the album. */ 49 | artists: SimplifiedArtist[]; 50 | /** The markets in which the album is available. */ 51 | available_markets?: string[]; 52 | /** Known external URLs for this album. */ 53 | external_urls: ExternalUrl; 54 | /** A link to the Web API endpoint providing full details of the album. */ 55 | href: string; 56 | /** The Spotify ID of the album. */ 57 | id: string; 58 | /** The cover art for the album in various sizes, widest first. */ 59 | images: Image[]; 60 | /** The name of the album. */ 61 | name: string; 62 | /** The date the album was first released, for example “1981-12-15”. */ 63 | release_date: string; 64 | /** The precision with which release_date value is known: “year” , “month” , or “day”. */ 65 | release_date_precision: string; 66 | /** Included in the response when a content restriction is applied. */ 67 | restrictions: Restriction[]; 68 | /** The total number of tracks in the album. */ 69 | total_tracks: number; 70 | /** The object type which will be 'album'. */ 71 | type: 'album'; 72 | /** The Spotify URI for the album. */ 73 | uri: string; 74 | } -------------------------------------------------------------------------------- /typings/artist.d.ts: -------------------------------------------------------------------------------- 1 | import { ExternalUrl, Image } from "./global"; 2 | import { Followers } from "./user"; 3 | 4 | /** 5 | * The structure containing the simplified details of the Spotify Artist. 6 | */ 7 | export interface SimplifiedArtist { 8 | /** Known external URLs for this artist. */ 9 | external_urls: ExternalUrl; 10 | /** A link to the Web API endpoint providing full details of the artist. */ 11 | href: string; 12 | /** The Spotify ID for the artist. */ 13 | id: string; 14 | /** The name of the artist. */ 15 | name: string; 16 | /** The object type: "artist". */ 17 | type: 'artist'; 18 | /** The Spotify URI for the artist. */ 19 | uri: string; 20 | } 21 | 22 | /** 23 | * The structure containing the entire details of the Spotify Artist. 24 | */ 25 | export interface Artist extends SimplifiedArtist { 26 | /** Information about the followers of the artist. */ 27 | followers: Followers; 28 | /** A list of the genres the artist is associated with. For example: "Prog Rock" , "Post-Grunge". (If not yet classified, the array is empty.) */ 29 | genres: string[]; 30 | /** Images of the artist in various sizes, widest first. */ 31 | images: Image[]; 32 | /** The popularity of the artist. The value will be between 0 and 100, with 100 being the most popular. The artist’s popularity is calculated from the popularity of all the artist’s tracks. */ 33 | popularity: number; 34 | } -------------------------------------------------------------------------------- /typings/audiobook.d.ts: -------------------------------------------------------------------------------- 1 | import { ResumePoint } from "./episode"; 2 | import { Copyright, ExternalUrl, Image, Paging, Restriction } from "./global"; 3 | 4 | /** 5 | * The structure containing the complete details of the Spotify Audiobook. 6 | */ 7 | export interface Audiobook extends SimplifiedAudiobook { 8 | /** The chapters of the audiobook. */ 9 | chapters: Paging; 10 | } 11 | 12 | /** 13 | * The structure containing the complete details of the Spotify Chapter. 14 | */ 15 | export interface Chapter extends SimplifiedChapter { 16 | /** The audiobook to which the chapter belongs to. */ 17 | audiobook: SimplifiedAudiobook; 18 | } 19 | 20 | /** 21 | * The structure containing the simplified details of the Spotify Audiobook. 22 | */ 23 | export interface SimplifiedAudiobook { 24 | /** The authors of the auidobook. */ 25 | authors: Username[]; 26 | /** The markets where the audiobook is available. */ 27 | available_markets: string[]; 28 | /** The copyright statements of the audiobook. */ 29 | copyrights: Copyright[]; 30 | /** The description of the audiobook. */ 31 | description: string; 32 | /** The description of the audiobook with HTML tags. */ 33 | html_description: string; 34 | /** The edition of the audiobook. */ 35 | edition: string; 36 | /** Boolean stating if the audiobook contains explicit content. */ 37 | explicit: boolean; 38 | /** The external urls of the audiobook. */ 39 | external_urls: ExternalUrl; 40 | /** The href of the audiobook. */ 41 | href: string; 42 | /** The ID of the audiobook. */ 43 | id: string; 44 | /** All the images related to audiobook (cover arts). */ 45 | images: Image[]; 46 | /** The languages used in the audiobook. */ 47 | languages: string[]; 48 | /** The media type of the audiobook. */ 49 | media_type: string; 50 | /** The name of the audiobook. */ 51 | name: string; 52 | /** The narrators of the audiobook. */ 53 | narrators: Username[]; 54 | /** The publisher of the audiobook. */ 55 | publisher: string; 56 | /** The type of the audiobook. */ 57 | type: "audiobook"; 58 | /** The URI of the audiobook. */ 59 | uri: string; 60 | /** The total chapters of the audiobook. */ 61 | total_chapters: number; 62 | } 63 | 64 | /** 65 | * The structure containing the simplified details of Spotify Chapter. 66 | */ 67 | export interface SimplifiedChapter { 68 | /** The audio preview url of chapter. */ 69 | audio_preview_url: string; 70 | /** The markets where the chapter is available. */ 71 | available_markets: string[]; 72 | /** The number of the chapter. */ 73 | chapter_number: number; 74 | /** The description of the chapter. */ 75 | description: string; 76 | /** The HTML description of the chapter. */ 77 | html_description: string; 78 | /** The duration of the chapter in ms. */ 79 | duration_ms: number; 80 | /** Boolean stating if the chapter is explicit or not. */ 81 | explicit: boolean; 82 | /** The external urls of the chapter. */ 83 | external_urls: ExternalUrl; 84 | /** The href of the chapter. */ 85 | href: string; 86 | /** The ID of the chapter. */ 87 | id: string; 88 | /** The images of the chapter. */ 89 | images: Image[], 90 | /** Boolean stating if the chapter is playable or not. */ 91 | is_playable: boolean; 92 | /** The languages of the chapter. */ 93 | languages: string[]; 94 | /** The name of the chapter. */ 95 | name: string; 96 | /** The date the episode was first released, for example "1981-12-15". Depending on the precision, it might be shown as "1981" or "1981-12". */ 97 | release_date: string; 98 | /** The precision with which release_date value is known: "year", "month", or "day". */ 99 | release_date_precision: string; 100 | /** Included in the response when a content restriction is applied. */ 101 | restrictions: Restriction; 102 | /** The user’s most recent position in the chapter. Set if the supplied access token is a user token and has the scope ‘user-read-playback-position’. */ 103 | resume_point?: ResumePoint; 104 | /** The Spotify object type. */ 105 | type: "episode"; 106 | /** The Spotify URI for the chapter. */ 107 | uri: string; 108 | } 109 | 110 | /** 111 | * The structure containing the name of a particular user. 112 | */ 113 | export interface Username { 114 | /** The name of the user. */ 115 | name: string; 116 | } -------------------------------------------------------------------------------- /typings/browse.d.ts: -------------------------------------------------------------------------------- 1 | import { Image } from "./global"; 2 | import { SimplifiedTrack, TuneableTrack } from "./track"; 3 | 4 | /** 5 | * An object containing details about the spotify category. 6 | */ 7 | export interface Category { 8 | /** A link to the Web API endpoint returning full details of the category. */ 9 | href: string; 10 | /** The category icon, in various sizes. */ 11 | icons: Image[]; 12 | /** The Spotify category ID of the category. */ 13 | id: string; 14 | /** The name of the category. */ 15 | name: string; 16 | } 17 | 18 | /** 19 | * The spotify recommendation seed object. 20 | */ 21 | export interface RecommendationSeed { 22 | /** The number of tracks available after min_* and max_* filters have been applied. */ 23 | afterFilteringSize: number; 24 | /** The number of tracks available after relinking for regional availability. */ 25 | afterRelinkingSize: number; 26 | /** A link to the full track or artist data for this seed. */ 27 | href: string; 28 | /** The id used to select this seed. This will be the same as the string used in the seed_artists, seed_tracks or seed_genres parameter. */ 29 | id: string; 30 | /** The number of recommended tracks available for this seed. */ 31 | initialPoolSize: number; 32 | /** The entity type of this seed. */ 33 | type: 'artist' | 'track' | 'genre'; 34 | } 35 | 36 | /** 37 | * The collection of recommendation seed objects with tracks provided from the spotify api.. 38 | */ 39 | export interface Recommendations { 40 | /** An array of recommendation seed objects. */ 41 | seeds: RecommendationSeed[]; 42 | /** An array of track object (simplified) ordered according to the parameters supplied. */ 43 | tracks: SimplifiedTrack[]; 44 | } 45 | 46 | /** 47 | * Just an extension for [RecommendationQuery]. 48 | */ 49 | export type RecommendationQueryExtension = Partial>; 50 | 51 | /** 52 | * The query paramater structure of the [/recommendations] endpoint. 53 | */ 54 | export interface RecommendationQuery extends RecommendationQueryExtension { 55 | /** The target size of the list of recommended tracks. */ 56 | limit?: number; 57 | /** An ISO 3166-1 alpha-2 country code or the string from_token. */ 58 | market?: string; 59 | /** A comma separated list of Spotify IDs for seed artists. Up to 5 seed values may be provided in any combination of seed_artists, seed_tracks and seed_genres **/ 60 | seed_artists: string; 61 | /** A comma separated list of any genres in the set of available genre seeds. Up to 5 seed values may be provided in any combination of seed_artists, seed_tracks and seed_genres. */ 62 | seed_genres: string; 63 | /** A comma separated list of Spotify IDs for a seed track. Up to 5 seed values may be provided in any combination of seed_artists, seed_tracks and seed_genres. */ 64 | seed_tracks: string; 65 | } -------------------------------------------------------------------------------- /typings/episode.d.ts: -------------------------------------------------------------------------------- 1 | import { SimplifiedShow } from "./show"; 2 | import { ExternalUrl, Image, Restriction, Saved } from "./global"; 3 | 4 | /** 5 | * The saved episode object. 6 | */ 7 | export type SavedEpisode = Saved<'episode', Episode>; 8 | 9 | /** 10 | * The structure containing the complete details of the Spotify episode. 11 | */ 12 | export interface Episode extends SimplifiedEpisode { 13 | /** The show on which the episode belongs. */ 14 | show: SimplifiedShow; 15 | } 16 | 17 | /** 18 | * The structure containing the simplified details of the Spotify episode. 19 | */ 20 | export interface SimplifiedEpisode { 21 | /** A URL to a 30 second preview (MP3 format) of the episode. null if not available. */ 22 | audio_preview_url: string | null; 23 | /** A description of the episode. HTML tags are stripped away from this field, use html_description field in case HTML tags are needed. */ 24 | description: string; 25 | /** The episode length in milliseconds. */ 26 | duration_ms: number; 27 | /** Whether or not the episode has explicit content (true = yes it does; false = no it does not OR unknown). */ 28 | explicit: boolean; 29 | /** External URLs for this episode */ 30 | external_urls: ExternalUrl; 31 | /** A link to the Web API endpoint providing full details of the episode. */ 32 | href: string; 33 | /** A description of the episode. This field may contain HTML tags. */ 34 | html_description: string; 35 | /** The Spotify ID for the episode. */ 36 | id: string; 37 | /** The cover art for the episode in various sizes, widest first. */ 38 | images: Image[]; 39 | /** True if the episode is hosted outside of Spotify’s CDN. */ 40 | is_externally_hosted: boolean; 41 | /** True if the episode is playable in the given market. Otherwise false. */ 42 | is_playable: boolean; 43 | /** The language used in the episode, identified by a ISO 639 code. */ 44 | language?: string; 45 | /** A list of the languages used in the episode, identified by their ISO 639 code. */ 46 | languages: string[]; 47 | /** The name of the episode. */ 48 | name: string; 49 | /** The date the episode was first released, for example "1981-12-15". Depending on the precision, it might be shown as "1981" or "1981-12". */ 50 | release_date: string; 51 | /** The precision with which release_date value is known: "year", "month", or "day". */ 52 | release_date_precision: string; 53 | /** Included in the response when a content restriction is applied. */ 54 | restrictions: Restriction[]; 55 | /** The user’s most recent position in the episode. Set if the supplied access token is a user token and has the scope ‘user-read-playback-position’. */ 56 | resume_point?: ResumePoint; 57 | /** The object type: “episode”. */ 58 | type: 'episode'; 59 | /** The Spotify URI for the episode */ 60 | uri: string; 61 | } 62 | 63 | /** 64 | * An object containing the resume point. 65 | */ 66 | export interface ResumePoint { 67 | /** Whether or not the episode has been fully played by the user. */ 68 | fully_played: boolean; 69 | /** The user’s most recent position in the episode in milliseconds. */ 70 | resume_position_ms: number; 71 | } -------------------------------------------------------------------------------- /typings/global.d.ts: -------------------------------------------------------------------------------- 1 | import { Artist } from "./artist"; 2 | import { Track } from "./track"; 3 | import { SimplifiedAlbum } from "./album"; 4 | import { SimplifiedEpisode } from "./episode"; 5 | import { SimplifiedShow } from "./show"; 6 | import { SimplifiedPlaylist } from "./playlist"; 7 | import { SimplifiedAudiobook } from "./audiobook"; 8 | 9 | /** 10 | * All the spotify element types 11 | */ 12 | export type SpotifyType = 'user' | 'episode' | 'playlist' | 'show' | 'track' | 'album' | 'artist' | 'audiobook'; 13 | 14 | /** 15 | * All the spotify search types. 16 | */ 17 | export type SearchType = 'album' | 'artist' | 'track' | 'show' | 'episode' | 'playlist' | 'audiobook'; 18 | 19 | /** 20 | * The spotify object containing the details of an image. 21 | */ 22 | export interface Image { 23 | /** The image height in pixels. If unknown: null or not returned. */ 24 | height: number | null; 25 | /** The source URL of the image. */ 26 | url: string; 27 | /** The image width in pixels. If unknown: null or not returned. */ 28 | width: number | null; 29 | } 30 | 31 | /** 32 | * The external urls object which contains the spotify url within it. 33 | */ 34 | export interface ExternalUrl { 35 | /** The Spotify URL for the object. */ 36 | spotify: string; 37 | } 38 | 39 | /** 40 | * The external ids object which contains the spotify id within it. 41 | */ 42 | export interface ExternalID { 43 | /** International Article Number */ 44 | ean: string; 45 | /** International Standard Recording Code */ 46 | isrc: string; 47 | /** Universal Product Code */ 48 | upc: string; 49 | } 50 | 51 | /** 52 | * The paging object is a form of collection of items from the spotify api. 53 | */ 54 | export interface Paging { 55 | /** A link to the Web API endpoint returning the full result of the request. */ 56 | href: string; 57 | /** The requested data. */ 58 | items: T[]; 59 | /** The maximum number of items in the response (as set in the query or by default). */ 60 | limit: number; 61 | /** URL to the next page of items. (null if none) */ 62 | next?: string; 63 | /** The offset of the items returned (as set in the query or by default) */ 64 | offset: number; 65 | /** URL to the previous page of items. (null if none) */ 66 | previous?: string; 67 | /** The total number of items available to return. */ 68 | total: number; 69 | } 70 | 71 | /** 72 | * The cursor object having before and after keys of the items. 73 | */ 74 | export interface Cursor { 75 | /** The cursor to use as key to find the next page of items. */ 76 | after: string; 77 | /** The cursor to use as key to find the previous page of items. */ 78 | before: string; 79 | } 80 | 81 | 82 | /** 83 | * The paging object but with a additional cursor field. 84 | */ 85 | export interface CursorPaging extends Omit, 'offset' | 'previous'> { 86 | /** The cursors used to find the next set of items. */ 87 | cursors: Cursor; 88 | } 89 | 90 | /** 91 | * The copyright object contains the type and the name of copyright. 92 | */ 93 | export interface Copyright { 94 | /** The text of copyright. */ 95 | text: string; 96 | /** The type of copyright. */ 97 | type: 'C' | 'P'; 98 | } 99 | 100 | /** 101 | * The object containing the reason of restriction by the spotify api. 102 | */ 103 | export interface Restriction { 104 | /** The reason for the restriction. */ 105 | reason: 'market' | 'product' | 'explicit'; 106 | } 107 | 108 | /** 109 | * The error response sent by the spotify api during unusual status codes. 110 | */ 111 | export interface ErrorResponse { 112 | /** A short description of the cause of the error. */ 113 | message: string; 114 | /** The HTTP status code (also returned in the response header; see Response Status Codes for more information). */ 115 | status: number; 116 | } 117 | 118 | /** 119 | * The object containing the saved elements and the timestamp when they were added. 120 | */ 121 | export type Saved = { added_at: string } & Record; 122 | 123 | /** 124 | * The object structure returned by the [/search] endpoint. 125 | */ 126 | export interface SearchContent { 127 | /** The episode search results. */ 128 | episodes?: Paging; 129 | /** The show search results. */ 130 | shows?: Paging; 131 | /** The track search results. */ 132 | tracks?: Paging; 133 | /** The artists search results. */ 134 | artists?: Paging; 135 | /** The album search results. */ 136 | albums?: Paging; 137 | /** The playlist search results. */ 138 | playlists?: Paging; 139 | /** The audiobook search results. */ 140 | audiobooks?: Paging; 141 | } -------------------------------------------------------------------------------- /typings/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from './global'; 2 | export * from './user'; 3 | export * from './track'; 4 | export * from './artist'; 5 | export * from './album'; 6 | export * from './player'; 7 | export * from './playlist'; 8 | export * from './episode'; 9 | export * from './show'; 10 | export * from './browse'; 11 | export * from './audiobook'; -------------------------------------------------------------------------------- /typings/player.d.ts: -------------------------------------------------------------------------------- 1 | import { SimplifiedTrack, Track } from "./track"; 2 | import { Episode } from "./episode"; 3 | import { ErrorResponse, ExternalUrl, Cursor, SpotifyType } from "./global"; 4 | 5 | /** 6 | * The repeat state of the context. 7 | */ 8 | export type RepeatState = 'track' | 'off' | 'context'; 9 | 10 | /** 11 | * Player error reason types. 12 | */ 13 | export type PlayerErrorReason = 14 | | 'NO_PREV_TRACK' 15 | | 'NO_NEXT_TRACK' 16 | | 'NO_SPECIFIC_TRACK' 17 | | 'ALREADY_PAUSED' 18 | | 'NOT_PAUSED' 19 | | 'NOT_PLAYING_TRACK' 20 | | 'NOT_PLAYING_LOCALLY' 21 | | 'NOT_PLAYING_CONTEXT' 22 | | 'ENDLESS_CONTEXT' 23 | | 'CONTEXT_DISALLOW' 24 | | 'ALREADY_PLAYING' 25 | | 'RATE_LIMITED' 26 | | 'REMOTE_CONTROL_DISALLOW' 27 | | 'DEVICE_NOT_CONTROLLABLE' 28 | | 'VOLUME_CONTROL_DISALLOW' 29 | | 'NO_ACTIVE_DEVICE' 30 | | 'PREMIUM_REQUIRED' 31 | | 'UNKNOWN'; 32 | 33 | /** 34 | * An object containing the details of a device. 35 | */ 36 | export interface Device { 37 | /** The device ID. */ 38 | id: string | null; 39 | /** If this device is the currently active device. */ 40 | is_active: boolean; 41 | /** If this device is currently in a private session. */ 42 | is_private_session: boolean; 43 | /** Whether controlling this device is restricted. At present if this is “true” then no Web API commands will be accepted by this device. */ 44 | is_restricted: boolean; 45 | /** The name of the device. */ 46 | name: string; 47 | /** The device type. */ 48 | type: 'computer' | 'smartphone' | 'speaker'; 49 | /** The current volume in percent. */ 50 | volume_percent?: number; 51 | } 52 | 53 | /** 54 | * The context object of the player. 55 | */ 56 | export interface PlayerContext { 57 | /** External URLs for this context. */ 58 | external_urls: ExternalUrl; 59 | /** A link to the Web API endpoint providing full details of the track. */ 60 | href: string; 61 | /** The object type. */ 62 | type: SpotifyType; 63 | /** The Spotify URI for the context. */ 64 | uri: string; 65 | } 66 | 67 | /** 68 | * The disallows from the CurrentlyPlayingContext object. 69 | */ 70 | export interface ContextDisallows { 71 | /** Interrupting playback. Optional field. */ 72 | interrupting_playback: boolean; 73 | /** Pausing. */ 74 | pausing?: boolean; 75 | /** Resuming. */ 76 | resuming?: boolean; 77 | /** Seeking playback location. */ 78 | seeking?: boolean; 79 | /** Skipping to the next context. */ 80 | skipping_next?: boolean; 81 | /** Skipping to the previous context. */ 82 | skipping_prev?: boolean; 83 | /** Toggling repeat context flag. */ 84 | toggling_repeat_context?: boolean; 85 | /** Toggling repeat track flag. */ 86 | toggling_repeat_track?: boolean; 87 | /** Toggling shuffle flag. */ 88 | toggling_shuffle?: boolean; 89 | /** Transfering playback between devices. */ 90 | transferring_playback?: boolean; 91 | } 92 | 93 | /** 94 | * The currently playing context of the player api. 95 | */ 96 | export interface CurrentlyPlayingContext extends CurrentlyPlaying { 97 | /** Allows to update the user interface based on which playback actions are available within the current context. */ 98 | actions: ContextDisallows; 99 | /** The device that is currently active. */ 100 | device: Device; 101 | /** The repeat state. */ 102 | repeat_state: RepeatState; 103 | /** The shuffle state. */ 104 | shuffle_state: 'on' | 'off'; 105 | } 106 | 107 | /** 108 | * The currently playing object of the player api. 109 | */ 110 | export interface CurrentlyPlaying { 111 | /** The context. */ 112 | context: PlayerContext | null; 113 | /** The object type of the currently playing item. */ 114 | currently_playing_type: 'track' | 'episode' | 'ad' | 'unknown'; 115 | /** If something is currently playing, return true. */ 116 | is_playing: boolean; 117 | /** Progress into the currently playing track or episode. */ 118 | progress_ms: number | null; 119 | /** The item of the context. */ 120 | item: Track | Episode | null; 121 | /** Unix Millisecond Timestamp when data was fetched. */ 122 | timestamp: number; 123 | } 124 | 125 | /** 126 | * The devices object of the player api. 127 | */ 128 | export interface Devices { 129 | /** A list of 0..n Device objects. */ 130 | devices: Device[]; 131 | } 132 | 133 | /** 134 | * The recently played object which is returned by the [Player.getRecentlyPlayed] function. 135 | */ 136 | export interface RecentlyPlayed { 137 | /** The cursors to check other pages of recently played. */ 138 | cursors: Cursor; 139 | /** A link to the Web API endpoint providing full details of the track. */ 140 | href: string; 141 | /** The maximum number of items in the response (as set in the query or by default). */ 142 | limit: number; 143 | /** URL to the next page of items. ( null if none) */ 144 | next?: string; 145 | /** The total number of items available to return. */ 146 | total: number; 147 | /** The items which have been recently played. */ 148 | items: { 149 | /** The track which has been played recently. */ 150 | track: Track, 151 | /** The timestamp when it was played. */ 152 | playedAt: string 153 | }[]; 154 | } 155 | 156 | /** 157 | * The play history object of the player api. 158 | */ 159 | export interface PlayHistory { 160 | /** The context the track was played from. */ 161 | context: PlayerContext; 162 | /** The date and time the track was played. */ 163 | played_at: string; 164 | /** The track the user listened to. */ 165 | track: SimplifiedTrack; 166 | } 167 | 168 | /** 169 | * The error response sent by the spotify player api during unusual status codes. 170 | */ 171 | export interface PlayerErrorResponse extends ErrorResponse { 172 | /** The reason for the error. */ 173 | reason: PlayerErrorReason; 174 | } -------------------------------------------------------------------------------- /typings/playlist.d.ts: -------------------------------------------------------------------------------- 1 | import { Followers, PublicUser } from "./user"; 2 | import { Track } from "./track"; 3 | import { Episode } from "./episode"; 4 | import { ExternalUrl, Image, Paging } from "./global"; 5 | 6 | /** 7 | * The structure containing the reference for the tracks of the playlist.. 8 | */ 9 | export interface PlaylistTracksReference { 10 | /** A link to the Web API endpoint where full details of the playlist’s tracks can be retrieved. */ 11 | href: string; 12 | /** The total number of tracks in playlist. */ 13 | total: number; 14 | } 15 | 16 | /** 17 | * The structure containing the details of the Spotify Track in the playlist.. 18 | */ 19 | export interface PlaylistTrack { 20 | /** The date and time the track or episode was added. */ 21 | added_at: string | null; 22 | /** The Spotify user who added the track or episode. */ 23 | added_by: PublicUser | null; 24 | /** Whether this track or episode is a local file or not. */ 25 | is_local: boolean; 26 | /** Information about the track or episode. */ 27 | track: Track | Episode | null; 28 | } 29 | 30 | /** 31 | * The structure containing the simplified details of the Spotify Playlist. 32 | */ 33 | export interface SimplifiedPlaylist { 34 | /** True if the owner allows other users to modify the playlist. */ 35 | collaborative: boolean; 36 | /** The playlist description. Only returned for modified, verified playlists, otherwise null. */ 37 | description: string | null; 38 | /** Known external URLs for this playlist. */ 39 | external_urls: ExternalUrl; 40 | /** A link to the Web API endpoint providing full details of the playlist. */ 41 | href: string; 42 | /** The Spotify ID for the playlist. */ 43 | id: string; 44 | /** Images for the playlist. The array may be empty or contain up to three images. */ 45 | images: Image[]; 46 | /** The name of the playlist. */ 47 | name: string; 48 | /** The user who owns the playlist. */ 49 | owner: PublicUser; 50 | /** The version identifier for the current playlist. Can be supplied in other requests to target a specific playlist version */ 51 | snapshot_id: string; 52 | /** A collection containing a link ( href ) to the Web API endpoint where full details of the playlist’s tracks can be retrieved, along with the total number of tracks in the playlist. */ 53 | tracks: PlaylistTracksReference; 54 | /** The Spotify URI for the playlist. */ 55 | uri: string; 56 | /** The object type: “playlist” */ 57 | type: 'playlist'; 58 | } 59 | 60 | /** 61 | * The structure containing the complete details of the Spotify Playlist. 62 | */ 63 | export interface Playlist extends Omit { 64 | /** Information about the followers of the playlist. */ 65 | followers: Followers; 66 | /** The playlist’s public/private status: true the playlist is public, false the playlist is private, null the playlist status is not relevant. */ 67 | public: boolean | null; 68 | /** Information about the tracks of the playlist. Note, a track object may be null. This can happen if a track is no longer available. */ 69 | tracks: PlaylistTrack[]; 70 | } 71 | 72 | /** 73 | * The structure returned by the [/browse/featured-playlists] endpoint. 74 | */ 75 | export interface FeaturedPlaylists { 76 | /** The message from the featured playlists. */ 77 | message: string; 78 | /** The list of the featured playlists wrapped in Paging object. */ 79 | playlists: Paging 80 | } 81 | 82 | /** 83 | * The query structure required by the [/users/{id}/playlists] enpoint. 84 | */ 85 | export interface CreatePlaylistQuery { 86 | /** The name for the new playlist, for example "Your Coolest Playlist". */ 87 | name: string; 88 | /** Defaults to true. If true the playlist will be public. */ 89 | public?: boolean; 90 | /** Defaults to false. If true the playlist will be collaborative. */ 91 | collaboratve?: boolean; 92 | /** The description for the playlist. */ 93 | description?: string; 94 | } -------------------------------------------------------------------------------- /typings/show.d.ts: -------------------------------------------------------------------------------- 1 | import { SimplifiedEpisode } from "./episode"; 2 | import { Copyright, ExternalUrl, Image, Paging, Saved } from "./global"; 3 | 4 | /** 5 | * The saved show object. 6 | */ 7 | export type SavedShow = Saved<'show', Show>; 8 | 9 | /** 10 | * The structure containing the complete details of the Spotify Show. 11 | */ 12 | export interface Show extends SimplifiedShow { 13 | /** A list of the show’s episodes. */ 14 | episodes: SimplifiedEpisode[] | Paging; 15 | } 16 | 17 | /** 18 | * The structure containing the simplified details of the Spotify Show. 19 | */ 20 | export interface SimplifiedShow { 21 | /** A list of the countries in which the show can be played, identified by their ISO 3166-1 alpha-2 code. */ 22 | available_markets: string[]; 23 | /** The copyright statements of the show. */ 24 | copyrights: Copyright[]; 25 | /** A description of the show. HTML tags are stripped away from this field, use html_description field in case HTML tags are needed. */ 26 | description: string; 27 | /** Whether or not the show has explicit content (true = yes it does; false = no it does not OR unknown). */ 28 | explicit: boolean; 29 | /** External URLs for this show. */ 30 | external_urls: ExternalUrl; 31 | /** A link to the Web API endpoint providing full details of the show. */ 32 | href: string; 33 | /** A description of the show. This field may contain HTML tags. */ 34 | html_description: string; 35 | /** The Spotify ID for the show. */ 36 | id: string; 37 | /** The cover art for the show in various sizes, widest first. */ 38 | images: Image[]; 39 | /** True if all of the show’s episodes are hosted outside of Spotify’s CDN. This field might be null in some cases. */ 40 | is_externally_hosted: boolean; 41 | /** A list of the languages used in the show, identified by their ISO 639 code. */ 42 | languages: string[]; 43 | /** The media type of the show. */ 44 | media_type: string; 45 | /** The name of the show. */ 46 | name: string; 47 | /** The publisher of the show. */ 48 | publisher: string; 49 | /** The object type: “show”. */ 50 | type: 'show'; 51 | /** The Spotify URI for the show. */ 52 | uri: string; 53 | } -------------------------------------------------------------------------------- /typings/track.d.ts: -------------------------------------------------------------------------------- 1 | import { SimplifiedAlbum } from './album'; 2 | import { Artist, SimplifiedArtist } from './artist'; 3 | import { 4 | ExternalID, 5 | ExternalUrl, 6 | Restriction, 7 | Saved, 8 | SpotifyType, 9 | } from './global'; 10 | 11 | /** 12 | * The saved track object. 13 | */ 14 | export type SavedTrack = Saved<'track', Track>; 15 | 16 | /** 17 | * The structure containing the simplified details of the Spotify Track. 18 | * 19 | * @see https://developer.spotify.com/documentation/web-api/reference/#object-simplifiedtrackobject 20 | */ 21 | export interface SimplifiedTrack { 22 | /** The artists who performed the track. Each artist object includes a link in href to more detailed information about the artist. */ 23 | artists: SimplifiedArtist[]; 24 | /** A list of the countries in which the track can be played. */ 25 | available_markets?: string[]; 26 | /** The disc number (usually 1 unless the album consists of more than one disc). */ 27 | disc_number: number; 28 | /** The track length in milliseconds. */ 29 | duration_ms: number; 30 | /** Whether or not the track has explicit lyrics ( true = yes it does; false = no it does not OR unknown). */ 31 | explicit: boolean; 32 | /** External URLs for this track. */ 33 | external_urls: ExternalUrl; 34 | /** A link to the Web API endpoint providing full details of the track. */ 35 | href: string; 36 | /** The Spotify ID for the track. */ 37 | id: string; 38 | /** Whether or not the track is from a local file. */ 39 | is_local: boolean; 40 | /** Part of the response when Track Relinking is applied. If true , the track is playable in the given market. Otherwise false. */ 41 | is_playable?: boolean; 42 | /** Part of the response when Track Relinking is applied and is only part of the response if the track linking, in fact, exists. */ 43 | linked_from?: LinkedTrack; 44 | /** The name of the track. */ 45 | name: string; 46 | /** A URL to a 30 second preview (MP3 format) of the track. */ 47 | preview_url: string; 48 | /** Included in the response when a content restriction is applied. */ 49 | restrictions: Restriction[]; 50 | /** The number of the track. If an album has several discs, the track number is the number on the specified disc. */ 51 | track_number: number; 52 | /** The object type: “track”. */ 53 | type: 'track'; 54 | /** The Spotify URI for the track. */ 55 | uri: string; 56 | } 57 | 58 | /** 59 | * The structure containing the complete details of the Spotify Track. 60 | * 61 | * @see https://developer.spotify.com/documentation/web-api/reference/#object-trackobject 62 | */ 63 | export interface Track extends SimplifiedTrack { 64 | /** The album on which the track appears. */ 65 | album: SimplifiedAlbum; 66 | /** The artists who performed the track. Each artist object includes a link in href to more detailed information about the artist. */ 67 | artists: Artist[]; 68 | /** Known external IDs for the track. */ 69 | external_ids: ExternalID; 70 | /** The popularity of the track. The value will be between 0 and 100, with 100 being the most popular. */ 71 | popularity: number; 72 | } 73 | 74 | /** 75 | * The structure of the spotify linked track object. 76 | * 77 | * @see https://developer.spotify.com/documentation/web-api/reference/#object-linkedtrackobject 78 | */ 79 | export interface LinkedTrack { 80 | /** A map of url name and the url. */ 81 | external_urls: ExternalUrl; 82 | /** The api url where you can get the full details of the linked track. */ 83 | href: string; 84 | /** The id of the linked track. */ 85 | id: string; 86 | /** The type of spotify object. */ 87 | type: SpotifyType; 88 | /** The uri of this object. */ 89 | uri: string; 90 | } 91 | 92 | /** 93 | * An object containing all the features of the audio. 94 | * 95 | * @see https://developer.spotify.com/documentation/web-api/reference/#object-audiofeaturesobject 96 | */ 97 | export interface AudioFeatures extends Omit { 98 | /** An HTTP URL to access the full audio analysis of this track. An access token is required to access this data. */ 99 | analysis_url: string; 100 | /** The Spotify ID of the track. */ 101 | id: string; 102 | /** A link to the Web API endpoint providing full details of the track. */ 103 | track_href: string; 104 | /** The object type: “audio_features” */ 105 | type: string; 106 | /** The Spotify URI for the track. */ 107 | uri: string; 108 | } 109 | 110 | /** 111 | * The tuneable track object. 112 | * 113 | * @see https://developer.spotify.com/documentation/web-api/reference/#object-tuneabletrackobject 114 | */ 115 | export interface TuneableTrack { 116 | /** A confidence measure from 0.0 to 1.0 of whether the track is acoustic. 1.0 represents high confidence the track is acoustic. */ 117 | acousticness: number; 118 | /** Danceability describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity. A value of 0.0 is least danceable and 1.0 is most danceable. */ 119 | danceability: number; 120 | /** The duration of the track in milliseconds. */ 121 | duration_ms: number; 122 | /** Energy is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity. */ 123 | energy: number; 124 | /** Predicts whether a track contains no vocals. “Ooh” and “aah” sounds are treated as instrumental in this context. Rap or spoken word tracks are clearly “vocal”. */ 125 | instrumentalness: number; 126 | /** The key the track is in. Integers map to pitches using standard Pitch Class notation. */ 127 | key: number; 128 | /** Detects the presence of an audience in the recording. Higher liveness values represent an increased probability that the track was performed live. */ 129 | liveness: number; 130 | /** The overall loudness of a track in decibels (dB). */ 131 | loudness: number; 132 | /** Mode indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived. Major is represented by 1 and minor is 0. */ 133 | mode: number; 134 | /** The popularity of the track. The value will be between 0 and 100, with 100 being the most popular. */ 135 | popularity: number; 136 | /** Speechiness detects the presence of spoken words in a track. */ 137 | speechiness: number; 138 | /** The overall estimated tempo of a track in beats per minute (BPM). */ 139 | tempo: number; 140 | /** An estimated overall time signature of a track. */ 141 | time_signature: number; 142 | /** A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. */ 143 | valence: number; 144 | } 145 | 146 | /** 147 | * Time interval object of [TrackAudioAnalysis]. 148 | * No documentation found for the object. 149 | */ 150 | export interface TimeInterval { 151 | /** The starting point (in seconds) of the time interval. */ 152 | start: number; 153 | /** The duration (in seconds) of the time interval. */ 154 | duration: number; 155 | /** The confidence, from 0.0 to 1.0, of the reliability of the interval. */ 156 | confidence: number; 157 | } 158 | 159 | /** 160 | * The element structure of the array of [AudioAnalysis.sections] property. 161 | * No documentation found for the object. 162 | */ 163 | export type AudioSection = TimeInterval & { 164 | /** The overall loudness of the section in decibels (dB). Loudness values are useful for comparing relative loudness of sections within tracks. */ 165 | loudness: number; 166 | /** The overall estimated tempo of the section in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece and derives directly from the average beat duration. */ 167 | tempo: number; 168 | /** The confidence, from 0.0 to 1.0, of the reliability of the tempo. Some tracks contain tempo changes or sounds which don't contain tempo (like pure speech) which would correspond to a low value in this field. */ 169 | tempo_confidence: number; 170 | /** The estimated overall key of the section. The values in this field ranging from 0 to 11 mapping to pitches using standard Pitch Class notation (E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on). If no key was detected, the value is -1. */ 171 | key: number; 172 | /** The confidence, from 0.0 to 1.0, of the reliability of the key. Songs with many key changes may correspond to low values in this field. */ 173 | key_confidence: number; 174 | /** Indicates the modality (major or minor) of a section, the type of scale from which its melodic content is derived. This field will contain a 0 for "minor", a 1 for "major", or a -1 for no result. Note that the major key (e.g. C major) could more likely be confused with the minor key at 3 semitones lower (e.g. A minor) as both keys carry the same pitches. */ 175 | mode: number; 176 | /** The confidence, from 0.0 to 1.0, of the reliability of the mode. */ 177 | mode_confidence: number; 178 | /** An estimated time signature. The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure). The time signature ranges from 3 to 7 indicating time signatures of "3/4", to "7/4". */ 179 | time_signature: number; 180 | /** The confidence, from 0.0 to 1.0, of the reliability of the time_signature. Sections with time signature changes may correspond to low values in this field. */ 181 | time_signature_confidence: number; 182 | }; 183 | 184 | /** 185 | * The element structure of the array of [AudioAnalysis.segments] property. 186 | * No documentation found for the object. 187 | */ 188 | export type AudioSegment = TimeInterval & { 189 | /** The onset loudness of the segment in decibels (dB). Combined with loudness_max and loudness_max_time, these components can be used to describe the "attack" of the segment. */ 190 | loudness_start: number; 191 | /** The peak loudness of the segment in decibels (dB). Combined with loudness_start and loudness_max_time, these components can be used to describe the "attack" of the segment. */ 192 | loudness_max: number; 193 | /** The segment-relative offset of the segment peak loudness in seconds. Combined with loudness_start and loudness_max, these components can be used to desctibe the "attack" of the segment. */ 194 | loudness_max_time: number; 195 | /** The offset loudness of the segment in decibels (dB). This value should be equivalent to the loudness_start of the following segment. */ 196 | loudness_end: number; 197 | /** Pitch content is given by a “chroma” vector, corresponding to the 12 pitch classes C, C#, D to B, with values ranging from 0 to 1 that describe the relative dominance of every pitch in the chromatic scale. For example a C Major chord would likely be represented by large values of C, E and G (i.e. classes 0, 4, and 7). */ 198 | pitches: number[]; 199 | /** Timbre is the quality of a musical note or sound that distinguishes different types of musical instruments, or voices. It is a complex notion also referred to as sound color, texture, or tone quality, and is derived from the shape of a segment’s spectro-temporal surface, independently of pitch and loudness. */ 200 | timbre: number[]; 201 | }; 202 | 203 | /** 204 | * The object structure of [AudioAnalysis.track] property. 205 | * No documentation found for the object. 206 | */ 207 | export interface AudioTrack { 208 | /** The exact number of audio samples analyzed from this track. See also analysis_sample_rate. */ 209 | num_samples: number; 210 | /** Length of the track in seconds. */ 211 | duration: number; 212 | /** This field will always contain the empty string. */ 213 | sample_md5: string; 214 | /** An offset to the start of the region of the track that was analyzed. (As the entire track is analyzed, this should always be 0.) */ 215 | offset_seconds: number; 216 | /** The length of the region of the track was analyzed, if a subset of the track was analyzed. (As the entire track is analyzed, this should always be 0.) */ 217 | window_seconds: number; 218 | /** The sample rate used to decode and analyze this track. May differ from the actual sample rate of this track available on Spotify. */ 219 | analysis_sample_rate: number; 220 | /** The number of channels used for analysis. If 1, all channels are summed together to mono before analysis. */ 221 | analysis_channels: number; 222 | /** The time, in seconds, at which the track's fade-in period ends. If the track has no fade-in, this will be 0.0. */ 223 | end_of_fade_in: number; 224 | /** The time, in seconds, at which the track's fade-out period starts. If the track has no fade-out, this should match the track's length. */ 225 | start_of_fade_out: number; 226 | /** The overall loudness of a track in decibels (dB). Loudness values are averaged across the entire track and are useful for comparing relative loudness of tracks. Loudness is the quality of a sound that is the primary psychological correlate of physical strength (amplitude). Values typically range between -60 and 0 db. */ 227 | loudness: number; 228 | /** The overall estimated tempo of a track in beats per minute (BPM). In musical terminology, tempo is the speed or pace of a given piece and derives directly from the average beat duration. */ 229 | tempo: number; 230 | /** The confidence, from 0.0 to 1.0, of the reliability of the tempo. */ 231 | tempo_confidence: number; 232 | /** An estimated time signature. The time signature (meter) is a notational convention to specify how many beats are in each bar (or measure). The time signature ranges from 3 to 7 indicating time signatures of "3/4", to "7/4". */ 233 | time_signature: number; 234 | /** The confidence, from 0.0 to 1.0, of the reliability of the time_signature. */ 235 | time_signature_confidence: number; 236 | /** The key the track is in. Integers map to pitches using standard Pitch Class notation. E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on. If no key was detected, the value is -1. */ 237 | key: number; 238 | /** The confidence, from 0.0 to 1.0, of the reliability of the key. */ 239 | key_confidence: number; 240 | /** Mode indicates the modality (major or minor) of a track, the type of scale from which its melodic content is derived. Major is represented by 1 and minor is 0. */ 241 | mode: number; 242 | /** The confidence, from 0.0 to 1.0, of the reliability of the mode. */ 243 | mode_confidence: number; 244 | /** An Echo Nest Musical Fingerprint (ENMFP) codestring for this track. */ 245 | codestring: string; 246 | /** A version number for the Echo Nest Musical Fingerprint format used in the codestring field. */ 247 | code_version: number; 248 | /** An EchoPrint codestring for this track. */ 249 | echoprintstring: string; 250 | /** A version number for the EchoPrint format used in the echoprintstring field. */ 251 | echoprint_version: number; 252 | /** A Synchstring for this track. */ 253 | synchstring: string; 254 | /** A version number for the Synchstring used in the synchstring field. */ 255 | synch_version: number; 256 | /** A Rhythmstring for this track. The format of this string is similar to the Synchstring. */ 257 | rhythmstring: string; 258 | /** A version number for the Rhythmstring used in the rhythmstring field. */ 259 | rhythm_version: number; 260 | } 261 | 262 | /** 263 | * The object structure of [AudioAnalysis.meta] property. 264 | * No documentation found for the object. 265 | */ 266 | export interface AudioAnalysisMeta { 267 | /** The version of the Analyzer used to analyze this track. */ 268 | analyzer_version: string; 269 | /** The platform used to read the track's audio data. */ 270 | platform: string; 271 | /** A detailed status code for this track. If analysis data is missing, this code may explain why. */ 272 | detailed_status: string; 273 | /** The return code of the analyzer process. 0 if successful, 1 if any errors occurred. */ 274 | status_code: number; 275 | /** The Unix timestamp (in seconds) at which this track was analyzed. */ 276 | timestamp: number; 277 | /** The amount of time taken to analyze this track. */ 278 | analysis_time: number; 279 | /** The method used to read the track's audio data. */ 280 | input_process: string; 281 | } 282 | 283 | /** 284 | * The object structure returned by [/audio-analysis/{id}] endpoint. 285 | * No documentation found for the object. 286 | */ 287 | export interface AudioAnalysis { 288 | /** The time intervals of the bars throughout the track. A bar (or measure) is a segment of time defined as a given number of beats. */ 289 | bars: TimeInterval[]; 290 | /** The time intervals of beats throughout the track. A beat is the basic time unit of a piece of music; for example, each tick of a metronome. Beats are typically multiples of tatums. */ 291 | beats: TimeInterval[]; 292 | /** A tatum represents the lowest regular pulse train that a listener intuitively infers from the timing of perceived musical events (segments). */ 293 | tatums: TimeInterval[]; 294 | /** Sections are defined by large variations in rhythm or timbre, e.g. chorus, verse, bridge, guitar solo, etc. Each section contains its own descriptions of tempo, key, mode, time_signature, and loudness. */ 295 | sections: AudioSection[]; 296 | /** Each segment contains a roughly conisistent sound throughout its duration. */ 297 | segments: AudioSegment[]; 298 | /** No documentation found for the object. */ 299 | track: AudioTrack; 300 | /** No documentation found for the object. */ 301 | meta: AudioAnalysisMeta; 302 | } 303 | -------------------------------------------------------------------------------- /typings/user.d.ts: -------------------------------------------------------------------------------- 1 | import { Artist } from "./artist"; 2 | import { Image, ExternalUrl } from "./global"; 3 | 4 | /** 5 | * The product type in the User object. 6 | */ 7 | export type UserProductType = "free" | "open" | "premium"; 8 | 9 | /** 10 | * The token type in the AccessToken object. 11 | */ 12 | export type AccessTokenType = "bearer"; 13 | 14 | /** 15 | * The spotify api object containing the details of the followers of a user. 16 | */ 17 | export interface Followers { 18 | /** The api url where you can get the list of followers. This will be null as the spotify api does not supports it at the moment. */ 19 | href: string | null; 20 | /** The total number of followers. */ 21 | total: number; 22 | } 23 | 24 | /** 25 | * The spotify api object containing the information of explicit content. 26 | * 27 | * @see https://developer.spotify.com/documentation/web-api/reference/#object-explicitcontentsettingsobject 28 | */ 29 | export interface ExplicitContentSettings { 30 | /** When true, indicates that explicit content should not be played. */ 31 | filter_enabled: boolean; 32 | /** When true, indicates that the explicit content setting is locked and can’t be changed by the user. */ 33 | filter_locked: boolean; 34 | } 35 | 36 | /** 37 | * The spotify api object containing details of a user's public and private details. 38 | * 39 | * @see https://developer.spotify.com/documentation/web-api/reference/#object-privateuserobject 40 | */ 41 | export interface PrivateUser extends PublicUser { 42 | /** The country of the user, as set in the user’s account profile. */ 43 | country: string; 44 | /** The user’s email address, as entered by the user when creating their account. */ 45 | email: string; 46 | /** The user’s Spotify subscription level. */ 47 | product?: UserProductType; 48 | /** The user’s explicit content settings. */ 49 | explicit_content?: ExplicitContentSettings; 50 | /** The user’s profile image. */ 51 | images: Image[]; 52 | /** Information about the followers of the user. */ 53 | followers: Followers; 54 | } 55 | 56 | /** 57 | * The spotify api object containing details of a user's public details. 58 | * 59 | * @see https://developer.spotify.com/documentation/web-api/reference/#object-publicuserobject 60 | */ 61 | export interface PublicUser { 62 | /** The name displayed on the user’s profile. null if not available. */ 63 | display_name: string | null; 64 | /** A link to the Web API endpoint for this user. */ 65 | href: string; 66 | /** The Spotify user ID for the user. */ 67 | id: string; 68 | /** The Spotify URI for the user. */ 69 | uri: string; 70 | /** The Spotify object type which will be 'User'. */ 71 | type: 'user' | 'artist'; 72 | /** The user’s profile image. */ 73 | images?: Image[]; 74 | /** Information about the followers of the user. */ 75 | followers?: Followers; 76 | /** Known external URLs for this user. */ 77 | external_urls: ExternalUrl; 78 | } 79 | 80 | /** 81 | * The cursor paging object for followed artists. 82 | */ 83 | export interface FollowedArtistCursorPaging { 84 | /** A link to the Web API endpoint returning the full result of the request. */ 85 | href: string; 86 | /** The maximum number of items in the response (as set in the query or by default). */ 87 | limit: number; 88 | /** URL to the next page of items. (null if none) */ 89 | next: string; 90 | /** The cursors used to find the next set of items. */ 91 | cursors: { 92 | /** The cursor to use as key to find the next page of items. */ 93 | after: string; 94 | /** The cursor to use as key to find the previous page of items. */ 95 | before: string; 96 | }; 97 | /** The total number of items available to return. */ 98 | total: number; 99 | /** The requested data. */ 100 | items: Artist[]; 101 | } 102 | 103 | /** 104 | * An object containing artists followed by the user. 105 | */ 106 | export interface FollowedArtistsResults { 107 | /** The paging object giving you an array of artists followed by the user. */ 108 | artists: FollowedArtistCursorPaging; 109 | } 110 | 111 | /** 112 | * The spotify api object containing the user's access token. 113 | * 114 | * @see https://developer.spotify.com/documentation/web-api/concepts/access-token 115 | */ 116 | export interface AccessToken { 117 | /** The token used to access the Spotify Web API */ 118 | access_token: string; 119 | /** The type of token which is of type bearer */ 120 | token_type: AccessTokenType; 121 | /** The time after which the access token expires */ 122 | expires_in: number; 123 | } --------------------------------------------------------------------------------