Code Monkey home page Code Monkey logo

spotify-finder's Introduction

spotify-finder

Build Status Coverage Status

NPM

A isomorphic Spotify client, that use the Client Credentials authorization flow. It allows to use some Spotify Web API endpoints.

Install

$ npm install spotify-finder

Usage

import Spotify from 'spotify-finder'
const client = new Spotify({
  consumer: {
    key: 'YOUR_CLIENT_ID', // from v2.1.0 is required
    secret: 'YOUR_CLIENT_SECRET' // from v2.1.0 is required
  }
})

Note: you have that provide the client credentials because from 29th May 2017 was removed unauthenticated calls to the Spotify Web API more info. Create an application in Spotify click here.

Search for all types

const params = {
  q: 'Demi', // required
}
client.search(params)
  .then(data => {
    // do something with data
  })

Search for type specific with limit

const params = {
  q: 'Stone Cold', // required
  type: 'artist', // optional for default 'artist,album,track'
  limit: 5 // optional for default 20
}
client.search(params)
  .then(data => {
    // do something with data
  })

Get a List of New Releases

const params = {
  to: 'new-releases', // required
  limit: 5, // optional for default 20
  offset: 5 // optional for default 0
}
client.browse(params)
  .then(albums => {
    // do something with album's
  })

Get a List of Featured Playlists

client.browse({ to: 'featured-playlists' })
  .then(playlists => {
    // do something with playlist's
  })

Get a List of Categories

client.browse({ to: 'categories' })
  .then(categories => {
    // do something with categories
  })

Get a Category by id

client.getCategory('toptrack')
  .then(category => {
    // do something with category
  })

Get a Category’s Playlists

const params = {
  playlists: true, // required
  limit: 5, // optional for default 20
  offset: 5, // optional for default 0
  country: 'BR' // optional for default 'SE'
}
client.getCategory('toptrack', params)
  .then(playlists => {
    // do something with playlists
  })

Get album by id

client.getAlbum('41MnTivkwTO3UUJ8DrqEJJ', { tracks: false })
  .then(album => {
    // do something with album
  })

Get an album's tracks

client.getAlbum('41MnTivkwTO3UUJ8DrqEJJ', { tracks: true })
  .then(tracks => {
    // do something with tracks
  })

Get several albums by id

const ids = ['41MnTivkwTO3UUJ8DrqEJJ', '6UXCm6bOO4gFlDQZV5yL37']
client.getAlbums(ids)
  .then(albums => {
    // do something with albums
  })

Get artist by id

client.getArtist('6S2OmqARrzebs0tKUEyXyp')
  .then(artist => {
    // do something with artist
  })

Get an artist's albums

const params = {
  albums: true, // required
  album_type: 'album,single', // optional for default all types
  limit: 5, // optional for default 20
  offset: 5 // optional for default 0
}
client.getArtist('6S2OmqARrzebs0tKUEyXyp', params)
  .then(albums => {
    // do something with albums
  })

Get an artist's top tracks

client.getArtist('6S2OmqARrzebs0tKUEyXyp', { topTracks: true })
  .then(tracks => {
    // do something with tracks
  })

Get an artist's related artists

client.getArtist('6S2OmqARrzebs0tKUEyXyp', { relatedArtists: true })
  .then(artists => {
     //do something with artists
  })

Get several artists by id

const ids = ['15deb326635d69d0505434', '934da7155ec15deb32663'],
client.getArtists(ids)
  .then(artists => {
    //do something with artists
  })

Get an track by id

client.getTrack('934da7155ec15deb32663')
  .then(track => {
    //do something with track
  })

Get several tracks by id

const ids = ['15deb326635d69d0505s', 'da7155ec15deb326635d69d']
client.getTracks(ids)
  .then(tracks => {
    //do something with tracks
  })

spotify-finder's People

Contributors

luixlacrux avatar thoriqazzikraa avatar moisesdelacruz avatar

Stargazers

David ??? avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.