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

spotify-wrapper

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spotify-wrapper - npm Package Compare versions

Comparing version 1.0.5 to 2.0.0

173

dist/spotify-wrapper.umd.js

@@ -7,5 +7,5 @@ (function webpackUniversalModuleDefinition(root, factory) {

else if(typeof exports === 'object')
exports["spotifyWrapper"] = factory();
exports["SpotifyWrapper"] = factory();
else
root["spotifyWrapper"] = factory();
root["SpotifyWrapper"] = factory();
})(this, function() {

@@ -77,3 +77,3 @@ return /******/ (function(modules) { // webpackBootstrap

/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })

@@ -91,12 +91,54 @@ /************************************************************************/

});
var TOKEN_API = 'BQCiU1O5dNyjf0gPuaZSmuiixeo5qKax6qUuELQJyL827jywk2j5wctuqXJqLrRK5PlGFOjKwjlUWFbF2vCiCbLRG08NSeIbVagRJhf2aTHlEoldKT2G56igxBlBhqr2fp1w7jnCIusQ5Qjf_G0';
var API_URL = exports.API_URL = 'https://api.spotify.com/v1';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global fetch */
var HEADERS = exports.HEADERS = {
headers: {
Authorization: '\'Bearer ' + TOKEN_API + '\''
var _search = __webpack_require__(4);
var _search2 = _interopRequireDefault(_search);
var _album = __webpack_require__(2);
var _album2 = _interopRequireDefault(_album);
var _config = __webpack_require__(3);
var _config2 = _interopRequireDefault(_config);
var _utils = __webpack_require__(5);
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var SpotifyWrapper = function () {
function SpotifyWrapper(options) {
_classCallCheck(this, SpotifyWrapper);
this.apiURL = options.apiURL || _config2.default;
this.token = options.token;
this.search = _search2.default.bind(this)();
this.album = _album2.default.bind(this)();
}
};
_createClass(SpotifyWrapper, [{
key: 'request',
value: function request(url) {
var headers = {
headers: {
Authorization: '\'Bearer ' + this.token + '\''
}
};
return fetch(url, headers).then(_utils2.default);
}
}]);
return SpotifyWrapper;
}();
exports.default = SpotifyWrapper;
/***/ }),

@@ -106,13 +148,5 @@ /* 1 */

"use strict";
module.exports = __webpack_require__(0).default;
Object.defineProperty(exports, "__esModule", {
value: true
});
var toJSON = function toJSON(data) {
return data.json();
};
exports.default = toJSON;
/***/ }),

@@ -128,26 +162,19 @@ /* 2 */

});
exports.getAlbumTracks = exports.getAlbums = exports.getAlbum = undefined;
exports.default = album;
function album() {
var _this = this;
var _config = __webpack_require__(0);
return {
getAlbum: function getAlbum(id) {
return _this.request(_this.apiURL + "/albums/" + id);
},
getAlbums: function getAlbums(ids) {
return _this.request(_this.apiURL + "/albums/?ids=" + ids);
},
getTracks: function getTracks(id) {
return _this.request(_this.apiURL + "/albums/" + id + "/tracks");
}
};
}
var _utils = __webpack_require__(1);
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* global fetch */
var getAlbum = exports.getAlbum = function getAlbum(id) {
return fetch(_config.API_URL + '/albums/' + id, _config.HEADERS).then(_utils2.default);
};
var getAlbums = exports.getAlbums = function getAlbums(ids) {
return fetch(_config.API_URL + '/albums/?ids=' + ids, _config.HEADERS).then(_utils2.default);
};
var getAlbumTracks = exports.getAlbumTracks = function getAlbumTracks(id) {
return fetch(_config.API_URL + '/albums/' + id + '/tracks', _config.HEADERS).then(_utils2.default);
};
/***/ }),

