https://github.com/lflimeira/sdk-spotify
A project created with the focus to study TDD in JavaScript, following the course "JS com TDD na Prática".
https://github.com/lflimeira/sdk-spotify
automated-testing chai husky javascript js mochajs nyc tdd
Last synced: 3 months ago
JSON representation
A project created with the focus to study TDD in JavaScript, following the course "JS com TDD na Prática".
- Host: GitHub
- URL: https://github.com/lflimeira/sdk-spotify
- Owner: lflimeira
- License: mit
- Created: 2017-11-04T22:56:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-15T18:15:02.000Z (almost 7 years ago)
- Last Synced: 2025-01-24T15:14:35.459Z (3 months ago)
- Topics: automated-testing, chai, husky, javascript, js, mochajs, nyc, tdd
- Language: JavaScript
- Homepage:
- Size: 272 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://travis-ci.org/lflimeira/js-tdd-studies) [](https://coveralls.io/github/lflimeira/js-tdd-studies?branch=master)
# Spotify SDK
A wrapper to work with the [Spotify Web API](https://developer.spotify.com/web-api/).
## Browser Support
This library relies on [Fetch API](https://fetch.spec.whatwg.org/). And this API is supported in the following browsers.
 |  |  |  |  |
--- | --- | --- | --- | --- |
39+ ✔ | 42+ ✔ | 29+ ✔ | 10.1+ ✔ | Nope ✘ |## Dependencies
This library depends on [fetch](https://fetch.spec.whatwg.org/) to make requests to the Spotify Web API. For environments that don't support fetch, you'll need to provide a [polyfill](https://github.com/github/fetch) to browser or [polyfill](https://github.com/bitinn/node-fetch) to Node.
## Installation
```sh
$ npm install sdk-spotify --save
```## How to use
### ES6
```js
// to import a specific method
import { method } from 'spotify-wrapper';// to import everything
import * as spotifyWrapper from 'spotify-wrapper';
```### CommonJS
```js
var spotifyWrapper = require('spotify-wrapper');
```### UMD in Browser
```html
```
After that the library will be available to the Global as `spotifyWrapper`. Follow an example:
```js
const albums = spotifyWrapper.searchAlbums('Choosen Artist');
```## Methods
> Follow the methods that the library provides.
### search(query, types)
> 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*.
**Arguments**
| Argument | Type | Options |
|----------|---------|-------------------|
|`query` |*string* | 'Any search query'|**Example**
```js
searchAlbums('Incubus')
.then(data => {
// do what you want with the data
})
```### searchArtists(query)
> 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*.
**Arguments**
| Argument | Type | Options |
|----------|---------|-------------------|
|`query` |*string* | 'Any search query'|**Example**
```js
searchArtists('Incubus')
.then(data => {
// do what you want with the data
})
```### searchTracks(query)
> 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*.
**Arguments**
| Argument | Type | Options |
|----------|---------|-------------------|
|`query` |*string* | 'Any search query'|**Example**
```js
searchTracks('Drive')
.then(data => {
// do what you want with the data
})
```### searchPlaylists(query)
> 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*.
**Arguments**
| Argument | Type | Options |
|----------|---------|-------------------|
|`query` |*string* | 'Any search query'|**Example**
```js
searchPlaylists('Happy Day')
.then(data => {
// do what you want with the data
})
```### getAlbum(id)
> Search for informations about a specific Album with provided id. Test in [Spotify Web Console](https://developer.spotify.com/web-api/console/get-album/).
**Arguments**
| Argument | Type | Options |
|----------|---------|-------------------|
|`id` |*string* | 'Specific id'|**Example**
```js
getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
```### getAlbums(ids)
> 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/).
**Arguments**
| Argument | Type | Options |
|----------|---------|-------------------|
|`ids` |*Array of strings* | ['id1', 'id2']|**Example**
```js
getAlbum(['4aawyAB9vmqN3uQ7FjRGTy', '1A2GTWGtFfWp7KSQTwWOyo'])
.then(data => {
// do what you want with the data
})
```### getAlbumTracks(id)
> 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/).
**Arguments**
| Argument | Type | Options |
|----------|---------|-------------------|
|`id` |*string* | 'Specific id'|**Example**
```js
getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
```## Contributing
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
## Authors
| |
|:---------------------:|
| [Felipe Limeira](https://github.com/lflimeira/) |## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details