Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

genius-lyrics-api

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

genius-lyrics-api

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

  • 3.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
468
increased by38.46%
Maintainers
1
Weekly downloads
 
Created
Source

genius-lyrics-api npm version

A JavaScript package that leverages Genius API to search and fetch/scrape 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.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
}

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

type song {
	id: number;		// Genius song id
	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 object 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 array of type song.

Support

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

Keywords

FAQs

Package last updated on 06 Jan 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc