Um wrapper para trabalhar com o Spotify Web API.
Esta biblioteca conta com Fetch API. E essa API é suportada nos seguintes navegadores.
39+ ✔ | 42+ ✔ | 29+ ✔ | 10.1+ ✔ | Nope ✘ |
Essa biblioteca depende de Fetch para fazer solicitações à API da Web do Spotify. Para ambientes que não oferecem suporte à busca, é necessário fornecer um polyfill ao navegador ou polyfill para Node.
$ npm i @tacioantonio/spotify-web-api
// to import a specific method
import { method } from '@tacioantonio/spotify-web-api';
// to import everything
import * as spotifyWrapper from '@tacioantonio/spotify-web-api';
var spotifyWrapper = require('@tacioantonio/spotify-web-api');
<!-- to import non-minified version -->
<script src="spotify-web-api.umd.js"></script>
<!-- to import minified version -->
<script src="spotify-web-api.umd.min.js"></script>
Siga os métodos que a biblioteca fornece.
Procure informações sobre os álbuns com a consulta fornecida. Teste no Spotify Web Console com o tipo definido como álbum.
Argumentos
Argument | Type | Options |
---|---|---|
query |
string | 'Any search query' |
Exemplo
spotify.search.albums('Incubus')
.then(data => {
// do what you want with the data
})
Procure informações sobre artistas com a consulta fornecida. Teste no Spotify Web Console com o tipo definido como álbum.
Argumentos
Argument | Type | Options |
---|---|---|
query |
string | 'Any search query' |
Exemplo
spotify.search.artists('Incubus')
.then(data => {
// do what you want with the data
})
Procure informações sobre artistas com a consulta fornecida. Teste no Spotify Web Console com o tipo definido como álbum.
Argumentos
Argument | Type | Options |
---|---|---|
query |
string | 'Any search query' |
Exemplo
spotify.search.tracks('Incubus')
.then(data => {
// do what you want with the data
})
Pesquise informações sobre a Playlist com a consulta fornecida. Teste no Spotify Web Console com o tipo definido como álbum.
Argumentos
Argument | Type | Options |
---|---|---|
query |
string | 'Any search query' |
Exemplo
spotify.search.playlists('Incubus')
.then(data => {
// do what you want with the data
})
Obter faixas de um álbum. Teste no Spotify Web Console - Get an Album.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.album.getAlbum('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter vários álbuns. Teste no Spotify Web Console - Get Several Albums.
Argumentos
Argument | Type | Options |
---|---|---|
ids |
Array of strings | ['id1', 'id2'] |
Exemplo
spotify.album.getAlbums(['4aawyAB9vmqN3uQ7FjRGTy','4aawyAB9vmqN3uQ7FjRGTy'])
.then(data => {
// do what you want with the data
})
Obter faixas de um álbum. Teste no Spotify Web Console - Get an Album's Tracks.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.album.getTracks('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter um Artista. Teste no Spotify Web Console - Get an Artist.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.album.getArtist('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter vários artistas. Teste no Spotify Web Console - Get Several Artists.
Argumentos
Argument | Type | Options |
---|---|---|
ids |
Array of strings | ['id1', 'id2'] |
Exemplo
spotify.artist.getArtists(['4aawyAB9vmqN3uQ7FjRGTy', '4aawyAB9vmqN3uQ7FjRGTy'])
.then(data => {
// do what you want with the data
})
Obter álbuns de um artista. Teste no Spotify Web Console - Get an Artist's Albums.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.artist.getArtistAlbums('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter artistas relacionados a um artista. Teste no Spotify Web Console - Get an Artist's Related Artists.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.artist.getRelatedArtists('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter as principais faixas de um artista. Teste no Spotify Web Console - Get an Artist's Top Tracks Artists.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.artist.getArtistTopTracks('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter uma faixa. Teste no Spotify Web Console - Get a Track.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.track.getTrack('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter várias faixas. Teste no Spotify Web Console - Get Several Tracks.
Argumentos
Argument | Type | Options |
---|---|---|
ids |
Array of strings | ['id1', 'id2'] |
Exemplo
spotify.track.getTracks(['4aawyAB9vmqN3uQ7FjRGTy', '4aawyAB9vmqN3uQ7FjRGTy'])
.then(data => {
// do what you want with the data
})
Obter recursos de áudio para uma faixa. Teste no Spotify Web Console - Get Audio Features for a Track.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.track.getAudioFeature('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter recursos de áudio para várias faixas. Teste no Spotify Web Console - Get Audio Features for Several Tracks.
Argumentos
Argument | Type | Options |
---|---|---|
ids |
Array of strings | ['id1', 'id2'] |
Exemplo
spotify.track.getAudioFeatures(['4aawyAB9vmqN3uQ7FjRGTy', '4aawyAB9vmqN3uQ7FjRGTy'])
.then(data => {
// do what you want with the data
})
Obter análise de áudio para uma faixa. Teste no Spotify Web Console - Get Audio Analysis for a Track.
Argumentos
Argument | Type | Options |
---|---|---|
id |
string | 'Specific id' |
Exemplo
spotify.track.getAudioAnalysis('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter uma lista de listas de reprodução do usuário atual. Teste no Spotify Web Console - Get a List of Current User's Playlists.
Argumentos
Argument | Type | Options |
---|---|---|
--- | --- | --- |
Exemplo
spotify.playlist.getPlaylists()
.then(data => {
// do what you want with the data
})
Obter faixas de uma lista de reprodução. Teste em Spotify Web Console - Get a Playlist's Tracks.
Argumentos
Argument | Type | Options |
---|---|---|
playlistId |
string | 'Specific id' |
Exemplo
spotify.playlist.getPlaylistsTracks('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter uma lista de reprodução. Teste em Spotify Web Console - Get a Playlist.
Argumentos
Argument | Type | Options |
---|---|---|
playlistId |
string | 'Specific id' |
Exemplo
spotify.playlist.getPlaylist('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Obter uma lista de listas de reprodução de um usuário. Teste em Spotify Web Console - Get a List of a User's Playlists.
Argumentos
Argument | Type | Options |
---|---|---|
userId |
string | 'Specific id' |
Exemplo
spotify.playlist.getUsers('4aawyAB9vmqN3uQ7FjRGTy')
.then(data => {
// do what you want with the data
})
Crie uma lista de reprodução. Teste em Spotify Web Console - Create a Playlist.
Argumentos
Argument | Type | Options |
---|---|---|
name |
string | 'Any query' |
description |
string | 'Any query' |
isPublic |
boolean | 'Any query' |
Exemplo
spotify.playlist.postPlaylists('Muse', 'My music', false)
.then(data => {
// do what you want with the data
})
Adicionar faixas a uma lista de reprodução. Teste em Spotify Web Console - Add Tracks to a Playlist.
Argumentos
Argument | Type | Options |
---|---|---|
playlistId |
string | 'Specific id' |
uris |
string | 'Any track query' |
Exemplo
spotify.playlist.postPlaylistsTracks('3cEYpjA9oz9GiPac4AsH4n', 'spotify%3Atrack%3A4iV5W9uYEdYUVa79Axb7Rh%2Cspotify%3Atrack%3A1301WleyT98MSxVHPZCA6M')
.then(data => {
// do what you want with the data
})
Reordenar ou substituir as faixas de uma lista de reprodução. Teste em Spotify Web Console - Reorder or replace a Playlist's Tracks.
Argumentos
Argument | Type | Options |
---|---|---|
playlistId |
string | 'Specific id' |
rangeStart |
number | 'Any query' |
rangeLength |
number | 'Any query' |
insertBefore |
number | 'Any query' |
Exemplo
spotify.playlist.postPlaylists('3cEYpjA9oz9GiPac4AsH4n', 1, 2, 3)
.then(data => {
// do what you want with the data
})
Alterar os detalhes de uma lista de reprodução. Teste em Spotify Web Console - Change a Playlist's Details.
Argumentos
Argument | Type | Options |
---|---|---|
playlistId |
string | 'Specific id' |
name |
string | 'Any query' |
description |
string | 'Any query' |
isPublic |
boolean | 'Any query' |
Exemplo
spotify.playlist.putPlaylists('3cEYpjA9oz9GiPac4AsH4n', 'Muse', 'My music', false);
.then(data => {
// do what you want with the data
})
Remover faixas de uma lista de reprodução. Teste em Spotify Web Console - Remove Tracks from a Playlist.
Argumentos
Argument | Type | Options |
---|---|---|
playlistId |
string | 'Specific id' |
uri |
string | 'Any track query' |
positions |
number | 'Any query' |
Exemplo
spotify.playlist.deletePlaylists('3cEYpjA9oz9GiPac4AsH4n', 'spotify:track:2DB2zVP1LVu6jjyrvqD44z', [0]);
.then(data => {
// do what you want with the data
})
Executando testes:
$ npm run test
Assistindo os testes:
$ npm run test:tdd
Cobrir os testes:
$ npm run test:coverage
Por favor CONTRIBUTING.md para obter detalhes sobre nosso código de conduta e o processo de envio de solicitações pull para nós.
Nós usamos SemVer para controle de versão. Para as versões disponíveis, consulte o tags on this repository.
Tácio Antônio |
Veja também a lista de contributors que participaram deste projeto.
Este projeto está licenciado sob a licença MIT - consulte o LICENSE.md para detalhes.