Giter Site home page Giter Site logo

spotifyjs's Introduction

SpotifyJS -- A pure JavaScript module for accessing the Spotify Metadata API

DESCRIPTION

SpotifyJS is a very lightweight interface to the Spotify Metadata API (http://developer.spotify.com/en/metadata-api/overview/).

Using this module you can easily access the "search" and "lookup" services.

All querying functions are asynchronous so you must provide callbacks.

Examples

Perform a basic search

var spotify_metadata = new Spotify.Metadata();
spotify_metadata.search('skrillex', function(responseData){
	var responseData = JSON.parse(responseData);

	console.log("Number of results: "+data.info.num_results);
});

Search by artist

var spotify_metadata = new Spotify.Metadata();
spotify_metadata.search({method: 'artist', q: 'skrillex'}, function(responseData){
	var responseData = JSON.parse(responseData);

	console.log("Number of results: "+data.info.num_results);
});

Search by album

var spotify_metadata = new Spotify.Metadata();
spotify_metadata.search({method: 'album', q: 'skrillex'}, function(responseData){
	var responseData = JSON.parse(responseData);

	console.log("Number of results: "+data.info.num_results);
});

Search by track

var spotify_metadata = new Spotify.Metadata();
spotify_metadata.search({method: 'track', q: 'skrillex'}, function(responseData){
	var responseData = JSON.parse(responseData);

	console.log("Number of results: "+data.info.num_results);
});

Artist lookup (requires an artist_id - see previous examples response data for reference - ex: 4YrKBkKSVeqDamzBPWVnSJ)

var spotify_metadata = new Spotify.Metadata();
spotify_metadata.lookup({target: 'artist', id: '4YrKBkKSVeqDamzBPWVnSJ'}, function(responseData){
	var responseData = JSON.parse(responseData);

	console.log("Number of results: "+data.info.num_results);
});

Album lookup

var spotify_metadata = new Spotify.Metadata();
spotify_metadata.lookup({target: 'album', id: '6G9fHYDCoyEErUkHrFYfs4'}, function(responseData){
	var responseData = JSON.parse(responseData);

	console.log("Number of results: "+data.info.num_results);
});

Track lookup

var spotify_metadata = new Spotify.Metadata();
spotify_metadata.lookup({target: 'track', id: '6NmXV4o6bmp704aPGyTVVG'}, function(responseData){
	var responseData = JSON.parse(responseData);

	console.log("Number of results: "+data.info.num_results);
});

Gather "extras" - Spotify Metadata API allows extra information to be returned with some results. Extra data includes album details, or track details. Examples below:

var spotify_metadata = new Spotify.Metadata();
spotify_metadata.lookup({target: 'artist', id: '4YrKBkKSVeqDamzBPWVnSJ', params: {extras: 'album'}}, function(responseData){
	var responseData = JSON.parse(responseData);

	console.log("Number of results: "+data.info.num_results);
});

spotifyjs's People

Contributors

palmerj3 avatar

Watchers

James Cloos avatar Stefano Gargiulo 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.