@@ -163,35 +190,31 @@ /* 3 */

});
exports.searchPlaylists = exports.searchTracks = exports.searchAlbums = exports.searchArtists = exports.search = undefined;
var API_URL = 'https://api.spotify.com/v1';
exports.default = API_URL;
var _config = __webpack_require__(0);
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
var _utils = __webpack_require__(1);
"use strict";
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = search;
function searcher(type, query) {
return this.request(this.apiURL + '/search?q=' + query + '&type=' + type);
}
/* global fetch */
var search = exports.search = function search(query, type) {
return fetch(_config.API_URL + '/search?q=' + query + '&type=' + type, _config.HEADERS).then(_utils2.default);
};
function search() {
return {
artists: searcher.bind(this, 'artist'),
albums: searcher.bind(this, 'album'),
tracks: searcher.bind(this, 'track'),
playlists: searcher.bind(this, 'playlist')
};
}
var searchArtists = exports.searchArtists = function searchArtists(query) {
return search(query, 'artist');
};
var searchAlbums = exports.searchAlbums = function searchAlbums(query) {
return search(query, 'album');
};
var searchTracks = exports.searchTracks = function searchTracks(query) {
return search(query, 'track');
};
var searchPlaylists = exports.searchPlaylists = function searchPlaylists(query) {
return search(query, 'playlist');
};
/***/ }),
/* 4 */
/* 5 */
/***/ (function(module, exports, __webpack_require__) {

@@ -202,15 +225,9 @@

var _search = __webpack_require__(3);
var _album = __webpack_require__(2);
module.exports = {
search: _search.search,
searchArtists: _search.searchArtists,
searchAlbums: _search.searchAlbums,
searchPlaylists: _search.searchPlaylists,
getAlbum: _album.getAlbum,
getAlbums: _album.getAlbums,
getAlbumTracks: _album.getAlbumTracks
Object.defineProperty(exports, "__esModule", {
value: true
});
var toJSON = function toJSON(data) {
return data.json();
};
exports.default = toJSON;

@@ -217,0 +234,0 @@ /***/ })

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.spotifyWrapper=t():e.spotifyWrapper=t()}(this,function(){return function(e){function t(u){if(r[u])return r[u].exports;var n=r[u]={i:u,l:!1,exports:{}};return e[u].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,u){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:u})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=4)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.API_URL="https://api.spotify.com/v1",t.HEADERS={headers:{Authorization:"'Bearer BQCiU1O5dNyjf0gPuaZSmuiixeo5qKax6qUuELQJyL827jywk2j5wctuqXJqLrRK5PlGFOjKwjlUWFbF2vCiCbLRG08NSeIbVagRJhf2aTHlEoldKT2G56igxBlBhqr2fp1w7jnCIusQ5Qjf_G0'"}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var u=function(e){return e.json()};t.default=u},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getAlbumTracks=t.getAlbums=t.getAlbum=void 0;var u=r(0),n=r(1),s=function(e){return e&&e.__esModule?e:{default:e}}(n);t.getAlbum=function(e){return fetch(u.API_URL+"/albums/"+e,u.HEADERS).then(s.default)},t.getAlbums=function(e){return fetch(u.API_URL+"/albums/?ids="+e,u.HEADERS).then(s.default)},t.getAlbumTracks=function(e){return fetch(u.API_URL+"/albums/"+e+"/tracks",u.HEADERS).then(s.default)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.searchPlaylists=t.searchTracks=t.searchAlbums=t.searchArtists=t.search=void 0;var u=r(0),n=r(1),s=function(e){return e&&e.__esModule?e:{default:e}}(n),c=t.search=function(e,t){return fetch(u.API_URL+"/search?q="+e+"&type="+t,u.HEADERS).then(s.default)};t.searchArtists=function(e){return c(e,"artist")},t.searchAlbums=function(e){return c(e,"album")},t.searchTracks=function(e){return c(e,"track")},t.searchPlaylists=function(e){return c(e,"playlist")}},function(e,t,r){"use strict";var u=r(3),n=r(2);e.exports={search:u.search,searchArtists:u.searchArtists,searchAlbums:u.searchAlbums,searchPlaylists:u.searchPlaylists,getAlbum:n.getAlbum,getAlbums:n.getAlbums,getAlbumTracks:n.getAlbumTracks}}])});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SpotifyWrapper=e():t.SpotifyWrapper=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var u=n[r]={i:r,l:!1,exports:{}};return t[r].call(u.exports,u,u.exports,e),u.l=!0,u.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1)}([function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{default:t}}function u(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}(),o=n(4),s=r(o),a=n(2),f=r(a),c=n(3),l=r(c),p=n(5),d=r(p),b=function(){function t(e){u(this,t),this.apiURL=e.apiURL||l.default,this.token=e.token,this.search=s.default.bind(this)(),this.album=f.default.bind(this)()}return i(t,[{key:"request",value:function(t){var e={headers:{Authorization:"'Bearer "+this.token+"'"}};return fetch(t,e).then(d.default)}}]),t}();e.default=b},function(t,e,n){t.exports=n(0).default},function(t,e,n){"use strict";function r(){var t=this;return{getAlbum:function(e){return t.request(t.apiURL+"/albums/"+e)},getAlbums:function(e){return t.request(t.apiURL+"/albums/?ids="+e)},getTracks:function(e){return t.request(t.apiURL+"/albums/"+e+"/tracks")}}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default="https://api.spotify.com/v1"},function(t,e,n){"use strict";function r(t,e){return this.request(this.apiURL+"/search?q="+e+"&type="+t)}function u(){return{artists:r.bind(this,"artist"),albums:r.bind(this,"album"),tracks:r.bind(this,"track"),playlists:r.bind(this,"playlist")}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(t){return t.json()};e.default=r}])});
//# sourceMappingURL=spotify-wrapper.umd.min.js.map

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

