mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Update spotify-api typings (#35739)
* Add recently played tracks Copied from234ea0f5b2(@JMPerez) and0bc4006352(@JMPerez) * Add custom playlist image upload Copied from53f7cec142(@lrholmes) * Add typings for player endpoints Copied from20ceacbdc3(@cloughney) * Fix seeds, add missing props to device, and add search response Copied from51c87d34ca(@amelialaundy) * Create type declaration for play operation Copied from932e72d7fb(@pduchesne) * Add myself to Definitions by * Specify TypeScript version
This commit is contained in:
parent
583ac5de40
commit
a73328b20a
121
types/spotify-api/index.d.ts
vendored
121
types/spotify-api/index.d.ts
vendored
@ -1,7 +1,9 @@
|
||||
// Type definitions for The Spotify Web API (including changes March 29th 2016)
|
||||
// Project: https://developer.spotify.com/web-api/
|
||||
// Definitions by: Niels Kristian Hansen Skovmand <https://github.com/skovmand>
|
||||
// Magnar Ovedal Myrtveit <https://github.com/Stadly>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
// Release comments:
|
||||
// -----------------
|
||||
@ -84,9 +86,9 @@ declare namespace SpotifyApi {
|
||||
min_tempo?: number,
|
||||
min_time_signature?: number,
|
||||
min_valence?: number,
|
||||
seed_artists?: string, // Comma separated string
|
||||
seed_genres?: string, // Comma separated string
|
||||
seed_tracks?: string, // Comma separated string
|
||||
seed_artists?: string[] | string, // Array of strings or Comma separated string
|
||||
seed_genres?: string[] | string, // Array of strings or Comma separated string
|
||||
seed_tracks?: string[] | string, // Array of strings or Comma separated string
|
||||
target_acousticness?: number
|
||||
target_danceability?: number
|
||||
target_duration_ms?: number
|
||||
@ -103,6 +105,38 @@ declare namespace SpotifyApi {
|
||||
target_valence?: number
|
||||
}
|
||||
|
||||
interface RecentlyPlayedParameterObject {
|
||||
limit?: number;
|
||||
after?: number;
|
||||
before?: number;
|
||||
}
|
||||
|
||||
interface TransferPlaybackParameterObject {
|
||||
play?: boolean;
|
||||
}
|
||||
|
||||
interface TrackRelinkingParameterObject {
|
||||
market?: string;
|
||||
}
|
||||
|
||||
interface DeviceSpecificParameterObject {
|
||||
device_id?: string;
|
||||
context_uri?: string;
|
||||
position_ms?: number;
|
||||
uris?: string[];
|
||||
offset?: Object;
|
||||
}
|
||||
|
||||
interface PlayParameterObject {
|
||||
device_id?: string;
|
||||
context_uri?: string;
|
||||
uris?: string[];
|
||||
offset?: {
|
||||
position?: number;
|
||||
uri?: string;
|
||||
};
|
||||
position_ms?: number;
|
||||
}
|
||||
|
||||
//
|
||||
// Responses from the Spotify Web API in the same order as in the API endpoint docs seen here:
|
||||
@ -415,6 +449,14 @@ declare namespace SpotifyApi {
|
||||
*/
|
||||
interface UsersTopTracksResponse extends PagingObject<TrackObjectFull> {}
|
||||
|
||||
/**
|
||||
* Get a User’s Recently Played Tracks
|
||||
*
|
||||
* GET /v1/me/player/recently-played
|
||||
* https://developer.spotify.com/web-api/get-users-top-artists-and-tracks/
|
||||
*/
|
||||
interface UsersRecentlyPlayedTracksResponse extends CursorBasedPagingObject<PlayHistoryObject> {}
|
||||
|
||||
/**
|
||||
* Get recommendations based on seeds
|
||||
*
|
||||
@ -473,6 +515,16 @@ declare namespace SpotifyApi {
|
||||
tracks: PagingObject<TrackObjectFull>
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for artists/albums/tracks/playlists
|
||||
*
|
||||
* GET /v1/search?type=album
|
||||
* https://developer.spotify.com/web-api/search-item/
|
||||
*/
|
||||
interface SearchResponse extends Partial<ArtistSearchResponse>, Partial<AlbumSearchResponse>, Partial<TrackSearchResponse>, Partial<PlaylistSearchResponse> {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a track
|
||||
*
|
||||
@ -579,6 +631,14 @@ declare namespace SpotifyApi {
|
||||
*/
|
||||
interface ReplacePlaylistTracksResponse extends VoidResponse {}
|
||||
|
||||
/**
|
||||
* Upload a Custom Playlist Cover Image
|
||||
*
|
||||
* PUT /v1/users/{user_id}/playlists/{playlist_id}/images
|
||||
* https://developer.spotify.com/web-api/upload-a-custom-playlist-cover-image/
|
||||
*/
|
||||
interface UploadCustomPlaylistCoverImageReponse extends VoidResponse {}
|
||||
|
||||
/**
|
||||
* Check if Users Follow a Playlist
|
||||
*
|
||||
@ -587,7 +647,13 @@ declare namespace SpotifyApi {
|
||||
*/
|
||||
interface UsersFollowPlaylistReponse extends Array<boolean> {}
|
||||
|
||||
interface UserDevicesResponse {
|
||||
devices: UserDevice[];
|
||||
}
|
||||
|
||||
interface CurrentPlaybackResponse extends CurrentlyPlayingObject, PlaybackObject {}
|
||||
|
||||
interface CurrentlyPlayingResponse extends CurrentlyPlayingObject {}
|
||||
|
||||
//
|
||||
// Objects from the Object Models of the Spotify Web Api, ordered alphabetically.
|
||||
@ -700,6 +766,7 @@ declare namespace SpotifyApi {
|
||||
*/
|
||||
interface CursorObject {
|
||||
after: string
|
||||
before?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@ -776,7 +843,7 @@ declare namespace SpotifyApi {
|
||||
limit: number,
|
||||
next: string,
|
||||
cursors: CursorObject,
|
||||
total: number
|
||||
total?: number
|
||||
}
|
||||
|
||||
/**
|
||||
@ -939,4 +1006,50 @@ declare namespace SpotifyApi {
|
||||
uri: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Context Object
|
||||
* [](https://developer.spotify.com/web-api/object-model/#context-object)
|
||||
*/
|
||||
interface ContextObject {
|
||||
type: ContextObjectType;
|
||||
href: string | null;
|
||||
external_urls: ExternalUrlObject | null;
|
||||
uri: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Play History Object
|
||||
* [](https://developer.spotify.com/web-api/web-api-personalization-endpoints/get-recently-played/#play-history-object)
|
||||
*/
|
||||
interface PlayHistoryObject {
|
||||
track: TrackObjectSimplified;
|
||||
played_at: string;
|
||||
context: ContextObject;
|
||||
}
|
||||
|
||||
interface PlaybackObject {
|
||||
shuffle_state: boolean;
|
||||
repeat_state: PlaybackRepeatState;
|
||||
}
|
||||
|
||||
interface CurrentlyPlayingObject {
|
||||
timestamp: number;
|
||||
device: UserDevice;
|
||||
progress_ms: number | null;
|
||||
is_playing: boolean;
|
||||
item: TrackObjectFull | null;
|
||||
context: ContextObject | null;
|
||||
}
|
||||
|
||||
interface UserDevice {
|
||||
id: string | null;
|
||||
is_active: boolean;
|
||||
is_restricted: boolean;
|
||||
name: string;
|
||||
type: string;
|
||||
volume_percent: number | null;
|
||||
}
|
||||
|
||||
type ContextObjectType = 'artist' | 'playlist' | 'album';
|
||||
type PlaybackRepeatState = 'off' | 'track' | 'context';
|
||||
}
|
||||
|
||||
@ -7063,4 +7063,111 @@ const replacePlaylistTracks : SpotifyApi.ReplacePlaylistTracksResponse = {};
|
||||
* GET /v1/users/{user_id}/playlists/{playlist_id}/followers/contains
|
||||
* https://developer.spotify.com/web-api/check-user-following-playlist/
|
||||
*/
|
||||
const checkUserFollowsPlaylist : SpotifyApi.UsersFollowPlaylistReponse = [true, false, true];
|
||||
const checkUserFollowsPlaylist : SpotifyApi.UsersFollowPlaylistReponse = [true, false, true];
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get current user's recently played tracks
|
||||
*
|
||||
* GET /v1/me/player/recently-played
|
||||
* https://developer.spotify.com/web-api/web-api-personalization-endpoints/get-recently-played/
|
||||
*/
|
||||
const getMyRecentlyPlayedTracks : SpotifyApi.UsersRecentlyPlayedTracksResponse = {
|
||||
"items": [
|
||||
{
|
||||
"track": {
|
||||
"artists": [
|
||||
{
|
||||
"external_urls": {
|
||||
"spotify": "https://open.spotify.com/artist/5INjqkS1o8h1imAzPqGZBb"
|
||||
},
|
||||
"href": "https://api.spotify.com/v1/artists/5INjqkS1o8h1imAzPqGZBb",
|
||||
"id": "5INjqkS1o8h1imAzPqGZBb",
|
||||
"name": "Tame Impala",
|
||||
"type": "artist",
|
||||
"uri": "spotify:artist:5INjqkS1o8h1imAzPqGZBb"
|
||||
}
|
||||
],
|
||||
"available_markets": [
|
||||
"CA",
|
||||
"MX",
|
||||
"US"
|
||||
],
|
||||
"disc_number": 1,
|
||||
"duration_ms": 108546,
|
||||
"explicit": false,
|
||||
"external_urls": {
|
||||
"spotify": "https://open.spotify.com/track/2gNfxysfBRfl9Lvi9T3v6R"
|
||||
},
|
||||
"href": "https://api.spotify.com/v1/tracks/2gNfxysfBRfl9Lvi9T3v6R",
|
||||
"id": "2gNfxysfBRfl9Lvi9T3v6R",
|
||||
"name": "Disciples",
|
||||
"preview_url": "https://p.scdn.co/mp3-preview/6023e5aac2123d098ce490488966b28838b14fa2",
|
||||
"track_number": 9,
|
||||
"type": "track",
|
||||
"uri": "spotify:track:2gNfxysfBRfl9Lvi9T3v6R"
|
||||
},
|
||||
"played_at": "2016-12-13T20:44:04.589Z",
|
||||
"context": {
|
||||
"uri": "spotify:artist:5INjqkS1o8h1imAzPqGZBb",
|
||||
"external_urls": {
|
||||
"spotify": "https://open.spotify.com/artist/5INjqkS1o8h1imAzPqGZBb"
|
||||
},
|
||||
"href": "https://api.spotify.com/v1/artists/5INjqkS1o8h1imAzPqGZBb",
|
||||
"type": "artist"
|
||||
}
|
||||
},
|
||||
{
|
||||
"track": {
|
||||
"artists": [
|
||||
{
|
||||
"external_urls": {
|
||||
"spotify": "https://open.spotify.com/artist/5INjqkS1o8h1imAzPqGZBb"
|
||||
},
|
||||
"href": "https://api.spotify.com/v1/artists/5INjqkS1o8h1imAzPqGZBb",
|
||||
"id": "5INjqkS1o8h1imAzPqGZBb",
|
||||
"name": "Tame Impala",
|
||||
"type": "artist",
|
||||
"uri": "spotify:artist:5INjqkS1o8h1imAzPqGZBb"
|
||||
}
|
||||
],
|
||||
"available_markets": [
|
||||
"CA",
|
||||
"MX",
|
||||
"US"
|
||||
],
|
||||
"disc_number": 1,
|
||||
"duration_ms": 467586,
|
||||
"explicit": false,
|
||||
"external_urls": {
|
||||
"spotify": "https://open.spotify.com/track/2X485T9Z5Ly0xyaghN73ed"
|
||||
},
|
||||
"href": "https://api.spotify.com/v1/tracks/2X485T9Z5Ly0xyaghN73ed",
|
||||
"id": "2X485T9Z5Ly0xyaghN73ed",
|
||||
"name": "Let It Happen",
|
||||
"preview_url": "https://p.scdn.co/mp3-preview/05dee1ad0d2a6fa4ad07fbd24ae49d58468e8194",
|
||||
"track_number": 1,
|
||||
"type": "track",
|
||||
"uri": "spotify:track:2X485T9Z5Ly0xyaghN73ed"
|
||||
},
|
||||
"played_at": "2016-12-13T20:42:17.016Z",
|
||||
"context": {
|
||||
"uri": "spotify:artist:5INjqkS1o8h1imAzPqGZBb",
|
||||
"external_urls": {
|
||||
"spotify": "https://open.spotify.com/artist/5INjqkS1o8h1imAzPqGZBb"
|
||||
},
|
||||
"href": "https://api.spotify.com/v1/artists/5INjqkS1o8h1imAzPqGZBb",
|
||||
"type": "artist"
|
||||
}
|
||||
}
|
||||
],
|
||||
"next": "https://api.spotify.com/v1/me/player/recently-played?before=1481661737016&limit=2",
|
||||
"cursors": {
|
||||
"after": "1481661844589",
|
||||
"before": "1481661737016"
|
||||
},
|
||||
"limit": 2,
|
||||
"href": "https://api.spotify.com/v1/me/player/recently-played?limit=2"
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user