Spotify SDK | Entity and Collection oriented | Browser and Node support!

Overview

Spotify SDK

npm version Documentation Status

Unofficial SDK recommended for Spotify in his developer center

Entity oriented SDK to work with the Spotify Web API.

Entity oriented? What? Yes, you will always receive entities+helpers as the API's response.

An awesome example

Too simple like: Get my User then retrieve my Playlist, then add a Track to one Playlist.

user.me().then((myUser) => { // -> return a User entity with helpers
    myUser.playlists().then((playlistsCollection) => {
        playlistsCollection.first().tracks // -> tracksCollections
        playlistsCollection.first().addTrack(trackEntity) // -> add a track to the playlist
    });
});

More Examples

Basic example

Complex example

Showcase - Projects using Spotify-SDK

- MagicPlaylist

- 20v

- Infinite Music Trivia

Getting Started

You can get it on npm.

npm install spotify-sdk --save

How to start?

After installing, you should add the SDK to your project.

import {Client, TrackHandler, PlaylistHandler} from 'spotify-sdk';

You can import all entities, handlers and resources of the library.

Init the client

let client = Client.instance;

client.settings = {
    clientId: 'CLIENT_ID',
    secretId: 'SECRET_ID'
};

If your applications require methods that need authentication:

client.settings = {
    clientId: 'CLIENT_ID',
    secretId: 'SECRET_ID',
    scopes: [SCOPE, SCOPE2],
    redirect_uri: 'REDIRECT_URL'
};

client.token = 'TOKEN';

Here there is a suggested implementation for login.

Documentation

Read the documentation here

Node Support

Now you can use the sdk in node!

Browser Support

This SDK use Babel and Polyfill in order to add comptiblity with old browseres.

Chrome logo Firefox logo Internet Explorer logo Opera logo Safari logo
42+ 41+ 9+ 29+ 8

Development

git clone [email protected]:loverajoel/spotify-sdk.git

npm install

npm run watch

Contributing

Pull requests and issues are very welcome. If you have found an bug, please open an issue.

License

MIT

