Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spotify-node-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spotify-node-wrapper - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

2

package.json
{
"name": "spotify-node-wrapper",
"version": "1.0.3",
"version": "1.1.0",
"description": "A simplified interface to interact with the Spotify Web API.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,2 +5,8 @@ import fetch from 'node-fetch';

/**
* Get a list of categories used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
* @async
* @param {string} accessToken - The access token for the user to get spotify categories for.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the categories.
*/
const getSeveralBrowseCategories = async (accessToken) => {

@@ -19,2 +25,9 @@ const options = {

/**
* Get a single category used to tag items in Spotify (on, for example, the Spotify player's "Browse" tab).
* @async
* @param {string} accessToken - The access token for the user to get spotify categories for.
* @param {string} categoryID - The ID of the category to retrieve information for.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the category.
*/
const getSingleBrowseCategory = async (accessToken, categoryID) => {

@@ -21,0 +34,0 @@ const options = {

@@ -5,2 +5,10 @@ import fetch from 'node-fetch';

/**
* Get Spotify catalog information for a single chapter identified by their unique Spotify ID.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} chapterID - The ID of the chapter to retrieve information for.
* @throws {Error} Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the chapter information.
*/
const getSingleChapter = async (accessToken, chapterID) => {

@@ -19,2 +27,10 @@ const options = {

/**
* Get Spotify catalog information for several chapters based on their Spotify IDs.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfChapterID - An array of Spotify IDs representing the chapters to retrieve information for.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the chapter information.
*/
const getSeveralChapters = async (accessToken, listOfChapterID) => {

@@ -21,0 +37,0 @@ if (listOfChapterID.length > 50) {

@@ -5,2 +5,10 @@ import fetch from 'node-fetch';

/**
* Get Spotify catalog information for a single episode identified by their unique Spotify ID.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} episodeID - The ID of the episode to retrieve information for.
* @throws {Error} Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the episode information.
*/
const getEpisode = async (accessToken, episodeID) => {

@@ -19,2 +27,10 @@ const options = {

/**
* Get Spotify catalog information for several episodes based on their Spotify IDs.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfEpisodeID - An array of Spotify IDs representing the episodes to retrieve information for.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the episode information.
*/
const getSeveralEpisodes = async (accessToken, listOfEpisodeID) => {

@@ -51,2 +67,9 @@ if (listOfEpisodeID.length > 50) {

/**
* Get a list of episodes the user has saved in their Spotify library.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the episode information.
*/
const getUsersSavedEpisodes = async (accessToken) => {

@@ -65,2 +88,10 @@ const options = {

/**
* Save one or more episodes to the user's Spotify library.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfEpisodeID - An array of Spotify IDs representing the episodes to save.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the episode information.
*/
const saveEpisodesForCurrentUser = async (accessToken, listOfEpisodeID) => {

@@ -96,2 +127,10 @@ if (listOfEpisodeID.length > 50) {

/**
* Remove one or more episodes from the user's Spotify library.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfEpisodeID - An array of Spotify IDs representing the episodes to remove.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the episode information.
*/
const removeUsersSavedEpisodes = async (accessToken, listOfEpisodeID) => {

@@ -127,2 +166,10 @@ if (listOfEpisodeID.length > 50) {

/**
* Check if one or more episodes is already saved in the current Spotify user's library.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfEpisodeID - An array of Spotify IDs representing the episodes to check.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the episode information.
*/
const checkUsersSavedEpisodes = async (accessToken, listOfEpisodeID) => {

@@ -129,0 +176,0 @@ if (listOfEpisodeID.length > 50) {

@@ -5,2 +5,9 @@ import fetch from 'node-fetch';

/**
* Get a list of available genre seeds for recommendations.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the available genre seeds.
*/
const getAvailableGenreSeeds = async (accessToken) => {

@@ -7,0 +14,0 @@ const options = {

@@ -7,2 +7,9 @@ import { json } from "express";

/**
* Get the next item from the Spotify API using the next URL parameter
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {string} nextURL - The next URL to fetch the next item from the Spotify API
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the next page of results.
*/
const getNext = async (accessToken, nextURL) => {

@@ -9,0 +16,0 @@ const options = {

@@ -5,2 +5,9 @@ import fetch from 'node-fetch';

/**
* Get a list of available markets for tracks.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the available markets.
*/
const getAvailableMarkets = async (accessToken) => {

@@ -7,0 +14,0 @@ const options = {

@@ -5,2 +5,9 @@ import fetch from 'node-fetch';

/**
* Get information about the user's current playback state, including track, track progress, and active device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const getPlaybackState = async (accessToken) => {

@@ -19,2 +26,10 @@ const options = {

/**
* Transfer the user's playback to a new device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} deviceID - The ID of the device to transfer playback to.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const transferPlayback = async (accessToken, deviceID) => {

@@ -42,2 +57,9 @@ const options = {

/**
* Get information about the user's currently available devices.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the available devices.
*/
const getAvailableDevices = async (accessToken) => {

@@ -56,2 +78,9 @@ const options = {

/**
* Get the user's current playback, including track, track progress, and active device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's current playback.
*/
const getCurrentlyPlayingTrack = async (accessToken) => {

@@ -70,2 +99,10 @@ const options = {

/**
* Starts the playback on the specified device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} deviceID - The ID of the device
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const startPlayback = async (accessToken, deviceID) => {

@@ -89,2 +126,10 @@ const options = {

/**
* Pauses the playback on the specified device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} deviceID - The ID of the device
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const pausePlayback = async (accessToken, deviceID) => {

@@ -108,2 +153,10 @@ const options = {

/**
* Skips to the next track in the queue for the specified device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} deviceID - The ID of the device
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const skipToNextTrack = async (accessToken, deviceID) => {

@@ -127,2 +180,10 @@ const options = {

/**
* Skips to the previous track in the queue for the specified device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} deviceID - The ID of the device
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const skipToPreviousTrack = async (accessToken, deviceID) => {

@@ -146,2 +207,11 @@ const options = {

/**
* Seeks to the specified position in the currently playing track for the specified device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} deviceID - The ID of the device
* @param {number} positionMs - The position in milliseconds to seek to. Must be a positive number.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const seekToPosition = async (accessToken, deviceID, positionMs) => {

@@ -165,2 +235,11 @@ const options = {

/**
* Sets the repeat mode for the specified device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} state - The state of the repeat mode. Must be one of 'context', 'track', or 'off'.
* @param {string} deviceID - The ID of the device
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const setRepeatMode = async (accessToken, state, deviceID) => {

@@ -188,2 +267,11 @@ if (!["context", "track", "off"].includes(state)) {

/**
* Sets the volume for the specified device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {number} volumePercent - The volume percentage to set. Must be a number between 0 and 100.
* @param {string} deviceID - The ID of the device
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const setPlaybackVolume = async (accessToken, volumePercent, deviceID) => {

@@ -211,2 +299,11 @@ if (volumePercent < 0 || volumePercent > 100) {

/**
* Toggles shuffle mode for the specified device.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {boolean} state - The state of the shuffle mode. Must be either 'true' or 'false'.
* @param {string} deviceID - The ID of the device
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const togglePlaybackShuffle = async (accessToken, state, deviceID) => {

@@ -234,2 +331,11 @@ if (typeof state !== "boolean") {

/**
* Get the recently played tracks from the playback queue.
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {number} limit - The number of tracks to return. Must be between 1 and 50.
* @param {number} before - A Unix timestamp in milliseconds. Returns all tracks played before this timestamp. Must be before the current time.
* @param {number} after - A Unix timestamp in milliseconds. Returns all tracks played after this timestamp. Must be before the current time.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's recently played tracks.
*/
const getRecentlyPlayedTracks = async (accessToken, limit = 20, before = undefined, after = undefined) => {

@@ -257,2 +363,9 @@ let url = `${baseURI}me/player/recently-played?limit=${limit}`;

/**
* Get the user's playback queue.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback queue.
*/
const getUserQueue = async (accessToken) => {

@@ -270,2 +383,11 @@ const options = {

/**
* Adds an item to the user's playback queue.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} uri - The URI of the item to add to the playback queue.
* @param {string} deviceID - The ID of the device
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playback state.
*/
const addItemToPlaybackQueue = async (accessToken, uri, deviceID) => {

@@ -272,0 +394,0 @@ const options = {

@@ -5,2 +5,10 @@ import fetch from 'node-fetch';

/**
* Get the playlist with the specified playlist ID
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {*} playlistID - The ID of the playlist to be retrieved
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist information.
*/
const getPlaylist = async (accessToken, playlistID) => {

@@ -18,2 +26,14 @@ const options = {

/**
* Change the details of a playlist to the specified information.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistID - The ID of the playlist to be updated.
* @param {string} name - The new name of the playlist.
* @param {boolean} isPublic - Whether the playlist should be public or not.
* @param {boolean} isCollaborative - Whether the playlist should be collaborative or not.
* @param {string} description - The new description of the playlist.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist information.
*/
const changePlaylistDetails = async (accessToken, playlistID, name, isPublic, isCollaborative, description) => {

@@ -44,2 +64,10 @@ const options = {

/**
* Get the items in the playlist with the specified playlist ID.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistID - The ID of the playlist to get the items of.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist items.
*/
const getPlaylistItems = async (accessToken, playlistID) => {

@@ -57,2 +85,15 @@ const options = {

/**
* Update the items in the playlist with the specified playlist ID.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistID - The ID of the playlist to update the items of.
* @param {string[]} uris - An array of Spotify track URIs to add to the playlist.
* @param {number} rangeStart - The position of the first item to replace.
* @param {number} insertBefore - The position where the new items should be inserted.
* @param {number} rangeLength - The number of items to be replaced.
* @param {string} snapshotID - The playlist's snapshot ID against which you want to make the changes.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist items.
*/
const updatePlaylistItems = async (accessToken, playlistID, uris, rangeStart, insertBefore, rangeLength, snapshotID) => {

@@ -84,2 +125,12 @@ const options = {

/**
* Add items to the playlist with the specified playlist ID.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistID - The ID of the playlist to update the items of.
* @param {string[]} uris - An array of Spotify track URIs to add to the playlist.
* @param {number} position - The position where the new items should be inserted.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist items.
*/
const addItemsToPlaylist = async (accessToken, playlistID, uris, position) => {

@@ -112,2 +163,12 @@ if (uris.length === 0 || uris.length > 100) {

/**
* Remove items from the playlist with the specified playlist ID.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistID - The ID of the playlist to update the items of.
* @param {string[]} uris - An array of Spotify track URIs to add to the playlist.
* @param {string} snapshotID - The playlist's snapshot ID against which you want to make the changes.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist items.
*/
const removePlaylistItems = async (accessToken, playlistID, uris, snapshotID) => {

@@ -136,2 +197,9 @@ const options = {

/**
* Get a list of the current user's playlists.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playlists.
*/
const getCurrentUserPlaylists = async (accessToken) => {

@@ -149,2 +217,10 @@ const options = {

/**
* Get a list of the current user's playlists.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} userID - The ID of the user whose playlists are to be retrieved.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's playlists.
*/
const getUserPlaylists = async (accessToken, userID) => {

@@ -162,2 +238,14 @@ const options = {

/**
* Create a new playlist for the current user.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} userID - The ID of the user to create the playlist for.
* @param {string} name - The name of the playlist.
* @param {boolean} isPublic - Whether the playlist should be public or not.
* @param {boolean} isCollaborative - Whether the playlist should be collaborative or not.
* @param {string} description - A description of the playlist.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist.
*/
const createPlaylist = async (accessToken, userID, name, isPublic, isCollaborative, description) => {

@@ -188,2 +276,9 @@ const options = {

/**
* Get an object consisting of Spotify featured playlists.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the featured playlists.
*/
const getFeaturedPlaylists = async (accessToken) => {

@@ -201,2 +296,10 @@ const options = {

/**
* Get a list of Spotify category playlists.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} categoryID - The ID of the category to get playlists for.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the featured playlists.
*/
const getCategoryPlaylists = async (accessToken, categoryID) => {

@@ -214,2 +317,10 @@ const options = {

/**
* Get the playlist cover image given the ID.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistID - The ID of the playlist to get the cover image for.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist cover image.
*/
const getPlaylistCoverImage = async (accessToken, playlistID) => {

@@ -227,2 +338,11 @@ const options = {

/**
* Add a custom cover image to a playlist.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistID - The ID of the playlist to add the cover image to.
* @param {string} image - The image to use as the cover image.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the playlist cover image.
*/
const addCustomPlaylistCoverImage = async (accessToken, playlistID, image) => {

@@ -229,0 +349,0 @@ const options = {

@@ -5,2 +5,10 @@ import fetch from 'node-fetch';

/**
* Search Spotify for an item.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {string} query - The search query.
* @param {string[]} types - The types of items to search for.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the search results.
*/
const searchForItem = async (accessToken, query, types) => {

@@ -7,0 +15,0 @@ const options = {

@@ -5,2 +5,10 @@ import fetch from 'node-fetch';

/**
* Get Spotify catalog information for a single show identified by its unique Spotify ID.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} showID - The Spotify ID for the show.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the show information.
*/
const getShow = async (accessToken, showID) => {

@@ -19,2 +27,10 @@ const options = {

/**
* Get Spotify catalog information for several shows based on their Spotify IDs.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfShowID - The Spotify IDs for the shows. Maximum: 50 IDs.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the show information.
*/
const getSeveralShows = async (accessToken, listOfShowID) => {

@@ -51,2 +67,10 @@ if (listOfShowID.length > 50) {

/**
* Get Spotify catalog information about an show’s episodes. Optional parameters can be used to limit the number of episodes returned.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} showID - The Spotify ID for the show.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the show's episodes information.
*/
const getShowEpisodes = async (accessToken, showID) => {

@@ -65,2 +89,9 @@ const options = {

/**
* Get the current user's saved shows
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's saved shows.
*/
const getUsersSavedShows = async (accessToken) => {

@@ -79,2 +110,10 @@ const options = {

/**
* Save one or more shows to the current user's library.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfShowID - The Spotify IDs for the shows. Maximum: 50 IDs.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing a status code and message.
*/
const saveShowsForCurrentUser = async (accessToken, listOfShowID) => {

@@ -119,2 +158,10 @@ if (listOfShowID.length > 50) {

/**
* Remove one or more shows from the current user's library.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfShowID - The Spotify IDs for the shows. Maximum: 50 IDs.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing a status code and message.
*/
const removeUsersSavedShows = async (accessToken, listOfShowID) => {

@@ -156,2 +203,10 @@ if (listOfShowID.length > 50) {

/**
* Check if one or more shows are already saved in the current Spotify user’s library.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} listOfShowID - The Spotify IDs for the shows. Maximum: 50 IDs.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing a status code and message.
*/
const checkUsersSavedShows = async (accessToken, listOfShowID) => {

@@ -158,0 +213,0 @@ if (listOfShowID.length > 50) {

@@ -5,2 +5,10 @@ import fetch from 'node-fetch';

/**
* Get a track from the Spotify API.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {string} trackID - The Spotify ID of the track.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the track.
*/
const getTrack = async (accessToken, trackID) => {

@@ -19,2 +27,10 @@ const options = {

/**
* Get a list of tracks from the Spotify API.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {array} listOfTrackID - The list of track IDs to retrieve from the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the tracks.
*/
const getSeveralTracks = async (accessToken, listOfTrackID) => {

@@ -51,2 +67,9 @@ if (listOfTrackID.length > 50) {

/**
* Get the current user's saved tracks from the Spotify API.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the tracks.
*/
const getUsersSavedTracks = async (accessToken) => {

@@ -65,2 +88,10 @@ const options = {

/**
* Save one or more tracks to the current user's Spotify library.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {array} listOfTrackID - The list of track IDs to save to the user's library.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing the response code.
*/
const saveTracksForCurrentUser = async (accessToken, listOfTrackID) => {

@@ -102,2 +133,10 @@ if (listOfTrackID.length > 50) {

/**
* Remove one or more tracks from the current user's Spotify library.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {array} listOfTrackID - The list of track IDs to remove from the user's library.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing the response code.
*/
const removeUsersSavedTracks = async (accessToken, listOfTrackID) => {

@@ -139,2 +178,10 @@ if (listOfTrackID.length > 50) {

/**
* Check if one or more tracks is already saved in the current Spotify user's "Your Music" library.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {array} listOfTrackID - The list of track IDs to check if they are saved in the user's library.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing the response code.
*/
const checkUsersSavedTracks = async (accessToken, listOfTrackID) => {

@@ -174,2 +221,10 @@ if (listOfTrackID.length > 50) {

/**
* Get audio features for multiple tracks based on their Spotify IDs.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {array} listOfTrackID - The list of track IDs to get audio features for.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing the audio features.
*/
const getTracksAudioFeatures = async (accessToken, listOfTrackID) => {

@@ -206,2 +261,10 @@ if (listOfTrackID.length > 100) {

/**
* Get audio features for a singular track based on the Spotify IDs.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {array} trackID - A track ID to get audio features for.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing the audio features.
*/
const getTrackAudioFeatures = async (accessToken, trackID) => {

@@ -220,2 +283,10 @@ const options = {

/**
* Get audio analysis for a singular track based on the Spotify IDs.
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {array} trackID - A track ID to get audio analysis for.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing the audio analysis.
*/
const getTrackAudioAnalysis = async (accessToken, trackID) => {

@@ -234,2 +305,10 @@ const options = {

/**
* Get recommendations based on seeds (artists, tracks, and genres).
* @async
* @param {string} accessToken - The access token for the user to be authenticated with the Spotify API.
* @param {object} queryParams - The query parameters to be passed in the request.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to a JSON object containing the recommendations.
*/
const getRecommendations = async (accessToken, queryParams) => {

@@ -236,0 +315,0 @@ const options = {

@@ -5,2 +5,9 @@ import fetch from 'node-fetch';

/**
* Get the current user's profile.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the current user's profile.
*/
const getCurrentUserProfile = async (accessToken) => {

@@ -19,2 +26,10 @@ const options = {

/**
* Get the current user's top artists or tracks.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} type - The type of item to get. Valid values are 'artists' or 'tracks'.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the current user's top artists or tracks.
*/
const getUsersTopItems = async (accessToken, type) => {

@@ -41,2 +56,10 @@ const validTypes = ['artists', 'tracks'];

/**
* Get a user's profile.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} userId - The user's Spotify user ID.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's profile.
*/
const getUserProfile = async (accessToken, userId) => {

@@ -55,2 +78,10 @@ const options = {

/**
* Let a user follow a playlist.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistId - The ID of the playlist to follow.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's profile.
*/
const followPlaylist = async (accessToken, playlistId, isPublic = true) => {

@@ -78,2 +109,10 @@ const options = {

/**
* Let a user unfollow a playlist.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistId - The ID of the playlist to unfollow.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the user's profile.
*/
const unfollowPlaylist = async (accessToken, playlistId) => {

@@ -97,2 +136,9 @@ const options = {

/**
* Get the current user's followed artists.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the current user's followed artists.
*/
const getFollowedArtists = async (accessToken) => {

@@ -111,2 +157,10 @@ const options = {

/**
* Follow one or more artists or users.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} ids - The IDs of the artists or users to follow.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the current user's followed artists.
*/
const followArtistsOrUsers = async (accessToken, ids) => {

@@ -137,2 +191,10 @@ if (ids.length === 0 || ids.length > 50) {

/**
* Unfollow one or more artists or users.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} ids - The IDs of the artists or users to unfollow.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the current user's followed artists.
*/
const unfollowArtistsOrUsers = async (accessToken, ids) => {

@@ -163,2 +225,10 @@ if (ids.length === 0 || ids.length > 50) {

/**
* Check if one or more artists or users are followed by the current user.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string[]} ids - The IDs of the artists or users to check.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the current user's followed artists.
*/
const checkUserFollowsArtistsOrUsers = async (accessToken, ids) => {

@@ -187,2 +257,11 @@ if (ids.length === 0 || ids.length > 50) {

/**
* Check if one or more users follow a playlist.
* @async
* @param {string} accessToken - The access token for authentication with the Spotify API.
* @param {string} playlistId - The ID of the playlist to check.
* @param {string[]} userIds - The IDs of the users to check.
* @throws {Error} - Will throw an error if there's an issue with the API request or response.
* @returns {Promise<object>} A Promise that resolves to the JSON object containing the current user's followed artists.
*/
const checkUsersFollowPlaylist = async (accessToken, playlistId, userIds) => {

@@ -189,0 +268,0 @@ if (userIds.length === 0 || userIds.length > 5) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc