RepositoryINIndia
AK

akashrchandran/spotify-lyrics-api

Archived Not Maintained Anymore.

642stars
55forks
2issues
7views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: musixmatch

#1 Repository of the week

1
TINIX TRENDING·Topic: spotify-lyrics

#1 Repository of the week

2
TINIX TRENDING·Topic: synced-lyrics

#2 Repository of the week

spotify-lyrics-api


A Rest API for fetching lyrics from Spotify which is powered by Musixmatch. Commandline version is available akashrchandran/syrics.

[!WARNING] This project is probably against Spotify TOS. Use at your own risks.

[!NOTE] Changed this project into a template repository, deploy your own version. If you need help, don't hesitate to open an issue.

Quick Start with Docker

The easiest way to run the API is using Docker:

docker run -d -p 8080:8080 -e SP_DC=your_sp_dc_cookie akashrchandran/spotify-lyrics-api

Then access the API at http://localhost:8080/?trackid=YOUR_TRACK_ID

Docker Compose

services:
  spotify-lyrics-api:
    image: akashrchandran/spotify-lyrics-api:latest
    ports:
      - "8080:8080"
    environment:
      - SP_DC=your_sp_dc_cookie
    restart: unless-stopped

📦 View on Docker Hub

Install using Composer

composer require akashrchandran/spotify-lyrics-api

Fetching Lyrics

For now it only supports track id or link.

Using GET Requests

You have to use query paramters to send data

Available Parameters:

ParameterDefault valueTypeDescription
trackid NoneStringThe trackid from spotify.
urlNoneStringThe url of the track from spotify.
format"id3"StringThe format of lyrics required. Options: id3, lrc, srt, raw.

You must specify either trackid or url, otherwise it will return error.

Examples

Using trackid

http://localhost:8080/?trackid=5f8eCNwTlr0RJopE9vQ6mB

Using url

http://localhost:8080/?url=https://open.spotify.com/track/5f8eCNwTlr0RJopE9vQ6mB?autoplay=true

response:

{
    "error": false,
    "syncType": "LINE_SYNCED",
    "lines": [
        {
            "startTimeMs": "960",
            "words": "One, two, three, four",
            "syllables": [],
            "endTimeMs": "0"
        },
        {
            "startTimeMs": "4020",
            "words": "Ooh-ooh, ooh-ooh-ooh",
            "syllables": [],
            "endTimeMs": "0"
        }
    ]
}

Changing format to lrc

http://localhost:8080/?trackid=5f8eCNwTlr0RJopE9vQ6mB&format=lrc

response:

{
    "error": false,
    "syncType": "LINE_SYNCED",
    "lines": [
        {
            "timeTag": "00:00.96",
            "words": "One, two, three, four"
        },
        {
            "timeTag": "00:04.02",
            "words": "Ooh-ooh, ooh-ooh-ooh"
        }
    ]
}

Responses

Different Responses given out by the API, are listed here.

If any error occurs the value of the error key will be set to true else false

"error": false //no error occured

Most of the lyrics are time synced or have timetags and some aren't time synced or have timetags. To differentiate between synced and unsynced we have key syncType.

"syncType": "LINE_SYNCED"

Musixmatch supports Line synced and Word synced type of timed lyrics. Line Synced is the timetag is given till which the line is sang and the word synced lyrics time specifed when the word comes up in the song. For now Spotify only supports line synced. Maybe they would support word synced in the future :/.

LINE Synced

{
    "error": false,
    "syncType": "LINE_SYNCED",
    "lines": [
        {
            "timeTag": "00:00.96",
            "words": "One, two, three, four"
        },
        {
            "timeTag": "00:04.02",
            "words": "Ooh-ooh, ooh-ooh-ooh"
        }
    ]
}

NOT Synced or Unsynced

Note the timeTags is set to 00:00.00.

{
    "error": false,
    "syncType": "UNSYNCED",
    "lines": [
        {
            "timeTag": "00:00.00",
            "words": "jaane nahin denge tuje"
        },
        {
            "timeTag": "00:00.00",
            "words": "chaahe tujh ko rab bulaa le, hum naa rab se darane waale"
        }
    ]
}

Error Messages

When trackid and url both are not given (400 Bad Request)

