### **Fast-paced and versatile Spotify API wrapper for Node.**
npm install spotifyx- Search API
- Browse API
- Albums API
- Artists API
- Tracks API
- Shows API
- Episodes API
- User API
- Markets API
Using NPM:
```
npm install --save spotifyx
Using Yarn:
``
yarn add spotifyx
CommonJS
`js`
const Spotify = require("spotifyx");
ES6
`js`
import Spotify from "spotifyx";
`js
import Spotify from "spotifyx";
(async () => {
const client = new Spotify({
clientId: "a-cool-id",
clientSecret: "a-cool-secret",
});
await client.login();
console.log(await client.search("Null Magma", ["artist"]));
})();
`
Key:
- 🄲 – Class declaration
- 🄿 – Property
- 🄼 – Method
_Most typedefs are from Spotify's documentation._
Constructs a new Spotify API client.
#### Parameters:
- credentials – Client credentials to log inclientId
- – Client IDclientSecret
- – Client secretredirectUrl?
- – URL to redirect to
#### Returns:
- Spotify – The newly created client
#### Example:
`js`
const client = new Spotify({
clientId: "a-cool-id",
clientSecret: "a-cool-secret",
});
---
readonly string
The client's current access token
---
Browser
The client's Spotify browse API
---
Artists
The client's Spotify artists API
---
Albums
The client's Spotify albums API
---
Tracks
The client's Spotify tracks API
---
Episodes
The client's Spotify episodes API
---
Shows
The client's Spotify shows API
---
Logs the client in and creates an access token.
#### Parameters:
#### Returns:
- string – The newly created access token
#### Example:
`js`
await client.login();
---
Searches Spotify using Spotify's search API.
#### Parameters:
- query – Search querytypes
- – Object types to search foroptions?
- – Search optionsmarket?
- – Market to search withinlimit?
- – Search results limitoffset?
- – Search results offsetincludeExternal?
- – Include externals in results
#### Returns:
- SearchResponse – Search results
#### Example:
`js`
const results = await client.search("Null Magma", ["artist"]);
---
Obtains a user from Spotify using an ID.
#### Parameters:
- id – The user's ID
#### Returns:
- PublicUserObject? – User obtained from the user ID, or undefined if no user was found
#### Example:
`js`
const user = await client.user("a-cool-id");
---
Gets all the markets.
#### Parameters:
#### Returns:
- string[] – All markets
#### Example:
`js`
const markets = await client.markets();
Wrapper for Spotify's browse API.
_private_
---
Fetches newest releases.
#### Parameters:
- options? – Fetch optionscountry?
- – Country codelimit?
- – Fetch limitoffset?
- – Fetch offset
#### Returns:
- BrowseNewReleasesResponse – Fetched new releases
#### Example:
`js`
const releases = await client.browse.newReleases({
limit: 25,
offset: 25,
});
---
Fetches featured playlists.
#### Parameters:
- options? – Fetch optionscountry?
- – Country codelocale?
- – Localetimestamp?
- – Timestamplimit?
- – Fetch limitoffset?
- – Fetch offset
#### Returns:
- BrowseFeaturedPlaylistsResponse – Fetched featured playlists
#### Example:
`js`
const playlists = await client.browse.featuredPlaylists();
---
Fetches all categories.
#### Parameters:
- options? – Fetch optionscountry?
- – Country codelocale?
- – Localelimit?
- – Fetch limitoffset?
- – Fetch offset
#### Returns:
- BrowseAllCategoriesResponse – Fetched categories
#### Example:
`js`
const categories = await client.browse.allCategories();
---
Fetches a category.
#### Parameters:
- category – The categoryoptions?
- – Fetch optionscountry?
- – Country codelocale?
- – Locale
#### Returns:
- BrowseCategoryResponse – Fetched categories
#### Example:
`js`
const category = await client.browse.category("party");
---
Fetches a category's playlists.
#### Parameters:
- category – The categoryoptions?
- – Fetch optionscountry?
- – Country codelimit?
- – Fetch limitoffset?
- – Fetch offset
#### Returns:
- PagingObject – Fetched playlists
#### Example:
`js`
const playlists = await client.browse.categoryPlaylists("party");
---
Fetches a category's playlists.
#### Parameters:
- seeds – Seedsartists
- – Seed artistsgenres
- – Seed genrestracks
- - Seed tracksoptions?
- – Fetch options
- _Not available_
#### Returns:
- BrowseRecommendationsResponse – Fetched category platlists
#### Example:
_Not available_
---
Fetches recommendation genres.
#### Parameters:
#### Returns:
- string[] – Fetched genres
#### Example:
`js`
const genres = await client.browse.recommendationGenres();
Wrapper for Spotify's artists API.
_private_
---
Retrieves an artist or multiple artists.
#### Parameters:
- ids – Can either be an ID or array of IDs.
#### Returns:
_If a single ID is used:_
- ArtistsSingleArtistResponse – The artist retrieved
_If an array of IDs is used:_
- ArtistsMultipleArtistsResponse – The artists retrieved
#### Example:
`js`
const artists = await client.artists.get(["a-id", "another-id"]);
---
Retrieves an artist's top tracks.
#### Parameters:
- id – Artist ID
#### Returns:
- ArtistsTopTracksResponse – The artist's top tracks
#### Example:
`js`
const topTracks = await client.artists.topTracks("an-id");
---
Retrieves an artist's related artists.
#### Parameters:
- id – Artist ID
#### Returns:
- ArtistsRelatedArtistsResponse – The artist's related artists
#### Example:
`js`
const related = await client.artists.related("an-id");
---
Retrieves an artist's albums.
#### Parameters:
- id – Artist ID
#### Returns:
- ArtistsAlbumsResponse – The artist's albums
#### Example:
`js`
const albums = await client.artists.albums("an-id");
Wrapper for Spotify's shows API.
_private_
---
Retrieves an album or multiple albums.
#### Parameters:
- ids – Can either be an ID or array of IDs.options?
- – Fetch optionsmarket?
- – Country code
#### Returns:
_If a single ID is used:_
- AlbumsSingleAlbumResponse – The album retrieved
_If an array of IDs is used:_
- AlbumsMultipleAlbumsResponse – The albums retrieved
#### Example:
`js`
const albums = await client.albums.get(["an-id", "another-id"]);
---
Retrieves an album's tracks.
#### Parameters:
- id – The album's IDoptions?
- – Fetch optionsmarket
- – Country codelimit
- – Fetch limitoffset
- – Fetch offset
#### Returns:
- AlbumsTracksResponse – The album's tracks
#### Example:
`js`
const tracks = await client.albums.tracks("an-id");
Wrapper for Spotify's tracks API.
_private_
---
Retrieves a track or multiple tracks.
#### Parameters:
- ids – Can either be an ID or array of IDs.options?
- – Fetch optionsmarket?
- – Country code
#### Returns:
_If a single ID is used:_
- TracksSingleTrackResponse – The track retrieved
_If an array of IDs is used:_
- TracksMultipleTracksResponse – The tracks retrieved
---
Retrieves a track or multiple tracks' audio features.
#### Parameters:
- ids – Can either be an ID or array of IDs.options?
- – Fetch optionsmarket?
- – Country code
#### Returns:
_If a single ID is used:_
- TracksSingleTrackAudioFeatureResponse – The audio feature retrieved
_If an array of IDs is used:_
- TracksMultipleTracksAudioFeaturesResponse – The audio features retrieved
Retrieves a track's audio analysis
#### Parameters:
- id – Track ID
#### Returns:
- AudioAnalysisObject – The audio analysis
Wrapper for Spotify's episodes API.
_private_
---
Retrieves an episode or multiple episodes.
#### Parameters:
- ids – Can either be an ID or array of IDs.options?
- – Fetch optionsmarket?
- – Country code
#### Returns:
_If a single ID is used:_
- EpisodesSingleEpisodeResponse – The episode retrieved
_If an array of IDs is used:_
- EpisodesMultipleEpisodesResponse – The episodes retrieved
Wrapper for Spotify's shows API.
_private_
---
Retrieves a show or multiple shows.
#### Parameters:
- ids – Can either be an ID or array of IDs.options?
- – Fetch optionsmarket?
- – Country code
#### Returns:
_If a single ID is used:_
- ShowsSingleShowResponse – The show retrieved
_If an array of IDs is used:_
- ShowsMultipleShowsResponse – The shows retrieved
#### Example:
`js`
const shows = await client.shows.get(["an-id", "another-id"]);
---
Retrieves a show's episodes.
#### Parameters:
- id – The show's ID
#### Returns:
- ShowsEpisodesResponse – The episodes retrieved
#### Example:
`js``
const episodes = await client.shows.episodes("an-id");
- Include other three authorization flows
- Use refresh tokens
- Spotify user auth service
- Authorization scopes
- Access to user-related APIs
- Access to other APIs