How to use spotify-web-api-js - 10 common examples

To help you get started, we’ve selected a few spotify-web-api-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WaterlooATX / MelodyMap / client / actions / spotify.js View on Github external
import Spotify from 'spotify-web-api-js';
const spotifyApi = new Spotify();

// our constants
export const SPOTIFY_TOKENS = 'SPOTIFY_TOKENS';
export const SPOTIFY_ME_BEGIN = 'SPOTIFY_ME_BEGIN';
export const SPOTIFY_ME_SUCCESS = 'SPOTIFY_ME_SUCCESS';
export const SPOTIFY_ME_FAILURE = 'SPOTIFY_ME_FAILURE';

/** set the app's access and refresh tokens */
export function setTokens(accessToken, refreshToken) {
  if (accessToken) { spotifyApi.setAccessToken(accessToken); }
  return { type: SPOTIFY_TOKENS, accessToken, refreshToken };
}

export function getMyInfo(){
  return {
    type: SPOTIFY_ME_BEGIN,
github benkaiser / stretto / src / js / services / spotify_api.js View on Github external
import SpotifyWebAPI from 'spotify-web-api-js';
import async from 'async';
import autobind from 'autobind-decorator';
import fetchJsonp from 'fetch-jsonp';

import Country from '../country';
import Song from '../models/song';
import SpotifyImporter from './spotify_importer';
import Utilities from '../utilities';


const SpotifyExternalAPI = new SpotifyWebAPI();

const chartMap = {
  'top': 'regional',
  'viral': 'viral'
};
const SPOTIFY_DEFAULT_COVER = 'https://developer.spotify.com/assets/branding-guidelines/icon1@2x.png';

export default class SpotifyAPI {
  static get instance() {
    return SpotifyAPI.__instance || (SpotifyAPI.__instance = new SpotifyAPI());
  }

  static fetchChart(type, options) {
    type = chartMap[type];
    const requestRealCover = options && options.requestRealCover || false;
    return fetch(`/spotifycharts/${type}/${Country.current()}/daily/latest/download`)
github ejurgensen / forked-daapd / web-src / src / pages / SpotifyPageBrowseNewReleases.vue View on Github external
load: function (to) {
    if (store.state.spotify_new_releases.length > 0) {
      return Promise.resolve()
    }

    const spotifyApi = new SpotifyWebApi()
    spotifyApi.setAccessToken(store.state.spotify.webapi_token)
    return spotifyApi.getNewReleases({ country: store.state.spotify.webapi_country, limit: 50 })
  },
github ifamed / slothMusic / src / VK / User.jsx View on Github external
import React from 'react';
import Config from '../Config/Config';
import Service from '../Service';
import Button from '../Button';
import SpotifyAPI from 'spotify-web-api-js';
import SpotifyUser from '../Spotify/User';
import oAuth from '../oAuth/oAuth';
import Captcha from '../Captcha';

const
	spotifyAPI = new SpotifyAPI(),
	spotifyUser = new SpotifyUser({access_token: localStorage.getItem('spotify_token')}),
	oauth = new oAuth();

export default class User extends React.Component {
	static propTypes = {
		access_token: React.PropTypes.string.isRequired
	};

	constructor(props) {
		super(props);

		this.state = {
			user: {},
			total: 0,
			import: [],
			albumId: null,
github WaterlooATX / MelodyMap / client / actions / actions.js View on Github external
export const FETCH_ARTIST = 'FETCH_ARTIST';
export const FETCH_SHOWS = 'FETCH_SHOWS';
export const LOCATION = 'LOCATION';
export const SELECT_ARTIST = 'SELECT_ARTIST';
export const SELECT_SHOW = 'SELECT_SHOW';
export const SELECT_VENUE = 'SELECT_VENUE';
export const SET_SPEAKER = 'SET_SPEAKER';
export const SPOTIFY_ME_BEGIN = 'SPOTIFY_ME_BEGIN';
export const SPOTIFY_ME_FAILURE = 'SPOTIFY_ME_FAILURE';
export const SPOTIFY_ME_SUCCESS = 'SPOTIFY_ME_SUCCESS';
export const SPOTIFY_TOKENS = 'SPOTIFY_TOKENS';
export const VENUES = 'VENUES';

import Spotify from 'spotify-web-api-js';
import { fetchShowsAPI } from '../models/api';
const spotifyApi = new Spotify();

export function setSpeaker(speaker) {
  return {
    type: SET_SPEAKER,
    payload: speaker,
  };
}

export function redux_Artists(artist) {
  return {
    type: FETCH_ARTIST,
    payload: artist,
  };
}

export function setLocation(location) {
github ejurgensen / forked-daapd / web-src / src / pages / SpotifyPageAlbum.vue View on Github external
load: function (to) {
    const spotifyApi = new SpotifyWebApi()
    spotifyApi.setAccessToken(store.state.spotify.webapi_token)
    return spotifyApi.getAlbum(to.params.album_id)
  },
github ejurgensen / forked-daapd / web-src / src / pages / SpotifyPageArtist.vue View on Github external
load: function (to) {
    const spotifyApi = new SpotifyWebApi()
    spotifyApi.setAccessToken(store.state.spotify.webapi_token)
    return Promise.all([
      spotifyApi.getArtist(to.params.artist_id),
      spotifyApi.getArtistAlbums(to.params.artist_id, { limit: 50, offset: 0, include_groups: 'album,single' })
    ])
  },
github ejurgensen / forked-daapd / web-src / src / pages / SpotifyPageBrowse.vue View on Github external
load: function (to) {
    if (store.state.spotify_new_releases.length > 0 && store.state.spotify_featured_playlists.length > 0) {
      return Promise.resolve()
    }

    const spotifyApi = new SpotifyWebApi()
    spotifyApi.setAccessToken(store.state.spotify.webapi_token)
    return Promise.all([
      spotifyApi.getNewReleases({ country: store.state.spotify.webapi_country, limit: 50 }),
      spotifyApi.getFeaturedPlaylists({ country: store.state.spotify.webapi_country, limit: 50 })
    ])
  },
github ejurgensen / forked-daapd / web-src / src / pages / SpotifyPagePlaylist.vue View on Github external
load_next: function ($state) {
      const spotifyApi = new SpotifyWebApi()
      spotifyApi.setAccessToken(this.$store.state.spotify.webapi_token)
      spotifyApi.getPlaylistTracks(this.playlist.id, { limit: 50, offset: this.offset }).then(data => {
        this.append_tracks(data, $state)
      })
    },

spotify-web-api-js

A client-side JS wrapper for the Spotify Web API

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular spotify-web-api-js functions