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 and thus, can be used on the frontend.
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 } from 'genius-lyrics-api';
const options = {
apiKey: 'XXXXXXXXXXXXXXXXXXXXXXX',
title: 'Blinding Lights',
artist: 'The Weeknd',
optimizeQuery: true
};
getLyrics(options).then(lyrics => console.log(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. Follow the instructions here.
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. Returns null
if no lyrics are 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. Returns null
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.
Support
If you find this package useful, hit the ⭐️ button. Cheers!