spotify-lyrics-api
v0.1.5
Published
A simple Node.js wrapper for fetching track lyrics from Spotify using internal endpoints.
Downloads
17
Maintainers
Readme
Spotify Lyrics Api for Nodejs
A simple Node.js wrapper for fetching track lyrics from Spotify using internal endpoints.
Lyrics can be retrieved with either a Spotify track ID or track URL.
[!WARNING] This wrapper/API uses internal Spotify endpoints and may violate Spotify's Terms of Service. Use on your own risk.
[!NOTE] Lyrics may not be available for free-tier accounts, even with a valid
sp_dccookie, due to Spotify limiting access to lyrics for them altogether.
Usage
- Install and import the
SpotifyLyricsclass
npm install spotify-lyrics-apiimport SpotifyLyricsApi from "spotify-lyrics-api"- You’ll need your Spotify
sp_dccookie (tied to your account). An indepth guide is provided by akashchandran here.
const my_sp_dc = "AQAcoo1dC1AhQ7eWRTeTj7FSOfrjj4tihjIhZr...";
const spotify = new SpotifyLyricsApi(my_sp_dc);- Asynchronous call to
getLyricsFromIDorgetLyricsFromURL
const trackID = "4gMgiXfqyzZLMhsksGmbQV"; // Pink Floyd - Another Brick in the Wall
const lyrics = await spotify.getLyricsFromID(trackID);
await writeFile("another-brick-in-the-wall.json", JSON.stringify(lyrics, null, 2));
const trackURL = "https://open.spotify.com/track/5jgFfDIR6FR0gvlA56Nakr?si=8d95746b3c694281" // The Beatles - Blackbird
const lyrics2 = await spotify.getLyricsFromURL(trackURL);
await writeFile("blackbird-2.json", JSON.stringify(lyrics2, null, 2));
Returned Lyrics
In most cases error is raised if lyrics for a particular track are not found.
If found, lyrics follow the SongLyricsData interface
interface SongLyricsData {
lyrics: Lyrics;
colors: Colors;
hasVocalRemoval: boolean;
}With Lyrics being
interface Lyrics {
syncType: string;
lines: LyricsLine[];
provider: string;
providerLyricsId: string;
providerDisplayName: string;
syncLyricsUri: string;
isDenseTypeface: boolean;
alternatives: any[];
language: string;
isRtlLanguage: boolean;
capStatus: string;
previewLines: LyricsLine[];
}With LyricsLine being
interface LyricsLine {
startTimeMs: string;
words: string;
syllables: any[];
endTimeMs: string;
transliteratedWords: string;
}With Colors being
interface Colors {
background: number;
text: number;
highlightText: number;
}Credits
Based on the PHP API by @akashrchandran.
@Thereallo1026 for updated Spotify secrets.
