Spotify API wrapper to return audio metadata
npm install spotify-audio-apiSpotify Web API wrapper to return audio metadata. This wrapper uses the client credentials auth flow, so only non-user related endpoints can be called.
``bash`
$ yarn add spotify-audio-api
Instantiate the class with your client ID and client secret provided from the Spotify developer dashboard:
`js
const clientId = 'fsd9f89shfsf2j'
const clientSecret = 'qf9asfsdgh9osgh9sa2'
const spotify = new SpotifyAPI(clientId, clientSecret)
`
This wrapper provides an axios instance with the Spotify API url as the base url.
You can retrieve an auth token with the getToken() method. This method fetches an auth token and sets it as the Authorization header in the axios instance.
`js
spotify.getToken()
spotify.instance.get(/artists/3TVXtAsR1Inumwj472S9r4).then((response) => console.log(response.data))`
#### getToken()
Makes a POST request to the Spotify API and sets the returned token in an axios instance.
Params
- albumId: spotify ID of an albumcallback
- : function to handle the returned data
Get info on an album's tracks.
Params
- albumId: spotify ID of an albumcallback
- : function to handle the returned data
Params
- artistId: spotify ID of an artistcallback
- : function to handle the returned data
Params
- artistId: spotify ID of an artistcallback
- : function to handle the returned data
Get artists related to an artist.
Params
- artistId: spotify ID of an artistcallback
- : function to handle the returned data
Params
- trackId: spotify ID of a trackcallback
- : function to handle the returned data
Get audio features for a single track/
Params
- trackId: spotify ID of a trackcallback
- : function to handle the returned data
Get audio analysis for a single track.
Params
- trackId: spotify ID of a trackcallback
- : function to handle the returned data
Params
- query: Search query stringcallback
- : function to handle the returned data
Params
- query: Search query stringcallback
- : function to handle the returned data
Params
- query: Search query stringcallback`: function to handle the returned data
-
---
built with skeletor 💀