EasySpotifyTS - A Spotify Web Api TS Wrapper
This is a TypeScript library that wraps Spotify Web API to make your life easier. It's still not published and in development. See features list to check what else I plan to add to this library.
There is also a JS version here.
Installation and Usage
This library is easier than the JS version to use, because it doesn't have any external dependencies. Also, if you like type hints, or intellisense, here you get them evem for responses that come from Spotify.
TypeScript environment
Install easy-spotify-ts, and then just import and use the library:
terminal
$ npm install node-fetch easy-spotify --save
app.ts
import { EasySpotify, EasySpotifyConfig } from "easy-spotify-ts";
import { Album } from "easy-spotify-ts/models";
const spotify = new EasySpotify(new EasySpotifyConfig("your-api-token"));
spotify.getAlbums(["382ObEPsp2rxGrnsizN5TX", "1A2GTWGtFfWp7KSQTwWOyo"], {market: "ES"}).then((albums) => {
console.log(albums);
}).catch((error) => {
console.log(error);
});
Methods available
getAlbum(id: string, options?: GetAlbumOptions): Promise<Album>
This method returns an album object with the provided id.
Check official documentation page
const album = await spotify.getAlbum("382ObEPsp2rxGrnsizN5TX", {market: "ES"});
getAlbums(ids: string[], options?: GetAlbumOptions): Promise<Album[]>
This method returns an array of album objects with the provided ids.
Check official documentation page
const albums = await spotify.getAlbums(["382ObEPsp2rxGrnsizN5TX", "1A2GTWGtFfWp7KSQTwWOyo"], {market: "ES"});
getAlbumTracks(id: string, options?: GetAlbumTracksOptions): Promise<PagingTracks>
This method returns a paging object with the tracks for an album given it's id. Tracks are in items property.
Check official documentation page
const tracks = await spotify.getAlbumTracks("1A2GTWGtFfWp7KSQTwWOyo", {limit: 10, offset: 1, market: "ES"});
getArtist(id: string): Promise<Artist>
This method returns an complete artist object for the given id.
Check official documentation page
const artist = await spotify.getArtist("0OdUWJ0sBjDrqHygGUXeCF");
Features to implement
Authors
License
This project is licensed under the MIT License - see the LICENSE.md file for details