Skip to content

TacioAntonio/spotify-web-api

Repository files navigation

Spotify web API

Build Status Coverage Status

Um wrapper para trabalhar com o Spotify Web API.

Suporte

Esta biblioteca conta com Fetch API. E essa API é suportada nos seguintes navegadores.

Pré-requisitos

Chrome Firefox Opera Safari IE
39+ ✔ 42+ ✔ 29+ ✔ 10.1+ ✔ Nope ✘

Dependências

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.

Instalação

$ npm i @tacioantonio/spotify-web-api

Como utilizar

ES6

// to import a specific method
import { method } from '@tacioantonio/spotify-web-api';
// to import everything
import * as spotifyWrapper from '@tacioantonio/spotify-web-api';

CommonJS

var spotifyWrapper = require('@tacioantonio/spotify-web-api');

UMD no navegador

<!-- 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>

Métodos

Siga os métodos que a biblioteca fornece.

Search

search.albums(query)

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
  })

search.artists(query)

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
  })

search.tracks(query)

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
  })

search.playlists(query)

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
  })

Album

album.getAlbum(id)

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
  })

album.getAlbums(ids)

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
  })

album.getTracks(id)

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
  })

Artista

artist.getArtist(id)

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
  })

artist.getArtists(ids)

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
  })

artist.getArtistAlbums(id)

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
  })

artist.getRelatedArtists(id)

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
  })

artist.getArtistTopTracks(id)

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
  })

Faixas

track.getTrack(id)

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
  })

track.getTracks(ids)

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
  })

track.getAudioFeature(id)

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
  })

track.getAudioFeatures(ids)

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
  })

track.getAudioAnalysis(id)

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
  })

Lista de reprodução

playlist.getPlaylists()

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
  })

playlist.getPlaylistsTracks(playlistId)

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
  })

playlist.getPlaylist(playlistId)

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
  })

playlist.getUsers(userId)

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
  })

playlist.postPlaylists(name, description, isPublic)

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
  })

playlist.postPlaylistsTracks(playlistId, uris)

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
  })

playlist.putPlaylistsTracks(playlistId, rangeStart, rangeLength, insertBefore)

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
  })

playlist.putPlaylists(playlistId, name, description, isPublic)

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
  })

playlist.deletePlaylists(playlistId, uri, positions)

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 os testes

Executando testes:

$ npm run test

Assistindo os testes:

$ npm run test:tdd

Cobrir os testes:

$ npm run test:coverage

Contribuição

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.

Versionamento

Nós usamos SemVer para controle de versão. Para as versões disponíveis, consulte o tags on this repository.

Autor

Tácio Antônio
Tácio Antônio

Veja também a lista de contributors que participaram deste projeto.

Licença

Este projeto está licenciado sob a licença MIT - consulte o LICENSE.md para detalhes.

About

A wrapper for working with the Spotifty API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published