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

quick-spotify-wrapper

v1.0.6

Published

A Simple wrapper around the spotify API

Downloads

2

Readme

Spotify API Wrapper

Moved from Chat-and-Share/quick-spotify-wrapper

Full documentation can be found here.

For support you can join my Discord Server.

Creating a Client

Example:

const Spotify = require("quick-spotify-wrapper");
const spotify = new Spotify("client id", "client secret");

(async () => {
  await spotify.login(); // you must call the login function before you can use any part of the library!
  // you can now use the library and make api calls!
})();

The client will handle automatically refreshing the authentication token.

Authentication Status

You can check the authentication status with spotify.authenticated which will return a boolean

Search

Search Example:

(async () => {
  await spotify.login();
  const results = await spotify
    .search("track:counting stars", 1, ["track"])
    .catch((error) => console.error(error));
  console.log(results);
})();

information related to how to use search can be found here: Spotify API Reference

Recommendations API

AN IMPORTANT THING TO UNDERSTAND IS THAT BETWEEN SEED_ARTISTS, SEED_GENRES, AND SEED_TRACKS, YOU CAN ONLY HAVE A MAX OF 5 COMBINED! NOT 5 PER SEED!

Recommendations API can be a bit complex so here are some examples:

Basic:

(async () => {
  await spotify.login();
  const results = await spotify.browse
    .getRecommendations(
      ["2sf28o6euxEDpYkG9dMtuM", "3bwENxqj9nhaAI3fsAwmv9"],
      ["pop"],
      ["6XwnkMuCSCu46Q4BS5nGNL", "4BacK7ZctqLEyFomDuh9jG"]
    )
    .catch((error) => console.error(error));
  console.log(results);
})();

What this does is generates recommendations from artists, genres, and tracks provided. You can provide up to 5 tracks, genres, and artists. this is the most basic example.

Here is a more complex example:

(async () => {
  await spotify.login();
  const results = await spotify.browse
    .getRecommendations(
      ["2sf28o6euxEDpYkG9dMtuM", "3bwENxqj9nhaAI3fsAwmv9"],
      ["pop"],
      ["6XwnkMuCSCu46Q4BS5nGNL", "4BacK7ZctqLEyFomDuh9jG"],
      ["min_popularity=1", "min_speechiness=0.33"],
      ["max_popularity=80", "max_speechiness=0.66"]
    )
    .catch((error) => console.error(error));
  console.log(results);
})();

This example generates recommendations with a minimum popularity of 1 and speechiness of 0.33, and a maximum popularity of 80 and speechiness of 0.66

More information on how to use this API can be found here: Spotify API Docs

Errors:

Spotify api returns error objects in the following form:

{ error: { status: <http resonse code>, message: '<error messages>' } }

Examples:

{ "error": { "status": 404, "message": "No such user" } }
{ "error": { "status": 400, "message": "invalid request" } }