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

easy-spotify-ts

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-spotify-ts - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

7

dist/EasySpotify.d.ts

@@ -5,3 +5,3 @@ import { AxiosInstance, AxiosPromise, AxiosRequestConfig } from "axios";

import { Artist } from "./models/Artist";
import { PagingTracks } from "./models/Paging";
import { PagingTracks, PagingAlbums } from "./models/Paging";
export interface GetAlbumTracksOptions {

@@ -15,2 +15,5 @@ limit?: number;

}
export interface GetArtistAlbumsOptions extends GetAlbumTracksOptions {
include_groups?: string;
}
export default class EasySpotify {

@@ -28,4 +31,6 @@ config: EasySpotifyConfig;

getArtist(id: string): Promise<Artist>;
getArtists(ids: string[]): Promise<Artist[]>;
getArtistAlbums(id: string, options?: GetArtistAlbumsOptions): Promise<PagingAlbums>;
buildRequest(endpoint: string, params?: AxiosRequestConfig["params"], method?: string): AxiosPromise<any>;
private buildHeaders;
}

@@ -51,2 +51,3 @@ "use strict";

var Album_1 = require("./models/Album");
var Artist_1 = require("./models/Artist");
var EasySpotify = /** @class */ (function () {

@@ -175,2 +176,55 @@ function EasySpotify(config) {

};
EasySpotify.prototype.getArtists = function (ids) {
return __awaiter(this, void 0, void 0, function () {
var response, artists, err_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("artists", { ids: "" + ids })];
case 1:
response = _a.sent();
if (response.data.artists) {
artists = response.data.artists.map(function (artist) {
return new Artist_1.Artist(artist);
});
return [2 /*return*/, artists];
}
else {
throw new Error("No artists found");
}
return [3 /*break*/, 3];
case 2:
err_5 = _a.sent();
throw err_5;
case 3: return [2 /*return*/];
}
});
});
};
EasySpotify.prototype.getArtistAlbums = function (id, options) {
return __awaiter(this, void 0, void 0, function () {
var response, err_6;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.buildRequest("artists/" + id + "/albums", options)];
case 1:
response = _a.sent();
if (response.data) {
return [2 /*return*/, response.data];
}
else {
throw new Error("Could not find any tracks for provided id");
}
return [3 /*break*/, 3];
case 2:
err_6 = _a.sent();
throw err_6;
case 3: return [2 /*return*/];
}
});
});
};
EasySpotify.prototype.buildRequest = function (endpoint, params, method) {

@@ -177,0 +231,0 @@ if (method === void 0) { method = "get"; }

@@ -7,6 +7,19 @@ import { SimplifiedArtist } from "./Artist";

import { PagingTracks } from "./Paging";
export declare class Album {
export interface SimplifiedAlbum {
album_group?: string;
album_type: string;
artists: SimplifiedArtist[];
available_markets: string[];
external_urls: ExternalUrls;
href: string;
id: string;
images: Image[];
name: string;
type: string;
uri: string;
}
export declare class Album implements SimplifiedAlbum {
album_type: string;
artists: SimplifiedArtist[];
available_markets: string[];
copyrights: Copyright[];

@@ -13,0 +26,0 @@ external_ids: ExternalIDS;

1

dist/models/Album.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Generated by https://quicktype.io
var Album = /** @class */ (function () {

@@ -5,0 +4,0 @@ function Album(response) {

@@ -12,3 +12,9 @@ import { ExternalUrls } from "./ExternalUrls";

}
export interface Artist extends SimplifiedArtist {
export declare class Artist implements SimplifiedArtist {
external_urls: ExternalUrls;
href: string;
id: string;
name: string;
type: string;
uri: string;
followers: Followers;

@@ -18,2 +24,3 @@ genres: string[];

popularity: number;
constructor(response: any);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Artist = /** @class */ (function () {
function Artist(response) {
this.external_urls = response.external_urls;
this.href = response.href;
this.id = response.id;
this.name = response.name;
this.type = response.type;
this.uri = response.type;
this.followers = response.followers;
this.genres = response.genres;
this.images = response.images;
this.popularity = response.popularity;
}
return Artist;
}());
exports.Artist = Artist;

@@ -5,1 +5,3 @@ "use strict";

exports.Album = Album_1.Album;
var Artist_1 = require("./Artist");
exports.Artist = Artist_1.Artist;

@@ -0,1 +1,2 @@

import { SimplifiedAlbum } from "./Album";
import { SimplifiedTrack } from "./SimplifiedTrack";

@@ -14,1 +15,4 @@ export interface Paging {

}
export interface PagingAlbums extends Paging {
items: SimplifiedAlbum[];
}
{
"name": "easy-spotify-ts",
"version": "0.1.2",
"version": "0.1.3",
"description": "A Spotify Web API library in Typescript",

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

@@ -22,3 +22,3 @@ # EasySpotifyTS - A Spotify Web Api TS Wrapper

import { EasySpotify, EasySpotifyConfig } from "easy-spotify-ts";
import { Album } from "easy-spotify-ts/models";
import { Album } from "easy-spotify-ts/dist/models";

@@ -69,3 +69,3 @@ const spotify = new EasySpotify(new EasySpotifyConfig("your-api-token"));

const artist = await spotify.getArtist("0OdUWJ0sBjDrqHygGUXeCF");
// do something with the albums
// do something with the artist
// artist.id

@@ -75,2 +75,27 @@ // artist.genres

```
### getArtists(id: string[]): Promise\<Artist[]\>
This method returns an array of artist objects for the given ids.
> Check [official documentation page](https://developer.spotify.com/documentation/web-api/reference/artists/get-several-artists/)
```ts
const artists = await spotify.getArtists(["0oSGxfWSnnOXhD2fKuz2Gy,3dBVyJ7JuOMt4GE9607Qin"]);
// do something with the artists
// artists[0].id
// artist[2].genres
// artist[1].followers.total
```
### getArtistAlbums(id: string, options?: GetArtistAlbumsOptions): Promise\<PagingAlbums\>
This method returns an array of simplified album objects for the given artist id.
> Check [official documentation page](https://developer.spotify.com/documentation/web-api/reference/artists/get-several-artists/)
```ts
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
```

@@ -77,0 +102,0 @@ ## <a name="features"></a> Features to implement

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