spotify-lyrics-api: Fetch Spotify Lyrics with a Powerful REST API

This repository profile is provided by osrepos.com, an open source repository discovery platform.

spotify-lyrics-api: Fetch Spotify Lyrics with a Powerful REST API

Summary

The spotify-lyrics-api is a robust REST API designed to fetch lyrics directly from Spotify, powered by Musixmatch. It offers various output formats like ID3, LRC, SRT, and raw text, making it highly versatile for developers. With convenient Docker deployment and a PHP package, integrating Spotify lyrics into your projects has never been easier.

Repository Information

Analyzed by OSRepos on June 17, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

The spotify-lyrics-api is a powerful REST API designed to fetch lyrics directly from Spotify, leveraging the data from Musixmatch. This project provides a simple and efficient way to integrate Spotify lyrics into your applications, supporting various output formats including ID3, LRC, SRT, and raw text. It allows developers to retrieve lyrics using either a Spotify track ID or a track URL.

Please note, as stated by the project maintainer, this project might be against Spotify's Terms of Service. Use it at your own risk. For a command-line version, you can explore akashrchandran/syrics.

Installation

Getting spotify-lyrics-api up and running is straightforward, with multiple deployment options available:

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.

For 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

Install using Composer

If you prefer to integrate it as a PHP package:

composer require akashrchandran/spotify-lyrics-api

Run Locally

You can also run the API directly on your local machine with PHP installed:

  1. Clone the repository:
    git clone https://github.com/akashrchandran/spotify-lyrics-api.git
    cd spotify-lyrics-api
  2. Set the SP_DC token as a temporary environment variable (find detailed guide here):
    export SP_DC=[your_sp_dc_cookie_here]
  3. Start the PHP server:
    php -S localhost:8080 api/index.php

Examples

The API supports fetching lyrics via GET requests or by using the PHP package.

Using GET Requests

You can use query parameters trackid or url to specify the Spotify track, and format for the desired output.

Example using trackid:

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

Example using url:

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

Example changing format to LRC:

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

The API returns JSON responses, indicating error status, syncType (LINE_SYNCED or UNSYNCED), and an array of lines with startTimeMs (or timeTag for LRC) and words.

Using as a PHP Package

After installing via Composer, you can integrate the functionality into your PHP application:

<?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) {
    echo "Error: " . $e->getMessage() . "\n";
    echo "Status Code: " . $e->getCode() . "\n";
}

You can also format lyrics into LRC, SRT, or raw text:

// 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']);

Why Use It

spotify-lyrics-api offers a developer-friendly solution for accessing Spotify lyrics. Its versatility, with support for various output formats and easy deployment via Docker, Heroku, or Vercel, makes it an excellent choice for projects requiring lyric integration. Whether you're building a music player, a karaoke application, or a data analysis tool, this API simplifies the process of obtaining synchronized or unsynchronized lyrics.

Links

Source repository

Open the original repository on GitHub.

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️