'use strict';
"use strict";

@@ -6,24 +6,17 @@ Object.defineProperty(exports, "__esModule", {

});
exports.getAlbumTracks = exports.getAlbums = exports.getAlbum = undefined;
exports.default = album;
function album() {
var _this = this;
var _config = require('./config');
var _utils = require('./utils');
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* global fetch */
var getAlbum = exports.getAlbum = function getAlbum(id) {
return fetch(_config.API_URL + '/albums/' + id, _config.HEADERS).then(_utils2.default);
};
var getAlbums = exports.getAlbums = function getAlbums(ids) {
return fetch(_config.API_URL + '/albums/?ids=' + ids, _config.HEADERS).then(_utils2.default);
};
var getAlbumTracks = exports.getAlbumTracks = function getAlbumTracks(id) {
return fetch(_config.API_URL + '/albums/' + id + '/tracks', _config.HEADERS).then(_utils2.default);
};
return {
getAlbum: function getAlbum(id) {
return _this.request(_this.apiURL + "/albums/" + id);
},
getAlbums: function getAlbums(ids) {
return _this.request(_this.apiURL + "/albums/?ids=" + ids);
},
getTracks: function getTracks(id) {
return _this.request(_this.apiURL + "/albums/" + id + "/tracks");
}
};
}

@@ -6,10 +6,3 @@ 'use strict';

});
var TOKEN_API = 'BQCiU1O5dNyjf0gPuaZSmuiixeo5qKax6qUuELQJyL827jywk2j5wctuqXJqLrRK5PlGFOjKwjlUWFbF2vCiCbLRG08NSeIbVagRJhf2aTHlEoldKT2G56igxBlBhqr2fp1w7jnCIusQ5Qjf_G0';
var API_URL = exports.API_URL = 'https://api.spotify.com/v1';
var HEADERS = exports.HEADERS = {
headers: {
Authorization: '\'Bearer ' + TOKEN_API + '\''
}
};
var API_URL = 'https://api.spotify.com/v1';
exports.default = API_URL;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global fetch */
var _search = require('./search');
var _search2 = _interopRequireDefault(_search);
var _album = require('./album');
module.exports = {
search: _search.search,
searchArtists: _search.searchArtists,
searchAlbums: _search.searchAlbums,
searchPlaylists: _search.searchPlaylists,
getAlbum: _album.getAlbum,
getAlbums: _album.getAlbums,
getAlbumTracks: _album.getAlbumTracks
};
var _album2 = _interopRequireDefault(_album);
var _config = require('./config');
var _config2 = _interopRequireDefault(_config);
var _utils = require('./utils');
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var SpotifyWrapper = function () {
function SpotifyWrapper(options) {
_classCallCheck(this, SpotifyWrapper);
this.apiURL = options.apiURL || _config2.default;
this.token = options.token;
this.search = _search2.default.bind(this)();
this.album = _album2.default.bind(this)();
}
_createClass(SpotifyWrapper, [{
key: 'request',
value: function request(url) {
var headers = {
headers: {
Authorization: '\'Bearer ' + this.token + '\''
}
};
return fetch(url, headers).then(_utils2.default);
}
}]);
return SpotifyWrapper;
}();
exports.default = SpotifyWrapper;

