Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheus-de-Souza committed Apr 12, 2018
1 parent 28ac829 commit 3b496c2
Showing 1 changed file with 26 additions and 43 deletions.
69 changes: 26 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,23 @@ This library depends on [fetch](https://fetch.spec.whatwg.org/) to make requests
## Installation

```sh
$ npm install spotify-wrapper --save
$ npm install mws-spotify-wrapper --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';
import SpotifyWrapper from 'mws-spotify-wrapper';
```

### CommonJS

```js
var spotifyWrapper = require('spotify-wrapper');
global.fetch = require('node-fetch');

var SpotifyWrapper = require('mws-spotify-wrapper').default;
```

### UMD in Browser
Expand All @@ -52,37 +50,21 @@ var spotifyWrapper = require('spotify-wrapper');
<script src="spotify-wrapper.umd.min.js"></script>
```

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` class. Follow an example:

```js
const albums = spotifyWrapper.searchAlbums('Choosen Artist');
const spotify = new SpotifyWrapper({
token: 'token',
});

const albums = spotify.search.albums('Chosen 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.albums(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*.
Expand All @@ -96,13 +78,13 @@ search('Incubus', ['artist', 'album'])
**Example**

```js
searchAlbums('Incubus')
spotify.albums.search('Incubus')
.then(data => {
// do what you want with the data
})
```

### searchArtists(query)
### search.artists(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*.
Expand All @@ -116,13 +98,13 @@ searchAlbums('Incubus')
**Example**

```js
searchArtists('Incubus')
spotify.search.artists('Incubus')
.then(data => {
// do what you want with the data
})
```

### searchTracks(query)
### search.tracks(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*.
Expand All @@ -136,13 +118,13 @@ searchArtists('Incubus')
**Example**

```js
searchTracks('Drive')
spotify.search.tracks('Drive')
.then(data => {
// do what you want with the data
})
```

### searchPlaylists(query)
### search.playlists(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*.
Expand All @@ -156,13 +138,13 @@ searchTracks('Drive')
**Example**

```js
searchPlaylists('Happy Day')
spotify.search.playlists('Happy Day')
.then(data => {
// do what you want with the data
})
```

### getAlbum(id)
### album.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/).
Expand All @@ -176,13 +158,13 @@ searchPlaylists('Happy Day')
**Example**

```js
getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
spotify.album.getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
```

### getAlbums(ids)
### album.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/).
Expand All @@ -195,13 +177,13 @@ getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
**Example**

```js
getAlbum(['4aawyAB9vmqN3uQ7FjRGTy', '1A2GTWGtFfWp7KSQTwWOyo'])
spotify.album.getAlbums(['4aawyAB9vmqN3uQ7FjRGTy', '1A2GTWGtFfWp7KSQTwWOyo'])
.then(data => {
// do what you want with the data
})
```

### getAlbumTracks(id)
### album.getTracks(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/).
Expand All @@ -214,11 +196,12 @@ getAlbum(['4aawyAB9vmqN3uQ7FjRGTy', '1A2GTWGtFfWp7KSQTwWOyo'])
**Example**

```js
getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
spotify.album.getTracks('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
```

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

0 comments on commit 3b496c2

Please sign in to comment.