Comments
  • Encoding query parameters

    Encoding query parameters

    I was testing today your MagicPlaylist site and I realised it's not handling some special characters properly when searching.

    A search query like "Maná" triggers the following request: https://api.spotify.com/v1/search?type=track&q=Man%E1&limit=1&market=US

    however, it should trigger this one instead: https://api.spotify.com/v1/search?type=track&q=Man%C3%A1&limit=1&market=US

    The query parameters need to be url encoded here: https://github.com/loverajoel/spotify-sdk/blob/master/src/handlers/TrackHandler.js#L24

    Let me know if you think this is a valid issue and I can work myself on a fix.

    bug 
    opened by JMPerez 2
  • Support for saved tracks and albums

    Support for saved tracks and albums

    Added support for user's saved tracks and albums.

    user.me().then((user) => {
    
      // Get user's saved tracks
      user.tracks().then((res) => {
        console.log('tracks', res);
      });
    
      // Get user's saved albums
      user.albums().then((res) => {
        console.log('albums', res);
      });
    
    });
    

    Array of tracks

    screen shot 2016-12-02 at 10 37 13

    Array of albums

    screen shot 2016-12-02 at 10 37 39

    opened by emiprandi 1
  • Set Client.fetch() method default 'GET'. Spelling fixes.

    Set Client.fetch() method default 'GET'. Spelling fixes.

    A bug I noticed while creating the unit test for Client.fetch() ... If 'method' is not set, the structure is POST (no query string, body set) but 'method' on the request is GET.

    if (method === 'GET') { ... assumes post while method: method || 'GET', ... assumes get

    I moved to the top: method = method || 'GET';

    Also a few trivial spelling corrections. I believe the whitespace changes are consistent with your styling preferences.

    opened by richclingman 1
  • Encode search query parameters to handle better non-ascii text - Fixes #13

    Encode search query parameters to handle better non-ascii text - Fixes #13

    This should fix the issue with the q query parameter when searching Spotify entities.

    I couldn't test these changes because the project wouldn't build for me. I'm seeing:

    [07:38:46] Starting 'build-persistent'...
    Error: Parsing file /Users/jmperez/spotify-sdk/examples/oauth.js: 'import' and 'export' may appear only with 'sourceType: module' (8:0)
    
    opened by JMPerez 1
  • Add Babel as a dev dependency

    Add Babel as a dev dependency

    This fixes the problem of not having installed babel as a global dependency, which makes running npm install fail trying to execute babel -d lib/ src/.

    opened by JMPerez 1
  • Add more browsers compatibility

    Add more browsers compatibility

    What does this PR do?

    Add core-js and github/fetch polyfill in order to add more browsers compatibility. Only use Promise, Symbol and fetch.

    Question?

    It's responsibility of the SDK add old browsers compatibility or of the implementation?

    What are the relevant tickets?

    https://github.com/loverajoel/spotify-sdk/issues/7

    enhancement 
    opened by loverajoel 0
  • Artsits: add follow and unfollow methods

    Artsits: add follow and unfollow methods

    What does this PR do?

    Add two new methods to Artists Entity and Artists Handlers.

    How should this be manually tested?

    Test the last example in examples/oauth.js

    npm run watch

    opened by loverajoel 0
  • docs: Fix simple typo, retrive -> retrieve

    docs: Fix simple typo, retrive -> retrieve

    There is a small typo in src/handlers/AlbumHandler.js, src/handlers/ArtistHandler.js, src/handlers/TrackHandler.js, src/handlers/UserHandler.js.

    Should read retrieve rather than retrive.

    opened by timgates42 0
  • Few Missing Entities

    Few Missing Entities

    @loverajoel

    I think since there has been no activity in this package, it is missing a few entities like episodes and shows.

    Also, I could not find a handler for search where you could perform a generic search for all entities.

    I would be happy to add these in and submit a pull request.

    opened by nomanurrehman 2
Releases(v1.0.0-beta1)
Owner
Joel Lovera
Creator of magicplaylist.co
Joel Lovera
Json2video-nodejs-sdk - Create videos programmatically in the cloud from NodeJS: add watermarks, resize videos, create slideshows, add soundtrack, voice-over with text-to-speech (TTS), text animations.

Create videos programmatically in Node JS Create and edit videos: add watermarks, resize videos, create slideshows, add soundtrack, automate the creat

null 2 Nov 20, 2022
discord.js is a powerful Node.js module that allows you to easily interact with the Discord API.

A powerful JavaScript library for interacting with the Discord API

Discord.js 21.6k Jan 5, 2023
Notion 3.4k Dec 30, 2022
This Binance trading bot detects the most volatile cryptos to buy and later sell at predefined Take Profit / Stop Loss thresholds.

Binance-volatility-trading-bot-JS I take the idea from this project. The original bot is written in Python. I quite like it so I re-write it in Java S

null 33 Aug 15, 2022
example app that creates a new player in Spotify Connect to play music from in the browse using Spotify Web Playback SDK.

Spotify Web Playback SDK Demo Requirements User must have Spotify Premium, DRM & EME supported and JavaScript enabled Web Browser. License Copyright 2

Sijey 8 Jul 20, 2022
A typescript data mapping tool. To support mutual transforming between domain model and orm entity.

ts-data-mapper A typescript mapping tool supports mutual transforming between domain model and orm entity. In most case, domain model is not fully com

zed 8 Mar 26, 2022
Spotify 2.0 com NextJS 12 - MIddleware, TailwindCSS, Spotify API, NextAuth, Recoil

Spotify Clone A spotify clone made with NextJS 12, TailwindCSS, NextAuth, Spotify API, Recoil Lessons Learned Setting up NextJS with Tailwind. NextAut

zF4ke 3 Mar 14, 2022
Spotify clone using Next.js, Spotify API, Tailwind, NextAuth, Recoil

Next.js + Tailwind CSS Example This example shows how to use Tailwind CSS (v2.2) with Next.js. It follows the steps outlined in the official Tailwind

Abdelwahab Hussein 2 Dec 25, 2021
spotify.ts is an wrapper built around Spotify's Web API

spotify.ts About spotify.ts is an wrapper built around Spotify's Web API. Features Fast Object Oriented Typescript, ESM, CJS support Easy to Use Insta

null 6 Nov 17, 2022
An NLP library for building bots, with entity extraction, sentiment analysis, automatic language identify, and so more

NLP.js If you're looking for the version 3 docs, you can find them here Version 3 "NLP.js" is a general natural language utility for nodejs. Currently

AXA 5.3k Dec 29, 2022
Show multiple entity states, attributes and icons in a single card in Home Assistant's Lovelace UI

room-card Show multiple entity states, attributes and icons in a single card in Home Assistant's Lovelace UI NOTE: This card is base on the multiple-e

Marco Kreeft 79 Dec 16, 2022
A 👩‍💻 developer-friendly entity management system for 🕹 games and similarly demanding applications, based on 🛠 ECS architecture.

Miniplex Ecosystem miniplex miniplex-react Introduction Miniplex is an entity management system for games and similarly demanding applications. Instea

Hendrik Mans 253 Dec 31, 2022
A robust HTML entity encoder/decoder written in JavaScript.

he he (for “HTML entities”) is a robust HTML entity encoder/decoder written in JavaScript. It supports all standardized named character references as

Mathias Bynens 3.2k Dec 27, 2022
Package for creating entity framework in a nodejs project based on Laravel artisan system.

Artisan Structuring system for an ExpressJs project. Version [Production] release 0.2.0 artisan - npm package Dependencies nodejs Installations Instal

Filipe A.S 17 Dec 11, 2022
Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's `move-ts`.

Movehat Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's move-ts. Movehat aspires to b

Pentagon 10 Sep 30, 2022
The iofod SDK provides developers with the ability to interact with the main iofod interface within the Web worker, enabling rapid development of iofod extensions through the SDK.

iofod-sdk English | 简体中文 The iofod SDK provides developers with the ability to interact with the main iofod interface within the Web worker, enabling

iofod, Inc. 47 Oct 17, 2022
Full-featured, middleware-oriented, programmatic HTTP and WebSocket proxy for node.js

rocky A multipurpose, full-featured, middleware-oriented and hackable HTTP/S and WebSocket proxy with powerful built-in features such as versatile rou

Tom 370 Nov 24, 2022
Query for CSS brower support data, combined from caniuse and MDN, including version support started and global support percentages.

css-browser-support Query for CSS browser support data, combined from caniuse and MDN, including version support started and global support percentage

Stephanie Eckles 65 Nov 2, 2022
Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all with IndexedDB. Perfectly suitable for your next (PWA) app.

BrowstorJS ?? ?? ?? Persistent key/value data storage for your Browser and/or PWA, promisified, including file support and service worker support, all

Nullix 8 Aug 5, 2022
A complete guide for learning Object Oriented Programming Pillars, SOLID Principles and Design Patterns with TypeScript!

Object Oriented Programming Expert With TypeScript This repository is a complete guide and tutorial for the principles and techniques of object-orient

Ahmad Jafari 44 Dec 29, 2022