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

spotify-recommendation

v1.0.1

Published

A module generates recommendations from tracks, artists, etc...

Downloads

11

Readme

What is this?

This module generates recommended songs for you using Spotify's Web API

Installation

  npm install spotify-recommendation
  // or
  yarn add spotify-recommendation

Usage

  const spotify-recommendation = require('spotify-recommendation')
  // or
  import { generateRecommendations, getAudioFeatures, getArtistGenres } from 'spotify-recommendation'

  spotify-recommendation.generateRecommendations(accessToken, trackId, artists, limit)
  // or
  generateRecommendations(accessToken, trackId, artistGenres, limit)

Parameters

  • accessToken* (string) - Access token you get by logging in user
  • trackId* (array, max 100)
  • artists (optional, array, max 100)
  • limit (optional, number, default 100)

Functions

  • generateRecommendations - This function generates recommendations based on given tracks and artists.

  • getAudioFeatures - This function returns audio features of given songs. (acousticness, danceability, energy, loudness, speechiness, tempo)

  • getArtistGenres - Returns the two most prevalent genres among artists.

All functions returns promise so you can use them like

generateRecommendations(accessToken, trackIds, artists, 50).then((data) => {
  console.log(data);
  recommendedSongs = data;
}

Returned Data

  • generateRecommendations
{
  album: {
    album_type: 'ALBUM',
    artists: [ [Object] ],
    available_markets: [
      'AR', 'AU', 'AT', 'BE', 'BO', 'BR', 'BG', 'CA', 'CL', 'CO',
      'CR', 'CY', 'CZ', 'DK', 'DO', 'DE', 'EC', 'EE', 'SV', 'FI',
      'FR', 'GR', 'GT', 'HN', 'HK', 'HU', 'IS', 'IE', 'IT', 'LV',
      'LT', 'LU', 'MY', 'MT', 'MX', 'NL', 'NZ', 'NI', 'NO', 'PA',
      'PY', 'PE', 'PH', 'PL', 'PT', 'SG', 'SK', 'ES', 'SE', 'CH',
      'TW', 'TR', 'UY', 'US', 'GB', 'AD', 'LI', 'MC', 'ID', 'JP',
      'TH', 'VN', 'RO', 'IL', 'ZA', 'SA', 'AE', 'BH', 'QA', 'OM',
      'KW', 'EG', 'MA', 'DZ', 'TN', 'LB', 'JO', 'PS', 'IN', 'BY',
      'KZ', 'MD', 'UA', 'AL', 'BA', 'HR', 'ME', 'MK', 'RS', 'SI',
      'KR', 'BD', 'PK', 'LK', 'GH', 'KE', 'NG', 'TZ', 'UG', 'AG',
    ],
    external_urls: {
      spotify: 'https://open.spotify.com/album/3BIiOsLIJBsH9UJYFRqfxs'
    },
    href: 'https://api.spotify.com/v1/albums/3BIiOsLIJBsH9UJYFRqfxs',
    id: '3BIiOsLIJBsH9UJYFRqfxs',
    images: [ [Object], [Object], [Object] ],
    name: 'Ölüm Dansı',
    release_date: '2023-08-04',
    release_date_precision: 'day',
    total_tracks: 13,
    type: 'album',
    uri: 'spotify:album:3BIiOsLIJBsH9UJYFRqfxs'
  },
  artists: [
    {
      external_urls: [Object],
      href: 'https://api.spotify.com/v1/artists/0PhqM7UAxtvWYi5j4MwxSl',
      id: '0PhqM7UAxtvWYi5j4MwxSl',
      name: 'Dolu Kadehi Ters Tut',
      type: 'artist',
      uri: 'spotify:artist:0PhqM7UAxtvWYi5j4MwxSl'
    }
  ],
  available_markets: [
    'AR', 'AU', 'AT', 'BE', 'BO', 'BR', 'BG', 'CA', 'CL', 'CO',
    'CR', 'CY', 'CZ', 'DK', 'DO', 'DE', 'EC', 'EE', 'SV', 'FI',
    'FR', 'GR', 'GT', 'HN', 'HK', 'HU', 'IS', 'IE', 'IT', 'LV',
    'LT', 'LU', 'MY', 'MT', 'MX', 'NL', 'NZ', 'NI', 'NO', 'PA',
    'PY', 'PE', 'PH', 'PL', 'PT', 'SG', 'SK', 'ES', 'SE', 'CH',
    'TW', 'TR', 'UY', 'US', 'GB', 'AD', 'LI', 'MC', 'ID', 'JP',
    'TH', 'VN', 'RO', 'IL', 'ZA', 'SA', 'AE', 'BH', 'QA', 'OM',
    'KW', 'EG', 'MA', 'DZ', 'TN', 'LB', 'JO', 'PS', 'IN', 'BY',
    'KZ', 'MD', 'UA', 'AL', 'BA', 'HR', 'ME', 'MK', 'RS', 'SI',
    'KR', 'BD', 'PK', 'LK', 'GH', 'KE', 'NG', 'TZ', 'UG', 'AG',
  ],
  disc_number: 1,
  duration_ms: 217546,
  explicit: false,
  external_ids: { isrc: 'QM4TX2382181' },
  external_urls: { spotify: 'https://open.spotify.com/track/1udlzg1P1Tqh4WGouHwXJA' },
  href: 'https://api.spotify.com/v1/tracks/1udlzg1P1Tqh4WGouHwXJA',
  id: '1udlzg1P1Tqh4WGouHwXJA',
  is_local: false,
  name: 'Ölüm Dansı',
  popularity: 46,
  preview_url: 'https://p.scdn.co/mp3-preview/140047a779bf0a63c64eb3f724a03f5eee8246ce?cid=a338ac7473534abcb3c7b9eacfdd3989',
  track_number: 13,
  type: 'track',
  uri: 'spotify:track:1udlzg1P1Tqh4WGouHwXJA'
}
  • getAudioFeatures
{
  acousticness: 0.28753,
  danceability: 0.533,
  energy: 0.70733,
  loudness: -6.58,
  speechiness: 0.044,
  tempo: 128.29433
}
  • getArtistGenres
["turkish rock", "alternative rock"];