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

melodify

v1.2.3

Published

An npm module for easy song and artist search on Spotify, no user login required.

Downloads

35

Readme


Melodify

Melodify is an npm module designed to simplify searching for songs and artists on Spotify. It allows developers to easily integrate Spotify search functionality into their projects without requiring user login credentials.

Features

  • Search for Songs: Retrieve song details, including album names, artists, popularity, duration, and album cover images.
  • Search for Artists: Get information about artists, including their genres, popularity, and profile images.
  • Top Results: Customize the number of top results based on popularity to suit your needs.
  • Multilingual Support: Set the language for returned results.
  • Prodia URL: Generate a URL for additional information about tracks using the Prodia API.

Installation

To install Melodify, use npm:

npm install melodify

Usage

First, you need to obtain your Spotify client ID and client secret from the Spotify Developer Dashboard.

Example

Here's an example of how to use Melodify in your project:

const SpotifySearch = require('melodify');

const clientId = 'YOUR_SPOTIFY_CLIENT_ID';
const clientSecret = 'YOUR_SPOTIFY_CLIENT_SECRET';

const spotifySearch = new SpotifySearch(clientId, clientSecret);

(async () => {
  try {
    spotifySearch.setLanguage('tr'); // Set language to Turkish

    // Search for tracks
    const tracks = await spotifySearch.searchTrack('Imagine', 5);
    console.log('Tracks:', tracks);

    // Search for artists
    const artists = await spotifySearch.searchArtist('John Lennon', 5);
    console.log('Artists:', artists);
  } catch (error) {
    console.error('Error:', error);
  }
})();

API

searchTrack(query, limit = 3)

Searches for tracks based on the query. Returns an array of tracks with the following properties:

  • name: The name of the track.
  • album: The name of the album.
  • artists: An array of artist names.
  • popularity: The popularity of the track.
  • duration: The duration of the track in "minutes:seconds" format.
  • imageUrl: The URL of the album cover image.
  • prodiaUrl: The generated URL for additional information.
  • translations: An object containing the translated keys.

searchArtist(query, limit = 3)

Searches for artists based on the query. Returns an array of artists with the following properties:

  • name: The name of the artist.
  • genres: An array of genres associated with the artist.
  • popularity: The popularity of the artist.
  • imageUrl: The URL of the artist's profile image.
  • translations: An object containing the translated keys.

setLanguage(language)

Sets the language for the translations. Supported languages are:

  • en (English)
  • es (Spanish)
  • tr (Türkçe)

Testing

To run tests, use the following command:

npm test