PHPackages                             akashrchandran/spotify-lyrics-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. akashrchandran/spotify-lyrics-api

ActiveLibrary[API Development](/categories/api)

akashrchandran/spotify-lyrics-api
=================================

A Rest API for fetching lyrics from Spotify which is powered by Musixmatch.

v2.2.1(4mo ago)60366248[2 issues](https://github.com/akashrchandran/spotify-lyrics-api/issues)GPL-3.0-onlyPHPPHP ^8.0.0CI passing

Since Jan 12Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/akashrchandran/spotify-lyrics-api)[ Packagist](https://packagist.org/packages/akashrchandran/spotify-lyrics-api)[ RSS](/packages/akashrchandran-spotify-lyrics-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)DependenciesVersions (11)Used By (0)

[![spotify-lyrics-api](https://private-user-images.githubusercontent.com/78685510/297702352-12000a6d-ee53-41c4-9c69-98bc2559c5ed.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1NDk4MTEsIm5iZiI6MTc3NTU0OTUxMSwicGF0aCI6Ii83ODY4NTUxMC8yOTc3MDIzNTItMTIwMDBhNmQtZWU1My00MWM0LTljNjktOThiYzI1NTljNWVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA3VDA4MTE1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEwOWQ2MjYwYTAzZDRlNGVkYWU0MzE1ZGY3Njk4ZWZlYjcyN2JjOTcwYTExMjEzMjE1N2JiZTRhNGNlMjJmNzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0z7RFZ6uUIw-4br6gOZIeM6nFoNHDeX9d6YCIKOXV60)](https://private-user-images.githubusercontent.com/78685510/297702352-12000a6d-ee53-41c4-9c69-98bc2559c5ed.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzU1NDk4MTEsIm5iZiI6MTc3NTU0OTUxMSwicGF0aCI6Ii83ODY4NTUxMC8yOTc3MDIzNTItMTIwMDBhNmQtZWU1My00MWM0LTljNjktOThiYzI1NTljNWVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA0MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA3VDA4MTE1MVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEwOWQ2MjYwYTAzZDRlNGVkYWU0MzE1ZGY3Njk4ZWZlYjcyN2JjOTcwYTExMjEzMjE1N2JiZTRhNGNlMjJmNzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0z7RFZ6uUIw-4br6gOZIeM6nFoNHDeX9d6YCIKOXV60)

---

A Rest API for fetching lyrics from Spotify which is powered by Musixmatch. Commandline version is available [akashrchandran/syrics](https://github.com/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
=======================

[](#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

[](#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](https://hub.docker.com/r/akashrchandran/spotify-lyrics-api)

Install using Composer
======================

[](#install-using-composer)

```
composer require akashrchandran/spotify-lyrics-api

```

Fetching Lyrics
===============

[](#fetching-lyrics)

> For now it only supports track id or link.

Using GET Requests
------------------

[](#using-get-requests)

> You have to use query paramters to send data

**Available Parameters:**

ParameterDefault valueTypeDescription`trackid `NoneStringThe trackid from spotify.`url`NoneStringThe 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

[](#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

[](#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

[](#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
================

[](#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()`.

```
