{"name":"spotify-lyrics-api: Fetch Spotify Lyrics with a Powerful REST API","description":"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.","github":"https://github.com/akashrchandran/spotify-lyrics-api","url":"https://osrepos.com/repo/akashrchandran-spotify-lyrics-api","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/akashrchandran-spotify-lyrics-api","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/akashrchandran-spotify-lyrics-api.md","json":"https://osrepos.com/repo/akashrchandran-spotify-lyrics-api.json","topics":["spotify-lyrics-api","spotify","lyrics","musixmatch","REST API","PHP","web development","hacktoberfest"],"keywords":["spotify-lyrics-api","spotify","lyrics","musixmatch","REST API","PHP","web development","hacktoberfest"],"stars":null,"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.","content":"## Introduction\n\nThe `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.\n\nPlease 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](https://github.com/akashrchandran/syrics \"akashrchandran/syrics\").\n\n## Installation\n\nGetting `spotify-lyrics-api` up and running is straightforward, with multiple deployment options available:\n\n### Quick Start with Docker\n\nThe easiest way to run the API is using Docker:\n\nbash\ndocker run -d -p 8080:8080 -e SP_DC=your_sp_dc_cookie akashrchandran/spotify-lyrics-api\n\n\nThen, access the API at `http://localhost:8080/?trackid=YOUR_TRACK_ID`.\n\nFor Docker Compose:\n\nyaml\nservices:\n  spotify-lyrics-api:\n    image: akashrchandran/spotify-lyrics-api:latest\n    ports:\n      - \"8080:8080\"\n    environment:\n      - SP_DC=your_sp_dc_cookie\n    restart: unless-stopped\n\n\n### Install using Composer\n\nIf you prefer to integrate it as a PHP package:\n\nbash\ncomposer require akashrchandran/spotify-lyrics-api\n\n\n### Run Locally\n\nYou can also run the API directly on your local machine with PHP installed:\n\n1.  Clone the repository:\n    sh\n    git clone https://github.com/akashrchandran/spotify-lyrics-api.git\n    cd spotify-lyrics-api\n    \n2.  Set the `SP_DC` token as a temporary environment variable (find detailed guide [here](https://github.com/akashrchandran/syrics/wiki/Finding-sp_dc \"Finding SP_DC cookie guide\")):\n    sh\n    export SP_DC=[your_sp_dc_cookie_here]\n    \n3.  Start the PHP server:\n    sh\n    php -S localhost:8080 api/index.php\n    \n\n## Examples\n\nThe API supports fetching lyrics via GET requests or by using the PHP package.\n\n### Using GET Requests\n\nYou can use query parameters `trackid` or `url` to specify the Spotify track, and `format` for the desired output.\n\n**Example using trackid:**\n\n\nhttp://localhost:8080/?trackid=5f8eCNwTlr0RJopE9vQ6mB\n\n\n**Example using url:**\n\n\nhttp://localhost:8080/?url=https://open.spotify.com/track/5f8eCNwTlr0RJopE9vQ6mB?autoplay=true\n\n\n**Example changing format to LRC:**\n\n\nhttp://localhost:8080/?trackid=5f8eCNwTlr0RJopE9vQ6mB&format=lrc\n\n\nThe 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`.\n\n### Using as a PHP Package\n\nAfter installing via Composer, you can integrate the functionality into your PHP application:\n\nphp\n<?php\nrequire './vendor/autoload.php';\n\nuse SpotifyLyricsApi\\Spotify;\nuse SpotifyLyricsApi\\SpotifyException;\n\n$spotify = new Spotify(\"SP_DC here\");\n\ntry {\n    $spotify->checkTokenExpire();\n    $lyrics = $spotify->getLyrics(track_id: \"1418IuVKQPTYqt7QNJ9RXN\");\n    \n    // $lyrics contains the parsed lyrics data\n    echo \"Sync Type: \" . $lyrics['lyrics']['syncType'] . \"\\n\";\n    \n    foreach ($lyrics['lyrics']['lines'] as $line) {\n        echo \"[\" . $line['startTimeMs'] . \"] \" . $line['words'] . \"\\n\";\n    }\n} catch (SpotifyException $e) {\n    echo \"Error: \" . $e->getMessage() . \"\\n\";\n    echo \"Status Code: \" . $e->getCode() . \"\\n\";\n}\n\n\nYou can also format lyrics into LRC, SRT, or raw text:\n\nphp\n// Get lyrics in LRC format\n$lrcLines = $spotify->getLrcLyrics($lyrics['lyrics']['lines']);\n\n// Get lyrics in SRT format\n$srtLines = $spotify->getSrtLyrics($lyrics['lyrics']['lines']);\n\n// Get raw lyrics (plain text)\n$rawLines = $spotify->getRawLyrics($lyrics['lyrics']['lines']);\n\n\n## Why Use It\n\n`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.\n\n## Links\n\n*   **GitHub Repository:** [akashrchandran/spotify-lyrics-api](https://github.com/akashrchandran/spotify-lyrics-api \"GitHub Repository\")\n*   **Docker Hub:** [akashrchandran/spotify-lyrics-api](https://hub.docker.com/r/akashrchandran/spotify-lyrics-api \"Docker Hub\")\n*   **Command-line version (syrics):** [akashrchandran/syrics](https://github.com/akashrchandran/syrics \"Command-line version\")\n*   **Deploy to Heroku:** [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://dashboard.heroku.com/new?template=https://github.com/akashrchandran/spotify-lyrics-api \"Deploy to Heroku\")\n*   **Deploy with Vercel:** [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fakashrchandran%2Fspotify-lyrics-api%2Ftree%2Fmain&env=SP_DC&envDescription=Want%20to%20host%20your%20own%20version%20of%20this%20API%2C%20then%20you'll%20first%20need%20SP_DC%20cookie%20from%20spotify.&envLink=https%3A%2F%2Fgithub.com%2Fakashrchandran%2Fsyrics%2Fwiki%2FFinding-sp_dc&project-name=spotify-lyrics-api&repository-name=spotify-lyrics-api&redirect-url=https%3A%2F%2Fgithub.com%2Fakashrchandran%2Fspotify-lyrics-api%23examples \"Deploy with Vercel\")","metrics":{"detailViews":3,"githubClicks":1},"dates":{"published":null,"modified":"2026-06-17T19:21:35.000Z"}}