@@ -6,31 +6,14 @@ 'use strict';

});
exports.searchPlaylists = exports.searchTracks = exports.searchAlbums = exports.searchArtists = exports.search = undefined;
exports.default = search;
function searcher(type, query) {
return this.request(this.apiURL + '/search?q=' + query + '&type=' + type);
}
var _config = require('./config');
var _utils = require('./utils');
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* global fetch */
var search = exports.search = function search(query, type) {
return fetch(_config.API_URL + '/search?q=' + query + '&type=' + type, _config.HEADERS).then(_utils2.default);
};
var searchArtists = exports.searchArtists = function searchArtists(query) {
return search(query, 'artist');
};
var searchAlbums = exports.searchAlbums = function searchAlbums(query) {
return search(query, 'album');
};
var searchTracks = exports.searchTracks = function searchTracks(query) {
return search(query, 'track');
};
var searchPlaylists = exports.searchPlaylists = function searchPlaylists(query) {
return search(query, 'playlist');
};
function search() {
return {
artists: searcher.bind(this, 'artist'),
albums: searcher.bind(this, 'album'),
tracks: searcher.bind(this, 'track'),
playlists: searcher.bind(this, 'playlist')
};
}
{
"name": "spotify-wrapper",
"version": "1.0.5",
"version": "2.0.0",
"description": "A wrapper to work with the Spotify Web API.",

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

@@ -31,6 +31,10 @@ # Spotify Wrapper

// to import a specific method
import { method } from 'spotify-wrapper';
import SpotifyWrapper from 'spotify-wrapper';
// to import everything
import * as spotifyWrapper from 'spotify-wrapper';
const spotify = new SpotifyWrapper({
token: 'YOUR_TOKEN_HERE'
});
// using method
spotify.search.artists('Incubus');
```

@@ -41,3 +45,7 @@

```js
var spotifyWrapper = require('spotify-wrapper');
const spotifyWrapper = require('spotify-wrapper');
const spotify = new SpotifyWrapper({
token: 'YOUR_TOKEN_HERE'
});
```

@@ -55,6 +63,11 @@

After that the library will be available to the Global as `spotifyWrapper`. Follow an example:
After that the library will be available to the Global as `SpotifyWrapper`. Follow an example:
```js
const albums = spotifyWrapper.searchAlbums('Choosen Artist');
const spotify = new SpotifyWrapper({
token: 'YOUR_TOKEN_HERE'
});
const albums = spotify.search.albums('Choosen Artist');
```

@@ -66,24 +79,4 @@

### search(query, types)
### search.albums(query)
> Search for informations about artists, albums, tracks or playlists. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-search-item/).
**Arguments**
| Argument | Type | Options |
|----------|-------------------|-----------------------------------------|
|`query` |*string* | 'Any search query' |
|`type` |*Array of strings* | ['artist', 'album', 'track', 'playlist']|
**Example**
```js
search('Incubus', ['artist', 'album'])
.then(data => {
// do what you want with the data
})
```
### searchAlbums(query)
> Search for informations about Albums with provided query. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-search-item/) with type defined as *album*.

@@ -101,3 +94,3 @@

```js
searchAlbums('Incubus')
spotify.search.albums('Incubus')
.then(data => {

@@ -108,3 +101,3 @@ // do what you want with the data

### searchArtists(query)
### search.artists(query)

@@ -123,3 +116,3 @@ > Search for informations about Artists with provided query. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-search-item/) with type defined as *artist*.

```js
searchArtists('Incubus')
spotify.search.artists('Incubus')
.then(data => {

@@ -130,3 +123,3 @@ // do what you want with the data

### searchTracks(query)
### search.tracks(query)

@@ -145,3 +138,3 @@ > Search for informations about Tracks with provided query. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-search-item/) with type defined as *track*.

```js
searchTracks('Drive')
spotify.search.tracks('Drive')
.then(data => {

@@ -152,3 +145,3 @@ // do what you want with the data

### searchPlaylists(query)
### search.playlists(query)

@@ -167,3 +160,3 @@ > Search for informations about Playlist with provided query. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-search-item/) with type defined as *playlist*.

```js
searchPlaylists('Happy Day')
spotify.search.playlists('Happy Day')
.then(data => {

@@ -174,3 +167,3 @@ // do what you want with the data

### getAlbum(id)
### album.getAlbum(id)

@@ -189,3 +182,3 @@ > Search for informations about a specific Album with provided id. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-album/).

```js
getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
spotify.album.getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {

@@ -196,3 +189,3 @@ // do what you want with the data

### getAlbums(ids)
### album.getAlbums(ids)

@@ -210,3 +203,3 @@ > Search for informations about some Albums with all id's. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-several-albums/).

```js
getAlbum(['4aawyAB9vmqN3uQ7FjRGTy', '1A2GTWGtFfWp7KSQTwWOyo'])
spotify.album.getAlbums(['4aawyAB9vmqN3uQ7FjRGTy', '1A2GTWGtFfWp7KSQTwWOyo'])
.then(data => {

@@ -217,3 +210,3 @@ // do what you want with the data

### getAlbumTracks(id)
### album.getTracks(id)

@@ -231,3 +224,3 @@ > Search for all tracks in a specific Album with provided id. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-album-tracks/).

```js
getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
spotify.album.getTracks('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {

@@ -234,0 +227,0 @@ // do what you want with the data

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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