Git Product home page Git Product logo

meteor-spotify-web-api's Introduction

meteor-spotify-web-api

A meteor wrapper for Spotify's web API via the wonderful spotify-web-api-node.

Check out an example (examples/1 folder) here: http://spotify-web-api-example.meteor.com

Installation

  • meteor add xinranxiao:spotify-web-api

Usage

  1. Setup your clientId + clientSecret, either via the service-configuration package or directly through the api.
// This example is via `service-configuration`
ServiceConfiguration.configurations.update(
  { "service": "spotify" },
  {
    $set: {
      "clientId": "<your clientId>",
      "secret": "<your secret>"
    }
  },
  { upsert: true }
);
  1. Get an oauth access_token, either through xinranxiao:accounts-spotify, or directly through this API (refer here. ) for how).

  2. Make a new instance of the API and use it! Currently only available on the server.

var spotifyApi = new SpotifyWebApi();

// credentials are optional
var spotifyApi = new SpotifyWebApi({
  clientId : 'fcecfc72172e4cd267473117a17cbd4d',
  clientSecret : 'a6338157c9bb5ac9c71924cb2940e1a7',
  redirectUri : 'http://www.example.com/callback'
});
// Get Elvis' albums `synchronously` on the server.
var response = spotifyApi.getArtistAlbums('43ZHCT0cAZBISjO8DG9PnE');
console.log(response);

// Or use a classic callback approach. 
// Note that the OPTIONS parameter is always required for this format!
spotifyApi.getArtistAlbums('43ZHCT0cAZBISjO8DG9PnE', {}, function(err, result) {
  console.log(result);
});
  1. Your access_token will expire at some point.
// Just refresh the token and manually deal with the response.
// response contains the new access_token and the new expire_in
var response = spotifyApi.refreshAccessToken();

// Refresh the access token, update the current instance with the token, 
// and update the user's credentials as well.
spotifyApi.refreshAndUpdateAccessToken(); // All done here.

Currently, this package automatically sets the clientId and clientSecret if you have service-configuration configured. It also sets accessToken and refreshToken if you have a user connected with Spotify via xinranxiao:accounts-spotify (this won't work if you have your code inside a publication).

Contribution

If you have any problems with or suggestions for this package, please create a new issue.

meteor-spotify-web-api's People

Contributors

neoskai avatar xinranxiao avatar

Watchers

 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.