npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ejs-red-spotify

v0.0.3

Published

Spotify nodes

Downloads

8

Readme

ejs-red-spotify

Node red Spotify nodes

An experiment creating nodes to interact with Spotify

TODO

  1. Write help docs for nodes.
  2. Implement refresh token
  3. Store auth tokens in some way
  4. implement more of the api. Search, specific track.

Requirements

Currently the Spotify API requires that you have a Paid account to interact with most of the cool/fun api calls.

Pretty sure you also need an externally accessible node red domain for the auth callback,

NPM install

https://www.npmjs.com/package/ejs-red-spotify

npm install ejs-red-spotify --save

Flow

[{"id":"7c48295f.387a48","type":"http response","z":"b642d645.ba6cf8","name":"","statusCode":"","headers":{},"x":1387.5,"y":140,"wires":[]},{"id":"9c1ed06.a92163","type":"template","z":"b642d645.ba6cf8","name":"Spotify Sign in","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n  <head>\n  \n  <style type=\"text/css\">\n  /*#login {*/\n  /*  display: none;*/\n  /*}*/\n\n  /*#loggedin {*/\n  /*  display: none;*/\n  /*}*/\n  \n</style>\n<body>\n <div>\n    <div id=\"login\">\n     <h1>First, log in to spotify</h1>\n     <a href=\"/spotify/login\">Log in</a><br/>\n     <a href=\"/spotify/skip\">Skip</a><br/>\n     <a href=\"/spotify/pause\">Pause</a><br/>\n     <a href=\"/spotify/play\">Play</a><br/>\n     <a href=\"/spotify/search\">Search</a><br/>\n    </div>\n    <div id=\"loggedin\">\n    </div>\n </div>\n\n <script id=\"loggedin-template\" type=\"text/x-handlebars-template\">\n    <h1>Logged in as {{display_name}}</h1>\n    <img id=\"avatar\" width=\"200\" src=\"{{images.0.url}}\" />\n    <dl>\n     <dt>Display name</dt><dd>{{display_name}}</dd>\n     <dt>Username</dt><dd>{{id}}</dd>\n     <dt>Email</dt><dd>{{email}}</dd>\n     <dt>Spotify URI</dt><dd><a href=\"{{external_urls.spotify}}\">{{external_urls.spotify}}</a></dd>\n     <dt>Link</dt><dd><a href=\"{{href}}\">{{href}}</a></dd>\n     <dt>Profile Image</dt><dd>{{images.0.url}}</dd>\n    </dl>\n    <p><a href=\"/\">Log in again</a></p>\n </script>\n</body>\n</html>","output":"str","x":589.0554733276367,"y":140.99998664855957,"wires":[["7c48295f.387a48","eb03cb0a.2302d8"]]},{"id":"956d2dce.e447d","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify","method":"get","upload":false,"swaggerDoc":"","x":254,"y":140,"wires":[["9c1ed06.a92163"]]},{"id":"e0c2338f.14c95","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify/callback","method":"get","upload":false,"swaggerDoc":"","x":282,"y":460,"wires":[["6f9169ee.e03c28","43e844de.9e6a0c"]]},{"id":"6f9169ee.e03c28","type":"debug","z":"b642d645.ba6cf8","name":"","active":false,"console":"false","complete":"true","x":548.5,"y":400,"wires":[]},{"id":"6d8b6fa.f59829","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify/login","method":"get","upload":false,"swaggerDoc":"","x":271.5,"y":320,"wires":[["8c045a92.c20528"]]},{"id":"a83ebfd5.71aa4","type":"http response","z":"b642d645.ba6cf8","name":"","statusCode":"307","headers":{},"x":1404.5,"y":460,"wires":[]},{"id":"9fa829fe.0e0728","type":"http response","z":"b642d645.ba6cf8","name":"","statusCode":"307","headers":{},"x":1404.5,"y":320,"wires":[]},{"id":"9507e940.78ed68","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify/refresh_token","method":"get","upload":false,"swaggerDoc":"","x":298.5,"y":540,"wires":[[]]},{"id":"b4219872.3d9b28","type":"http request","z":"b642d645.ba6cf8","name":"","method":"POST","ret":"obj","url":"","tls":"","x":813,"y":460,"wires":[["fa147f30.7e346"]]},{"id":"fa147f30.7e346","type":"function","z":"b642d645.ba6cf8","name":"Decode Auth Reponse","func":"var access_token = msg.payload.access_token;\nvar refresh_token = msg.payload.refresh_token;\n\nmsg.cookies = {\n    refresh_token: {\n        value: refresh_token,\n        maxAge: 900000\n    },\n    access_token: {\n        value: access_token,\n        maxAge: 900000\n    }\n}\nglobal.set(\"refresh_token\",refresh_token); \nglobal.set(\"access_token\",access_token); \nmsg.headers= {location: \"/spotify/?\"+Math.random(1000)};\nreturn msg;","outputs":1,"noerr":0,"x":1145.5,"y":460,"wires":[["a83ebfd5.71aa4","64d9c5cc.c2d9dc"]],"inputAlignments":[false],"outputAlignments":[false]},{"id":"64d9c5cc.c2d9dc","type":"debug","z":"b642d645.ba6cf8","name":"","active":true,"console":"false","complete":"true","x":1388.5,"y":520,"wires":[]},{"id":"eb03cb0a.2302d8","type":"debug","z":"b642d645.ba6cf8","name":"","active":false,"console":"false","complete":"true","x":788.5,"y":100,"wires":[]},{"id":"105ba84d.767388","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify/skip","method":"get","upload":false,"swaggerDoc":"","x":269,"y":860,"wires":[["f75049d5.6d1c98"]]},{"id":"5576db66.9c25d4","type":"debug","z":"b642d645.ba6cf8","name":"","active":true,"console":"false","complete":"true","x":1148.5,"y":820,"wires":[]},{"id":"c51b0c43.1ad1","type":"http request","z":"b642d645.ba6cf8","name":"","method":"use","ret":"txt","url":"","tls":"","x":953,"y":860,"wires":[["5576db66.9c25d4"]]},{"id":"71a6fdf2.4499b4","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify/play","method":"get","upload":false,"swaggerDoc":"","x":269,"y":960,"wires":[["e7daa6fe.4cf6c8"]]},{"id":"1a4ba821.530078","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify/pause","method":"get","upload":false,"swaggerDoc":"","x":275.5,"y":760,"wires":[["950bcb33.681b78"]]},{"id":"8e809922.9efd28","type":"spotify-authorise","z":"b642d645.ba6cf8","name":"","spotifyConfig":"ee2518f3.d40368","x":827.5,"y":320,"wires":[["9fa829fe.0e0728"]]},{"id":"8c045a92.c20528","type":"spotify-scope","z":"b642d645.ba6cf8","name":"","scopes":["user-read-playback-state","user-library-read","user-modify-playback-state"],"x":578,"y":320,"wires":[["8e809922.9efd28"]]},{"id":"950bcb33.681b78","type":"spotify-api","z":"b642d645.ba6cf8","name":"","action":"pause","x":590,"y":760,"wires":[["c51b0c43.1ad1"]]},{"id":"f75049d5.6d1c98","type":"spotify-api","z":"b642d645.ba6cf8","name":"","action":"next","x":584.5,"y":860,"wires":[["c51b0c43.1ad1","bb2bb996.10ebd8"]]},{"id":"e7daa6fe.4cf6c8","type":"spotify-api","z":"b642d645.ba6cf8","name":"","action":"play","x":584,"y":960,"wires":[["c51b0c43.1ad1"]]},{"id":"bb2bb996.10ebd8","type":"debug","z":"b642d645.ba6cf8","name":"","active":true,"console":"false","complete":"true","x":928.5,"y":800,"wires":[]},{"id":"43e844de.9e6a0c","type":"spotify-callback","z":"b642d645.ba6cf8","name":"","spotifyConfig":"ee2518f3.d40368","x":584.5,"y":460,"wires":[["b4219872.3d9b28"]]},{"id":"93da6fea.dbcf9","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify/search","method":"get","upload":false,"swaggerDoc":"","x":277,"y":1160,"wires":[["117cf77c.c19869"]]},{"id":"117cf77c.c19869","type":"spotify-api","z":"b642d645.ba6cf8","name":"","action":"search","x":592,"y":1160,"wires":[["c51b0c43.1ad1","bb2bb996.10ebd8"]]},{"id":"2032ed39.255b52","type":"spotify-api","z":"b642d645.ba6cf8","name":"","action":"track","x":586.5,"y":1240,"wires":[[]]},{"id":"4584997b.7394c8","type":"http in","z":"b642d645.ba6cf8","name":"","url":"/spotify/track","method":"get","upload":false,"swaggerDoc":"","x":272,"y":1240,"wires":[["2032ed39.255b52"]]},{"id":"ec567d7e.e3a1d","type":"link in","z":"b642d645.ba6cf8","name":"Spotify-Pause","links":["e625aed2.20a87"],"x":335,"y":720,"wires":[["950bcb33.681b78"]]},{"id":"f192f0dd.eb453","type":"link in","z":"b642d645.ba6cf8","name":"Spotify-Next","links":["e8142471.28aaf8"],"x":335,"y":820,"wires":[["f75049d5.6d1c98"]]},{"id":"29ac83be.f22b2c","type":"link in","z":"b642d645.ba6cf8","name":"Spotify-Play","links":["97a4a776.7d7b08"],"x":335,"y":920,"wires":[["e7daa6fe.4cf6c8"]]},{"id":"c4cd570b.2c7708","type":"link in","z":"b642d645.ba6cf8","name":"Spotify-Search","links":[],"x":335,"y":1120,"wires":[["117cf77c.c19869"]]},{"id":"35d632ff.44b0de","type":"comment","z":"b642d645.ba6cf8","name":"Playback Control","info":"","x":148.5,"y":640,"wires":[]},{"id":"6e402d6f.3d47f4","type":"comment","z":"b642d645.ba6cf8","name":"Search","info":"","x":117,"y":1060,"wires":[]},{"id":"b5759d4a.ecf07","type":"comment","z":"b642d645.ba6cf8","name":"Authorisation","info":"","x":136.5,"y":240,"wires":[]},{"id":"ad2a0da2.ac568","type":"comment","z":"b642d645.ba6cf8","name":"Control Page","info":"","x":136,"y":60,"wires":[]},{"id":"2cbd779.e7b0f88","type":"comment","z":"b642d645.ba6cf8","name":"TODO - save credentials","info":"","x":1152,"y":420,"wires":[]}]

Demo Flow