apple-music-web-api
Advanced tools
Comparing version 0.2.3 to 0.3.0
import { Song, ListResponse } from "./Song"; | ||
import { Playlist } from "./Playlist"; | ||
import { Storefront } from "./Storefront"; | ||
export declare const initializeAppleMusicApi: (developerToken: string) => AppleMusicApiInterface; | ||
@@ -9,4 +10,5 @@ declare type TrackPayload = { | ||
declare type AppleMusicApiInterface = { | ||
fetchSong: (id: string) => Promise<Song>; | ||
fetchSongs: (ids: string[]) => Promise<ListResponse<Song>>; | ||
fetchSong: (storefront: string, id: string) => Promise<Song>; | ||
fetchSongs: (storefront: string, ids: string[]) => Promise<ListResponse<Song>>; | ||
getMyStorefront: (userToken: string) => Promise<ListResponse<Storefront>>; | ||
fetchLibraryPlaylists: (userToken: string) => AsyncIterableIterator<Playlist>; | ||
@@ -13,0 +15,0 @@ createPlaylist: (userToken: string, attributes: { |
@@ -128,10 +128,17 @@ "use strict"; | ||
}; | ||
var storefront = "us"; | ||
var appleMusicApi = function (callApi, pageApi) { return ({ | ||
fetchSong: function (id) { return callApi("/v1/catalog/" + storefront + "/songs/" + id); }, | ||
fetchSongs: function (ids) { | ||
return callApi("/v1/catalog/" + storefront + "/songs?ids=" + ids | ||
fetchSong: function (storefront, id) { | ||
return callApi("/v1/catalog/" + encodeURIComponent(storefront) + "/songs/" + encodeURIComponent(id)); | ||
}, | ||
fetchSongs: function (storefront, ids) { | ||
return callApi("/v1/catalog/" + encodeURIComponent(storefront) + "/songs?ids=" + ids | ||
.map(encodeURIComponent) | ||
.join(",")); | ||
}, | ||
getMyStorefront: function (userToken) { | ||
return callApi("/v1/me/storefront", { | ||
method: "GET", | ||
userToken: userToken | ||
}); | ||
}, | ||
fetchLibraryPlaylists: function (userToken) { | ||
@@ -138,0 +145,0 @@ return pageApi("/v1/me/library/playlists", { method: "GET", userToken: userToken }); |
{ | ||
"name": "apple-music-web-api", | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"description": "Apple Music API SDK for JS", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
48283
11
302
0