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

@noise-machines/lyricist

v2.3.0

Published

Fetches song lyrics using the Genius.com API and website.

Downloads

4

Readme

Lyricist 🎤

⭐️ Genius.com API client with lyrics scraper

v2.0

Version 2.0 is a complete rewrite with async/await.

Installation

yarn add lyricist

or

npm install lyricist --save

Node 6

Node 6 doesn't support async/await and will need to use the transpiled version (lyricist/node6), along with promises:

const Lyricist = require('lyricist/node6');

Note: Older versions of Node aren't currently supported. Open an issue if you'd like to see support for them

API Key

Get an access token at https://genius.com/api-clients.

const lyricist = new Lyricist(accessToken);

Look up a song

Use song() to fetch a song by ID:

const song = await lyricist.song(714198);
console.log(song.title);

// output: Death with Dignity

or with promises for node <= 6:

lyricist.song(714198).then(song => console.log(song.title));

Set text_format

The Genius API lets you specify how the response text is formatted. Supported formatting options are dom (default), plain and html. See https://docs.genius.com/#/response-format-h1 for further information. The textFormat option is supported by song(), album() and artist().

lyricist.song(714198, { textFormat: 'html' }).then(song => console.log(song.description.html));

// output: <p>The first track off of Sufjan’s 2015 album...

Get song lyrics

The Genius API doesn't offer lyrics, but Lyricist can scrape Genius.com for you. Simply provide the fetchLyrics option like this:

const song = await lyricist.song(714198, { fetchLyrics: true });
console.log(song.lyrics);

// output: Spirit of my silence I can hear you...

Look up an album

Use album() to look up an album by ID. The Genius API doesn't allow you to search an album by title, but song() will return an album.id:

const album = await lyricist.album(56682);
console.log(`${album.name} by ${album.artist.name}`);

// output: Lanterns by Son Lux

Get an album's tracklist

The Genius API doesn't provide tracklists, but Lyricist can scrape Genius.com and return the tracklist for you. Simply provide the fetchTracklist option like this:

const album = await lyricist.album(56682, { fetchTracklist: true });
console.log(album.songs);

// output: [{ id: 502102, title: 'Alternate World', ... }, { id: 267773, title: 'Lost It To Trying', ... }, ...]

Look up an artist

Use artist() to look up an artist by ID:

const artist = await lyricist.artist(2);
console.log(artist.name);
// output: Jay Z

Get songs by an artist

Use songsByArtist() to list an artist's songs. Example usage:

const songs = await lyricist.songsByArtist(2);

songsByArtist() will show 20 results per page by default, and can be as high as 50.

You can provide options as a second parameter. The available options are:

  • perPage: Number (default: 20)
  • page: Number (default: 1)
  • sort String: 'title' or 'popularity' (default: 'title')

Search for songs

Use search(query, { page = 1}) to search for songs using the Genius search endpoint. Genius' search endpoint doesn't seem to accept a perPage param.

Example:

const songs = await lyricist.search('Animal Collective', { page: 2 })

Warning ⚠️

Take care when fetching lyrics. This feature isn't officially supported by the Genius API, so use caching and rate-limit your app's requests as much as possible.

Genius API Docs

Check the Genius.com API docs for more info.