error response:

{
    "error": true,
    "message": "url or trackid parameter is required!"
}

When no lyrics found on spotify for given track (404 Not Found)

error response:

{
    "error": true,
    "message": "lyrics for this track is not available on spotify!"
}

Using as package

Install using composer require akashrchandran/spotify-lyrics-api.

Include the package's autoloader file in your PHP code and call class Spotify().

<?php
require './vendor/autoload.php';

use SpotifyLyricsApi\Spotify;
use SpotifyLyricsApi\SpotifyException;

$spotify = new Spotify("SP_DC here");

try {
    $spotify->checkTokenExpire();
    $lyrics = $spotify->getLyrics(track_id: "1418IuVKQPTYqt7QNJ9RXN");
    
    // $lyrics contains the parsed lyrics data
    echo "Sync Type: " . $lyrics['lyrics']['syncType'] . "\n";
    
    foreach ($lyrics['lyrics']['lines'] as $line) {
        echo "[" . $line['startTimeMs'] . "] " . $line['words'] . "\n";
    }
} catch (SpotifyException $e) {
    // Handle errors (rate limiting, not found, etc.)
    echo "Error: " . $e->getMessage() . "\n";
    echo "Status Code: " . $e->getCode() . "\n";
}

Formatting Lyrics

// Get lyrics in LRC format
$lrcLines = $spotify->getLrcLyrics($lyrics['lyrics']['lines']);

// Get lyrics in SRT format
$srtLines = $spotify->getSrtLyrics($lyrics['lyrics']['lines']);

// Get raw lyrics (plain text)
$rawLines = $spotify->getRawLyrics($lyrics['lyrics']['lines']);

image

Deployment

Want to host your own version of this API, But first you need SP_DC cookie from spotify

Finding SP_DC

You will find the detailed guide here.

Heroku

Deploy

Vercel

Deploy with Vercel

Run locally

use git to clone the repo to your local machine or you can download the latest zip file and extract it.

You need to have PHP installed on you machine to run this program.

Enter into the folder via terminal

cd spotify-lyrics-api

Set SP_DC token as environment variable temprorily

export SP_DC=[token here and remove the square brackets]

Start the server

php -S localhost:8080 api/index.php

now open your browser and type localhost:8080 and you should see the program running.

Credits

• Me -> For everything.

Similar Projects

Discover other similar projects and AI models.

Repository
WXRIW/Lyricify-App

Lyricify (/lɪ'rɪsəfaɪ/), a fantastic app to provide scroll lyrics for Spotify, Apple Music and other apps. 一款为 Spotify、Apple Music 等各种应用提供滚动歌词的软件。

7.4k
Nov 3, 2026
RepositorySwift
ddddxxx/LyricsX

🎶 Ultimate lyrics app for macOS.

5.3k
Jul 22, 2026
RepositoryVue
tranxuanthang/lrcget

Utility for mass-downloading LRC synced lyrics for your offline music library.

3.4k
Nov 20, 2026
RepositoryRust
tranxuanthang/lrclib

LRCLIB server written in Rust with Axum and SQLite3 database

2.3k
Nov 10, 2026
RepositoryTypeScript
Chevron7Locked/kima-hub

Kima Hub is built for music lovers who want the convenience of streaming services without sacrificing ownership of their library. Point it at your music collection, and Kima handles the rest: artist discovery, personalized playlists, podcast subscriptions, and seamless integration with tools you already use like Lidarr and Audiobookshelf.

1.3k
Nov 20, 2026
RepositoryTypeScript
tryliner/desktop

🔥💿 Liner is a desktop player for Windows and Linux that lets you pull your music and playlists from other platforms into one clean app. No ads and bloated features, just synced lyrics and your tracks without anything getting in the way.

1.2k
Dec 2, 2026
RepositoryJavaScript
mantou132/Spotify-Lyrics

🎉 Desktop Spotify Web Player Instant Synchronised Lyrics

1.1k
Nov 11, 2026
RepositoryGo
raitonoberu/sptlrx

Synchronized lyrics in your terminal

531
Apr 5, 2026
RepositoryPython
EbookFoundation/free-programming-books

:books: Freely available programming books

403.1k
Dec 3, 2026