genius-lyrics-api
A package that provides a convenient wrapper around Genius API for searching and scraping song lyrics.
It doesn't use any native node dependencies so it should work fine with front-end libraries like ReactJS & React Native.
Installation
Install with npm
npm install --save genius-lyrics-api
Or install with Yarn
yarn add genius-lyrics-api
Usage
import { getLyrics } from 'genius-lyrics-api';
const options = {
apiKey: 'XXXXXXXXXXXXXXXXXXXXXXX',
title: 'Blinding Lights',
artist: 'The Weeknd',
optimizeQuery: true
};
getLyrics(options).then(lyrics => console.log(lyrics));
Methods
genius-lyrics-api exposes the following methods:
getLyrics(options)
Automatically get the lyrics from genius.com using the title
& artist
fields.
Returns a promise that resolves to a string containing lyrics. Throws an error if lyrics are not found.
Arguments
const options = {
apiKey: string,
title: string,
artist: string,
optimizeQuery: boolean
};
All properties in the options
object are required except optimizeQuery
. If either of the title
or artist
is unknown, pass an empty string as its value.
searchLyrics(options)
Search lyrics from genius.com using the title
& artist
fields.
Returns a promise that resolves to an array of search results. Throws an error if no matches are found.
Receives the same arguments as getLyrics
.
getLyricsFromPath(path: string)
Get the lyrics of a song using the path
property present in the search results of searchLyrics
method.
Returns a promise that resolves to a string containing lyrics.