Socket
Socket
Sign inDemoInstall

quick-spotify-wrapper

Package Overview
Dependencies
7
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    quick-spotify-wrapper

A Simple wrapper around the spotify API


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

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 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" } }

Keywords

FAQs

Last updated on 19 Apr 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc