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

gnus_fider

v3.2.2

Published

A JavaScript package that leverages [Genius API](https://genius.com/developers) to search and fetch song lyrics and album art.<br/>It doesn't use any native node dependencies and therefore, can be used on the client-side.

Downloads

9

Readme

genius-lyrics-api npm version

A JavaScript package that leverages Genius API to search and fetch song lyrics and album art.It doesn't use any native node dependencies and therefore, can be used on the client-side.

Installation

Install with npm

npm install --save genius-lyrics-api

Or install with Yarn

yarn add genius-lyrics-api

Usage

Get the Genius Developer Access Token

import { getLyrics, getSong } from 'genius-lyrics-api';
const options = {
	apiKey: 'XXXXXXXXXXXXXXXXXXXXXXX',
	title: 'Blinding Lights',
	artist: 'The Weeknd',
	optimizeQuery: true
};

getLyrics(options).then((lyrics) => console.log(lyrics));

getSong(options).then((song) =>
	console.log(`
	${song.id}
	${song.title}
	${song.url}
	${song.albumArt}
	${song.lyrics}`)
);

:warning: You may get a CORS block error while testing on localhost. To bypass this, you need to disable Same-Origin Policy in your browser. You may follow the instructions here.

Types

type options {
	title: string;
	artist: string;
	apiKey: string;		// Genius developer access token
	optimizeQuery?: boolean; // Setting this to true will optimize the query for best results
	authHeader?: boolean; // Whether to include auth header in the search request. 'false' by default.
}

🚨 All properties in the options object are required except optimizeQuery and authHeader. If title or artist is unknown, pass an empty string.

type song {
	id: number;		// Genius song id
	title: string;          // Song title
	url: string;		// Genius webpage URL for the song
	lyrics: string;		// Song lyrics
	albumArt: string;	// URL of the album art image (jpg/png)
}
type searchResult {
	id: number;		// Genius song id
	url: string;		// Genius webpage URL for the song
	title: string;		// Song title
	albumArt: string;	// URL of the album art image (jpg/png)
}

Methods

genius-lyrics-api exposes the following methods:

getLyrics(options | url)

Accepts options or the url to a Genius song. Returns a promise that resolves to a string containing lyrics. Returns null if no lyrics are found.

getAlbumArt(options)

Accepts an options object. Returns a promise that resolves to a url (string) to the song's album art. Returns null if no url is found.

getSong(options)

Accepts an options object. Returns a promise that resolves to an object of type song. Returns null if song is not found.

searchSong(options)

Accepts an options object. Returns a promise that resolves to an array of type searchResult. Returns null if no matches are found.

getSongById(id: (number | string))

Accepts a valid Genius song ID. IDs can be found using the searchSong method. Returns a promise that resolves to an object of type song.

Support

If you find this package useful, hit that sweet sweet ⭐️ button.