Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
easy-spotify-ts
Advanced tools
This is a Javascript library written in Typescript that wraps Spotify Web API to make your spotify responses and requests benefit from autocompletion. It's still not published and in development. See features list to check what else I plan to add to this library.
This library is lightweight and only have one external dependency, which is axios, a powerful HTTP requests library. Also, if you like type hints, or intellisense, with easy-spotify-ts you have them for responses that come from Spotify Web API.
Install easy-spotify-ts, and then just import and use the library:
terminal
$ npm install easy-spotify-ts --save
app.js
const { EasySpotify, EasySpotifyConfig } = require("easy-spotify-ts");
// or with ES Modules:
import { EasySpotify, EasySpotifyConfig } from 'easy-spotify-ts';
const spotify = new EasySpotify(new EasySpotifyConfig("your-api-token"));
// Get multiple albums!
spotify.getAlbums(["382ObEPsp2rxGrnsizN5TX", "1A2GTWGtFfWp7KSQTwWOyo"], {market: "ES"}).then((albums) => {
// do something with albums
console.log(albums);
}).catch((error) => {
// catch an error, like invalid token or invalid request
console.log(error);
});
This method returns an album object with the provided id.
const album = await spotify.getAlbum("382ObEPsp2rxGrnsizN5TX", {market: "ES"});
// do something with the data
// album.tracks.items[0].preview_url
This method returns an array of album objects with the provided ids.
const albums = await spotify.getAlbums(["382ObEPsp2rxGrnsizN5TX", "1A2GTWGtFfWp7KSQTwWOyo"], {market: "ES"});
// do something with the albums
// albums[0].tracks.items[0].name
This method returns a paging object with the tracks for an album given it's id. Tracks are in items property.
const tracks = await spotify.getAlbumTracks("1A2GTWGtFfWp7KSQTwWOyo", {limit: 10, offset: 1, market: "ES"});
// do something with the albums
// tracks.total
// tracks.limit
// tracks.items[0].artists[1].name
This method returns an complete artist object for the given id.
const artist = await spotify.getArtist("0OdUWJ0sBjDrqHygGUXeCF");
// do something with the artist
// artist.id
// artist.genres
// artist.followers.total
This method returns an array of artist objects for the given ids.
const artists = await spotify.getArtists(["0oSGxfWSnnOXhD2fKuz2Gy,3dBVyJ7JuOMt4GE9607Qin"]);
// do something with the artists
// artists[0].id
// artist[2].genres
// artist[1].followers.total
This method returns an array of simplified album objects for the given artist id.
const artistAlbums = await spotify.getArtistAlbums("4aawyAB9vmqN3uQ7FjRGTy", {
include_groups: "appears_on",
limit: 3,
offset: 0,
market: "ES"
});
// do something with the albums
// artistAlbums.items.length
// artistAlbums.items[0].id
// artistAlbums.offset
This method returns an array of up to 10 top Track objects for the given artist id.
Check official documentation page
const topTracks = await spotfiy.getArtistTopTracks("43ZHCT0cAZBISjO8DG9PnE", {market: "SE"});
// do something with tracks
// topTracks[0].name
// topTracks[2].disc_number
// topTracks[9].preview_url
This method returns an array of related artists for the given artist id.
Check official documentation page
const relatedArtists = await spotfiy.getArtistRelatedArtists("43ZHCT0cAZBISjO8DG9PnE");
// do something with artists
// relatedArtists[0].followers.total
// relatedArtists[1].images[0].url
// relatedArtists[3].genres[0]
This method returns an paging object of albums for the given query.
Check official documentation page
const albums = await spotify.searchAlbums("Rock", {limit: 2});
// do something with albums
// albums.items[0].id
// albums.items[1].artists
This method returns an paging object of artists for the given query.
Check official documentation page
const artists = await spotify.searchArtists("Elvis", {limit: 2});
// do something with artists
// artists.items[0].name
// artists.items[1].uri
This method returns an paging object of playlists for the given query.
Check official documentation page
const playlists = await spotify.searchPlaylists("abba", {limit: 2, market: "US"});
// do something with playlists
// playlists.items[0].tracks
// playlists.items[1].owner
This method returns an paging object of tracks for the given query.
Check official documentation page
const tracks = await spotify.searchTracks("love", {limit: 2});
// do something with playlists
// tracks.items[0].artists
// tracks.items[1].preview_url
This method returns an object that may contain albums, artists, playlists or tracks paging object. Under options, you should define the type as comma-separated list of wich ones you want (in singular).
Check official documentation page
const result = await spotify.search("love", {type: "artist,playlist", limit: 2});
// do something with result
// result.artists.items[0].id
// result.playlists.total
// result.playlists.items[0].name
// result.tracks -> undefined
// result.albums -> undefined
This method returns a single category used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
Check official documentation page
const result = await spotify.getBrowseCategory("party", {country: "US"});
// do something with result
// result.href
// result.icons[0].height
This method returns a paged list of Spotify playlists tagged with a particular category.
Check official documentation page
const result = await spotify.getBrowseCategoryPlaylists("party", {country: "US"});
// do something with result
// result.href
// result.items[0].description
// result.limit
// result.offset
This method returns a list of categories used to tag items in Spotify (on, for example, the Spotify player’s “Browse” tab).
Check official documentation page
const result = await spotify.getBrowseListOfCategories({country: "US", limit: 10});
// do something with result
// result.href
// result.items[0].id
// result.limit
// result.offset
This method returns a list of Spotify featured playlists (shown, for example, on a Spotify player’s ‘Browse’ tab).
Check official documentation page
const result = await spotify.getBrowseFeaturedPlaylists({country: "US", limit: 10});
// do something with result
// result.message
// result.playlists.items[0].name
// result.playlists.limit
// result.playlists.offset
This method returns a list of new album releases featured in Spotify (shown, for example, on a Spotify player’s “Browse” tab).
Check official documentation page
const result = await spotify.getBrowseNewReleases({country: "US", limit: 10});
// do something with result
// result.message
// result.albums.items[0].name
// result.albums.limit
// result.albums.offset
This method can create a playlist-style listening experience based on seed artists, tracks and genres. There is a huge query options to use, I suggest you to really check the documentation, though, each target_* field has a hint when you type that should help you know what you're doing.
Check official documentation page
const result = await spotify.getBrowseRecommendations(
{
limit: 10,
seed_tracks: ["4NHQUGzhtTLFvgF5SZesLK", "1VBflYyxBhnDc9uVib98rw"],
target_loudness: 0.2,
min_instrumentalness: 0.4,
max_instrumentalness: 0.9,
}
);
// do something with result
// result.seeds
// result.tracks
Bruno Lombardi |
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
A Spotify Web API library in Typescript
The npm package easy-spotify-ts receives a total of 0 weekly downloads. As such, easy-spotify-ts popularity was classified as not popular.
We found that easy-spotify-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.